@trenskow/app 0.5.12 → 0.5.13

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.
package/README.md CHANGED
@@ -497,6 +497,8 @@ Supported HTTP methods are the same as those returned by [`http.METHODS`](https:
497
497
 
498
498
  You can only call these methods once per method per endpoint – calling it multiple times will result in only the last one getting used.
499
499
 
500
+ These also ends routing. After a method route has been called, the routing will go strait to the renderer.
501
+
500
502
  > Returns the endpoint.
501
503
 
502
504
  ###### Parameters
@@ -505,7 +507,7 @@ You can only call these methods once per method per endpoint – calling it mult
505
507
  | ---------- | ------------------------------ | :------------------------------------------------------: | :----------------: | :-----------: |
506
508
  | `handlers` | A (or an array of) handlers. * | Function, AsyncFunction or Array ([see also](#handlers)) | :white_check_mark: | |
507
509
 
508
- > \* When more than one handler are provided all but the last are treated as `.use` handlers (but specific to the HTTP method). Only the return value of the last handler is sent to the renderer.
510
+ > \* When more than one handler is provided only the return value of the last handler that returned a non-undefined value will be send the the renderer.
509
511
 
510
512
  ###### Example
511
513
 
package/lib/endpoint.js CHANGED
@@ -236,7 +236,7 @@ export default class Endpoint extends Router {
236
236
  for (let handler of layer.handlers) {
237
237
  const result = await handler(context);
238
238
  if (context.state !== 'routing') return;
239
- context.result = result;
239
+ if (typeof result !== 'undefined') context.result = result;
240
240
  }
241
241
 
242
242
  return context.result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trenskow/app",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "A small HTTP router.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -25,12 +25,12 @@
25
25
  },
26
26
  "homepage": "https://github.com/trenskow/app#readme",
27
27
  "devDependencies": {
28
- "eslint": "^8.2.0",
29
- "mocha": "^9.1.3",
30
- "supertest": "^6.1.6"
28
+ "eslint": "^8.13.0",
29
+ "mocha": "^9.2.2",
30
+ "supertest": "^6.2.2"
31
31
  },
32
32
  "dependencies": {
33
- "@trenskow/api-error": "^2.2.4",
34
- "@trenskow/caseit": "^1.1.1"
33
+ "@trenskow/api-error": "^2.2.5",
34
+ "@trenskow/caseit": "^1.1.3"
35
35
  }
36
36
  }
package/test/index.js CHANGED
@@ -93,7 +93,9 @@ describe('Application', () => {
93
93
  new Endpoint()
94
94
  .get(() => 'Ignore this!')
95
95
  .post(() => 'Not used')
96
- .get(() => 'Hello, World!')
96
+ .get(
97
+ () => 'Hello, World!',
98
+ () => { /* Ignore this */ })
97
99
  );
98
100
 
99
101
  await request