Comparing version 1.1.1 to 1.2.0
@@ -16,5 +16,3 @@ module.exports = function handleRequest (req, res, routeList, routers) { | ||
return setImmediate(() => mw(req, res, next)) | ||
} | ||
if (routers) { | ||
} else if (routers) { | ||
try { | ||
@@ -24,8 +22,12 @@ const method = req.method.toLowerCase() | ||
const router = routers.get(method) | ||
router(url, req, res) | ||
router(url, req, res, next) | ||
} catch (err) { | ||
return res.err(404) | ||
} | ||
} else { | ||
if (!res.finished) { | ||
res.end() | ||
} | ||
} | ||
} | ||
} |
{ | ||
"name": "take-five", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Very minimal JSON-REST server", | ||
@@ -5,0 +5,0 @@ "main": "take-five.js", |
@@ -85,4 +85,5 @@ # take-five | ||
### `next:function` | ||
You must either send data down to the client (and `end` the request either though `send`, `err` or `end`) or call `next` to invoke the next function in the route list. If there is no function remaining in the stack, and you haven't send data to the client, the client will hang until the socket timeout occurs. | ||
If you are done processing the request, but you want a later handler to be able to modify the response, call next. This will invoke the next handler in the stack. If there are no more handlers left, it will call `res.end()` and send the response as is. If you want to immediately send the response, you can call `res.end`, `res.send` or `res.err` directly. | ||
## Do we need another REST server? | ||
@@ -89,0 +90,0 @@ Probably not, but [`restify`](http://restify.com), [`hapi`](http://hapijs.com) and [`express`](http://expressjs.com) are all over-kill on the types of services I'm building for the most part. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
105336
27
591
110
3