jaypie 1.0.46 → 1.0.48

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/README.md +17 -1
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -215,6 +215,7 @@ See `HTTP` for status codes.
215
215
  #### `EXPRESS`
216
216
 
217
217
  * `EXPRESS.PATH.ANY` - String `*` for any path
218
+ * `EXPRESS.PATH.ID` - String `/:id` for an ID path
218
219
  * `EXPRESS.PATH.ROOT` - Regular expression for root path
219
220
 
220
221
  #### `HTTP`
@@ -362,6 +363,7 @@ throw MultiError(errors);
362
363
  | `NotImplementedError` | 400 | "The developer" (you again?) didn't finish this part yet - hopefully a temporary message |
363
364
  | `RejectedError` | 403 | Request filtered prior to processing |
364
365
  | `TeapotError` | 418 | RFC 2324 section-2.3.2 |
366
+ | `UnauthorizedError` | 401 | You need to log in |
365
367
  | `UnavailableError` | 503 | The thing you are looking for cannot come to the phone right now |
366
368
  | `UnhandledError` | 500 | An error that should have been handled wasn't |
367
369
  | `UnreachableCodeError` | 500 | Should not be possible |
@@ -400,6 +402,20 @@ const handler = expressHandler(async(req, res) => {
400
402
  }, { name: "lambdaReference"});
401
403
  ```
402
404
 
405
+ The order of options and handler may be swapped to improve readability. Having lifecycle methods listed before the handler may read more intuitively.
406
+
407
+ ```javascript
408
+ const handler = expressHandler({
409
+ name: "expressOptions",
410
+ setup: [connect],
411
+ teardown: [disconnect],
412
+ }, async(req, res) => {
413
+ // await new Promise(r => setTimeout(r, 2000));
414
+ // log.debug("Hello World");
415
+ return { message: "Hello World" };
416
+ });
417
+ ```
418
+
403
419
  #### Return Types
404
420
 
405
421
  Do not use `res.send` or `res.json` in the handler. The return value of the handler is the response body. The status code is determined by the error thrown or the return value. Custom status codes can be set by calling `res.status` in the handler.
@@ -424,7 +440,7 @@ const handler = expressHandler(async(req) => {
424
440
  // req.locals.key = "static"
425
441
  return { message: "Hello World" };
426
442
  }, {
427
- name: "lambdaReference",
443
+ name: "expressReference",
428
444
  locals: {
429
445
  asyncFn: async() => "async",
430
446
  fn: () => "function",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaypie",
3
- "version": "1.0.46",
3
+ "version": "1.0.48",
4
4
  "author": "Finlayson Studio",
5
5
  "type": "module",
6
6
  "exports": {
@@ -28,9 +28,9 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@jaypie/aws": "^1.0.8",
31
- "@jaypie/core": "^1.0.42",
31
+ "@jaypie/core": "^1.0.43",
32
32
  "@jaypie/datadog": "^1.0.3",
33
- "@jaypie/express": "^1.0.13",
33
+ "@jaypie/express": "^1.0.14",
34
34
  "@jaypie/lambda": "^1.0.13",
35
35
  "@jaypie/mongoose": "^1.0.9"
36
36
  },