@trenskow/app 0.5.10 → 0.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/endpoint.js +16 -10
  2. package/package.json +1 -1
package/lib/endpoint.js CHANGED
@@ -178,16 +178,22 @@ export default class Endpoint extends Router {
178
178
 
179
179
  async _route(path, context, next, idx = 0) {
180
180
 
181
- if (idx === this._layers.length && path.isLast) {
181
+ if (idx === this._layers.length) {
182
182
 
183
- const methods = this._layers
184
- .filter((layer) => layer.type === 'method')
185
- .map((layer) => layer.method.toUpperCase())
186
- .filter((value, index, array) => array.indexOf(value) === index);
183
+ if (path.isLast) {
187
184
 
188
- if (methods.length) {
189
- context.response.headers.allow = methods.join(', ');
190
- throw new ApiError.MethodNotAllowed();
185
+ const methods = this._layers
186
+ .filter((layer) => layer.type === 'method')
187
+ .map((layer) => layer.method.toUpperCase())
188
+ .filter((value, index, array) => array.indexOf(value) === index);
189
+
190
+ if (methods.length) {
191
+ context.response.headers.allow = methods.join(', ');
192
+ throw new ApiError.MethodNotAllowed();
193
+ }
194
+
195
+ } else {
196
+ throw new ApiError.NotFound();
191
197
  }
192
198
 
193
199
  }
@@ -242,8 +248,8 @@ export default class Endpoint extends Router {
242
248
  if (typeof layer.transform === 'function') {
243
249
  context.parameters[layer.name] = await layer.transform(
244
250
  Object.fromEntries([
245
- [ 'context', context ],
246
- [ layer.name, component ]
251
+ ['context', context],
252
+ [layer.name, component]
247
253
  ])
248
254
  );
249
255
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trenskow/app",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
4
4
  "description": "A small HTTP router.",
5
5
  "type": "module",
6
6
  "main": "index.js",