From 8eb86eea8b6d07b0e3962599c02a2f7fe140d950 Mon Sep 17 00:00:00 2001 From: 3imed-jaberi Date: Sat, 13 Jun 2020 16:22:03 +0200 Subject: [PATCH] =?UTF-8?q?=20add=20practical=20example=20wit=20koa=20v1/v?= =?UTF-8?q?2=20=F0=9F=A4=A0=20..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo.js | 15 --------------- examples/koa-v1.js | 15 +++++++++++++++ examples/koa-v2.js | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 15 deletions(-) delete mode 100644 demo.js create mode 100644 examples/koa-v1.js create mode 100644 examples/koa-v2.js diff --git a/demo.js b/demo.js deleted file mode 100644 index c0f1c14..0000000 --- a/demo.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -var jsonp = require('./'); -var koa = require('koa'); - -var app = koa(); -jsonp(app, { - callback: '_callback' // default is 'callback' -}); - -app.use(function* () { - this.jsonp = {foo: 'bar'}; -}); - -app.listen(1984); diff --git a/examples/koa-v1.js b/examples/koa-v1.js new file mode 100644 index 0000000..25100cd --- /dev/null +++ b/examples/koa-v1.js @@ -0,0 +1,15 @@ +'use strict'; + +const jsonp = require('.'); +const koa = require('koa'); + +const app = koa(); +jsonp(app, { + callback: '_callback' // default is 'callback' +}); + +app.use(function* () { + this.jsonp = { foo: 'bar' }; +}); + +app.listen(1984); \ No newline at end of file diff --git a/examples/koa-v2.js b/examples/koa-v2.js new file mode 100644 index 0000000..ea91a9e --- /dev/null +++ b/examples/koa-v2.js @@ -0,0 +1,15 @@ +'use strict'; + +const jsonp = require('.'); +const Koa = require('koa'); + +const app = new Koa(); +jsonp(app, { + callback: '_callback' // default is 'callback' +}); + +app.use(function (ctx) { + ctx.jsonp = { foo: 'bar' }; +}); + +app.listen(1984); \ No newline at end of file