Comparing version
@@ -8,2 +8,7 @@ # Nodecaf Changelog | ||
## [v0.11.2] - 2020-12-12 | ||
### Fixed | ||
- `all()` responding 404 to / path | ||
## [v0.11.1] - 2020-11-24 | ||
@@ -446,1 +451,2 @@ | ||
[v0.11.1]: https://gitlab.com/GCSBOSS/nodecaf/-/tags/v0.11.1 | ||
[v0.11.2]: https://gitlab.com/GCSBOSS/nodecaf/-/tags/v0.11.2 |
@@ -109,2 +109,8 @@ const assert = require('assert'); | ||
function moveAllPathParam({ params, next }){ | ||
params.path = params['0']; | ||
delete params['0']; | ||
next(); | ||
} | ||
module.exports = class API { | ||
@@ -126,3 +132,3 @@ | ||
proxy.all = (...chain) => METHODS.forEach(m => | ||
this.addEndpoint(m.toLowerCase(), '/:path*', ...chain)); | ||
this.addEndpoint(m.toLowerCase(), '(.*)', moveAllPathParam, ...chain)); | ||
@@ -129,0 +135,0 @@ spec.apply(context, [ proxy ]); |
{ | ||
"name": "nodecaf", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "Nodecaf is a light framework for developing RESTful Apps in a quick and convenient manner.", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
@@ -323,11 +323,8 @@ const assert = require('assert'); | ||
api({ all }){ | ||
all(({ res, params }) => { | ||
res.badRequest(!params.path); | ||
res.end(); | ||
}); | ||
all(({ res, params }) => res.end(params.path)); | ||
} | ||
}); | ||
await app.start(); | ||
assert.strictEqual((await app.trigger('post', '/foo/bar')).status, 200); | ||
assert.strictEqual((await app.trigger('get', '/foo/baz')).status, 200); | ||
assert.strictEqual((await app.trigger('post', '/foo/bar')).body, '/foo/bar'); | ||
assert.strictEqual((await app.trigger('get', '/')).body, '/'); | ||
await app.stop(); | ||
@@ -334,0 +331,0 @@ }); |
93861
0.2%1409
0.14%