Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove limiter && add convert method
- Loading branch information
1 parent
151823c
commit cd5340d
Showing
11 changed files
with
84 additions
and
98 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,4 +1,6 @@ | ||
node_modules | ||
coverage | ||
.vscode | ||
typings | ||
typings | ||
jsconfig.json | ||
lib |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
'use strict' | ||
const {router, route} = require('./router') | ||
const required = require('./required') | ||
const limiter = require('./limiter') | ||
const convert = require('./public/convert') | ||
|
||
module.exports = { | ||
router, | ||
route, | ||
required, | ||
limiter | ||
convert | ||
} |
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,17 @@ | ||
'use strict' | ||
const assert = require('assert') | ||
const {sureIsArray, decorate} = require('../private/utils') | ||
|
||
function handleDescriptor (target, name, descriptor, middleware) { | ||
target[name] = sureIsArray(target[name]) | ||
target[name].splice(target[name].length - 1, 0, middleware) | ||
|
||
return descriptor | ||
} | ||
|
||
function convert (middleware) { | ||
assert(typeof middleware === 'function', 'middleware should be a function') | ||
return decorate(handleDescriptor, [middleware]) | ||
} | ||
|
||
module.exports = convert |
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,17 @@ | ||
'use strict' | ||
/* global describe, it */ | ||
require('should') | ||
const app = require('./fixtures/app') | ||
const obj = require('./fixtures/apis/test') | ||
const request = require('supertest')(app.listen()) | ||
|
||
describe('public-convert', function () { | ||
it('should convert async function to koa middleware', async function () { | ||
let {text} = await request | ||
.get('/convert') | ||
.expect(200) | ||
|
||
text.should.containEql('test') | ||
obj.flag.should.containEql(true) | ||
}) | ||
}) |
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 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
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