@middy/http-cors 4.0.0 → 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 -78
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -36,84 +36,6 @@
36
36
  <p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/http-cors">https://middy.js.org/docs/middlewares/http-cors</a></p>
37
37
  </div>
38
38
 
39
- This middleware sets HTTP CORS headers (`Access-Control-Allow-Origin`, `Access-Control-Allow-Headers`, `Access-Control-Allow-Credentials`), necessary for making cross-origin requests, to the response object.
40
-
41
- Sets headers in `after` and `onError` phases.
42
-
43
-
44
- ## Install
45
-
46
- To install this middleware you can use NPM:
47
-
48
- ```bash
49
- npm install --save @middy/http-cors
50
- ```
51
-
52
- ## Options
53
-
54
- - `credentials` (boolean) (default `undefined`): if true, sets `Access-Control-Allow-Credentials`
55
- - `headers` (string) (default `undefined`): value to put in `Access-Control-Allow-Headers`
56
- - `methods` (string) (default `undefined`): value to put in `Access-Control-Allow-Methods`
57
- - `getOrigin` (function(incomingOrigin:string, options)): take full control of the generating the returned origin. Defaults to using the origin or origins option.
58
- - `origin` (string) (default `'*'`): origin to put in the header
59
- - `origins` (array) (default `[]`): An array of allowed origins. The incoming origin is matched against the list and is returned if present.
60
- - `exposeHeaders` (string) (default `undefined`): value to put in `Access-Control-Expose-Headers`
61
- - `maxAge` (string) (default `undefined`): value to put in `Access-Control-Max-Age` header
62
- - `requestHeaders` (string) (default `undefined`): value to put in `Access-Control-Request-Headers`
63
- - `requestMethods` (string) (default `undefined`): value to put in `Access-Control-Request-Methods`
64
- - `cacheControl` (string) (default `undefined`): value to put in `Cache-Control header` on pre-flight (OPTIONS) requests
65
- - `vary` (string) (default `undefined`): value to put in `Vary`, will set to `Origin` if `Access-Control-Allow-Origin` is not `*` and option unset.
66
-
67
- ```javascript
68
- import middy from '@middy/core'
69
- import httpErrorHandler from '@middy/http-error-handler'
70
- import cors from '@middy/http-cors'
71
-
72
- const handler = middy((event, context) => {
73
- throw new createError.UnprocessableEntity()
74
- })
75
- handler.use(httpErrorHandler())
76
- .use(cors())
77
-
78
- // when Lambda runs the handler...
79
- handler({}, {}, (_, response) => {
80
- t.is(response.headers['Access-Control-Allow-Origin'],'*')
81
- t.deepEqual(response,{
82
- statusCode: 422,
83
- body: 'Unprocessable Entity'
84
- })
85
- })
86
- ```
87
-
88
- ## Sample usage
89
-
90
- ```javascript
91
- import middy from '@middy/core'
92
- import cors from '@middy/http-cors'
93
-
94
- const handler = middy((event, context) => {
95
- return {}
96
- })
97
-
98
- handler.use(cors())
99
-
100
- // when Lambda runs the handler...
101
- handler({}, {}, (_, response) => {
102
- t.is(response.headers['Access-Control-Allow-Origin'],'*')
103
- })
104
- ```
105
-
106
-
107
- ## Middy documentation and examples
108
-
109
- 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).
110
-
111
-
112
- ## Contributing
113
-
114
- 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).
115
-
116
-
117
39
  ## License
118
40
 
119
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-cors",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "CORS (Cross-Origin Resource Sharing) middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -60,11 +60,11 @@
60
60
  "url": "https://github.com/middyjs/middy/issues"
61
61
  },
62
62
  "homepage": "https://middy.js.org",
63
- "gitHead": "582286144bcd79968a8c7c2f8867a23c80079a47",
63
+ "gitHead": "c5ece2bfbb0d607dcdea5685bf194a6cc19acc8d",
64
64
  "dependencies": {
65
- "@middy/util": "4.0.0"
65
+ "@middy/util": "4.0.1"
66
66
  },
67
67
  "devDependencies": {
68
- "@middy/core": "4.0.0"
68
+ "@middy/core": "4.0.1"
69
69
  }
70
70
  }