-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from jeremydaly/v0.8.1
v0.8.1
- Loading branch information
Showing
7 changed files
with
80 additions
and
13 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
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* Lightweight web framework for your serverless applications | ||
* @author Jeremy Daly <[email protected]> | ||
* @version 0.8.0 | ||
* @version 0.8.1 | ||
* @license MIT | ||
*/ | ||
|
||
|
@@ -184,10 +184,12 @@ class API { | |
if (mw[0].length > 0 && !matched) continue | ||
|
||
// Promisify middleware | ||
await new Promise(r => { | ||
let rtn = mw[1](request,response,() => { r() }) | ||
await new Promise(async r => { | ||
let rtn = await mw[1](request,response,() => { r() }) | ||
if (rtn) response.send(rtn) | ||
if (response._state === 'done') r() // if state is done, resolve promise | ||
}) | ||
|
||
} // end for | ||
|
||
// Execute the primary handler if in processing state | ||
|
@@ -239,7 +241,7 @@ class API { | |
if (response._state === 'processing') { | ||
|
||
// Flag error state (this will avoid infinite error loops) | ||
response._state === 'error' | ||
response._state = 'error' | ||
|
||
// Execute error middleware | ||
for (const err of this._errors) { | ||
|
@@ -372,7 +374,9 @@ class API { | |
|
||
|
||
// Register routes with options | ||
register(fn,options) { | ||
register(fn,opts) { | ||
|
||
let options = typeof opts === 'object' ? opts : {} | ||
|
||
// Extract Prefix | ||
let prefix = options.prefix && options.prefix.toString().trim() !== '' ? | ||
|
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,9 @@ | ||
'use strict' | ||
|
||
module.exports = function(app, opts) { | ||
|
||
app.get('/test-register-no-options', function(req,res) { | ||
res.json({ path: req.path, route: req.route, method: req.method }) | ||
}) | ||
|
||
} // end |
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