-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update the code base, drop support of node<10
Update 06/2020
- Loading branch information
Showing
16 changed files
with
254 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
coverage.html | ||
# OS # | ||
################### | ||
.DS_Store | ||
.idea | ||
Thumbs.db | ||
tmp/ | ||
temp/ | ||
|
||
|
||
# Node.js # | ||
################### | ||
node_modules | ||
package-lock.json | ||
|
||
|
||
# NYC # | ||
################### | ||
coverage | ||
*.lcov | ||
.nyc_output | ||
|
||
|
||
# Files # | ||
################### | ||
*.seed | ||
*.log | ||
*.csv | ||
*.dat | ||
*.out | ||
*.pid | ||
*.gz | ||
|
||
pids | ||
logs | ||
results | ||
|
||
node_modules | ||
npm-debug.log | ||
coverage/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"reporter": "spec", | ||
"timeout": 1000 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extension": [ | ||
".js" | ||
], | ||
"reporter": [ | ||
"text-lcov", | ||
"text", | ||
"lcov" | ||
], | ||
"report-dir": "./coverage", | ||
"temp-dir": "./.nyc_output" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- '4' | ||
- '3' | ||
- '2' | ||
- '1' | ||
script: "npm run test-cov" | ||
- 10 | ||
- 12 | ||
- 14 | ||
script: | ||
- npm run ci | ||
after_script: | ||
- "npm i codecov.io && cat ./coverage/coverage.json | ./node_modules/codecov.io/bin/codecov.io.js" | ||
- npm i codecov.io | ||
- cat ./coverage/coverage.json | ./node_modules/codecov.io/bin/codecov.io.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,23 @@ | ||
/**! | ||
* Copyright(c) koajs and other contributors. | ||
* MIT Licensed | ||
* | ||
* Authors: | ||
* fengmk2 <[email protected]> (http://fengmk2.com) | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var jsonpBody = require('jsonp-body'); | ||
|
||
module.exports = jsonp; | ||
const jsonpBody = require('jsonp-body'); | ||
|
||
function jsonp(app, options) { | ||
// eslint-disable-next-line func-names | ||
module.exports = function jsonp(app, options) { | ||
options = options || {}; | ||
var callback = options.callback || 'callback'; | ||
const callback = options.callback || 'callback'; | ||
|
||
// eslint-disable-next-line accessor-pairs | ||
Object.defineProperty(app.context, 'jsonp', { | ||
set: function (obj) { | ||
var jsonpFunction = this.query[callback]; | ||
if (!jsonpFunction) { | ||
return this.body = obj; | ||
} | ||
set(object) { | ||
const jsonpFunc = this.query[callback]; | ||
// eslint-disable-next-line no-return-assign | ||
if (!jsonpFunc) return (this.body = object); // eslint-disable-line no-setter-return | ||
|
||
this.set('X-Content-Type-Options', 'nosniff'); | ||
this.type = 'js'; | ||
this.body = jsonpBody(obj, jsonpFunction, options); | ||
this.body = jsonpBody(object, jsonpFunc, options); | ||
}, | ||
configurable: true | ||
}); | ||
} | ||
}; |
Oops, something went wrong.