@middy/http-error-handler 4.0.0-alpha.4 → 4.0.1

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 +0 -55
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -36,61 +36,6 @@
36
36
  <p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/http-error-handler">https://middy.js.org/docs/middlewares/http-error-handler</a></p>
37
37
  </div>
38
38
 
39
- Automatically handles uncaught errors that contain the properties `statusCode` (number) and `message` (string) and creates a proper HTTP response
40
- for them (using the message and the status code provided by the error object). Additionally, support for the property `expose` is included with a default value of `statusCode < 500`.
41
- We recommend generating these HTTP errors with the npm module [`http-errors`](https://npm.im/http-errors). When manually catching and setting errors with `statusCode >= 500` setting `{expose: true}`
42
- is needed for them to be handled.
43
-
44
- This middleware should be set as the last error handler unless you also want to register the `http-response-serializer`. If so, this middleware should come second-last and the `http-response-serializer` should come last.
45
-
46
-
47
- ## Install
48
-
49
- To install this middleware you can use NPM:
50
-
51
- ```bash
52
- npm install --save @middy/http-error-handler
53
- ```
54
-
55
-
56
- ## Options
57
-
58
- - `logger` (function) (default `console.error`) - a logging function that is invoked with the current error as an argument. You can pass `false` if you don't want the logging to happen.
59
- - `fallbackMessage` (string) (default `undefined`) - When non-http errors occur you can catch them by setting a fallback message to be used. These will be returned with a 500 status code.
60
-
61
- ## Sample usage
62
-
63
- ```javascript
64
- import middy from '@middy/core'
65
- import httpErrorHandler from '@middy/http-error-handler'
66
-
67
- const handler = middy((event, context) => {
68
- throw new createError.UnprocessableEntity()
69
- })
70
-
71
- handler
72
- .use(httpErrorHandler())
73
-
74
- // when Lambda runs the handler...
75
- handler({}, {}, (_, response) => {
76
- t.deepEqual(response,{
77
- statusCode: 422,
78
- body: 'Unprocessable Entity'
79
- })
80
- })
81
- ```
82
-
83
-
84
- ## Middy documentation and examples
85
-
86
- For more documentation and examples, refers to the main [Middy monorepo on GitHub](https://github.com/middyjs/middy) or [Middy official website](https://middy.js.org).
87
-
88
-
89
- ## Contributing
90
-
91
- Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/middyjs/middy/issues) or to [submit Pull Requests](https://github.com/middyjs/middy/pulls).
92
-
93
-
94
39
  ## License
95
40
 
96
41
  Licensed under [MIT License](LICENSE). Copyright (c) 2017-2022 [Luciano Mammino](https://github.com/lmammino), [will Farrell](https://github.com/willfarrell), and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/http-error-handler",
3
- "version": "4.0.0-alpha.4",
3
+ "version": "4.0.1",
4
4
  "description": "Http error handler middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -63,12 +63,12 @@
63
63
  },
64
64
  "homepage": "https://middy.js.org",
65
65
  "dependencies": {
66
- "@middy/util": "4.0.0-alpha.4"
66
+ "@middy/util": "4.0.1"
67
67
  },
68
68
  "devDependencies": {
69
- "@middy/core": "4.0.0-alpha.4",
70
- "@types/http-errors": "^1.8.0",
69
+ "@middy/core": "4.0.1",
70
+ "@types/http-errors": "^2.0.0",
71
71
  "@types/node": "^18.0.0"
72
72
  },
73
- "gitHead": "cbf2af8e31dab58ed28d26143cd77cca544657ae"
73
+ "gitHead": "c5ece2bfbb0d607dcdea5685bf194a6cc19acc8d"
74
74
  }