@middy/http-cors 7.2.2 → 7.3.0

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 (3) hide show
  1. package/index.d.ts +4 -0
  2. package/index.js +20 -1
  3. package/package.json +3 -6
package/index.d.ts CHANGED
@@ -25,4 +25,8 @@ declare function httpCors(
25
25
  options?: Options,
26
26
  ): middy.MiddlewareObj<unknown, unknown, Error>;
27
27
 
28
+ export declare function httpCorsValidateOptions(
29
+ options?: Record<string, unknown>,
30
+ ): void;
31
+
28
32
  export default httpCors;
package/index.js CHANGED
@@ -1,6 +1,25 @@
1
1
  // Copyright 2017 - 2026 will Farrell, Luciano Mammino, and Middy contributors.
2
2
  // SPDX-License-Identifier: MIT
3
- import { normalizeHttpResponse } from "@middy/util";
3
+ import { normalizeHttpResponse, validateOptions } from "@middy/util";
4
+
5
+ const optionSchema = {
6
+ disableBeforePreflightResponse: "boolean?",
7
+ getOrigin: "function?",
8
+ credentials: (v) => typeof v === "boolean" || typeof v === "string",
9
+ headers: "string?",
10
+ methods: "string?",
11
+ origin: "string?",
12
+ origins: "array?",
13
+ exposeHeaders: "string?",
14
+ maxAge: (v) => typeof v === "number" || typeof v === "string",
15
+ requestHeaders: "array?",
16
+ requestMethods: "array?",
17
+ cacheControl: "string?",
18
+ vary: "string?",
19
+ };
20
+
21
+ export const httpCorsValidateOptions = (options) =>
22
+ validateOptions("@middy/http-cors", optionSchema, options);
4
23
 
5
24
  const hostnameToPunycode = (hostname) => {
6
25
  const placeholder = "-_ANY_-";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/http-cors",
3
- "version": "7.2.2",
3
+ "version": "7.3.0",
4
4
  "description": "CORS (Cross-Origin Resource Sharing) middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -17,9 +17,6 @@
17
17
  "import": {
18
18
  "types": "./index.d.ts",
19
19
  "default": "./index.js"
20
- },
21
- "require": {
22
- "default": "./index.js"
23
20
  }
24
21
  }
25
22
  },
@@ -64,10 +61,10 @@
64
61
  "url": "https://github.com/sponsors/willfarrell"
65
62
  },
66
63
  "dependencies": {
67
- "@middy/util": "7.2.2"
64
+ "@middy/util": "7.3.0"
68
65
  },
69
66
  "devDependencies": {
70
- "@middy/core": "7.2.2",
67
+ "@middy/core": "7.3.0",
71
68
  "@types/aws-lambda": "^8.0.0",
72
69
  "@types/node": "^22.0.0"
73
70
  }