@middy/http-router 7.3.0 → 7.3.2
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/index.js +27 -4
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -12,16 +12,39 @@ const defaults = {
|
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
const methods = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]; // ANY excluded by design
|
|
16
|
+
|
|
15
17
|
const optionSchema = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: {
|
|
20
|
+
routes: {
|
|
21
|
+
type: "array",
|
|
22
|
+
uniqueItems: true,
|
|
23
|
+
items: {
|
|
24
|
+
type: "object",
|
|
25
|
+
required: ["method", "path", "handler"],
|
|
26
|
+
properties: {
|
|
27
|
+
method: { type: "string", enum: [...methods, "ANY"] },
|
|
28
|
+
path: {
|
|
29
|
+
allOf: [
|
|
30
|
+
{ type: "string", pattern: "^/" },
|
|
31
|
+
{ type: "string", pattern: "^(/|.*[^/])$" },
|
|
32
|
+
],
|
|
33
|
+
examples: ["/", "/users", "/users/{id}"],
|
|
34
|
+
},
|
|
35
|
+
handler: { instanceof: "Function" },
|
|
36
|
+
},
|
|
37
|
+
additionalProperties: false,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
notFoundResponse: { instanceof: "Function" },
|
|
41
|
+
},
|
|
42
|
+
additionalProperties: false,
|
|
18
43
|
};
|
|
19
44
|
|
|
20
45
|
export const httpRouterValidateOptions = (options) =>
|
|
21
46
|
validateOptions("@middy/http-router", optionSchema, options);
|
|
22
47
|
|
|
23
|
-
const methods = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]; // ANY excluded by design
|
|
24
|
-
|
|
25
48
|
const httpRouteHandler = (opts = {}) => {
|
|
26
49
|
let options;
|
|
27
50
|
if (Array.isArray(opts)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-router",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.2",
|
|
4
4
|
"description": "HTTP event router for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"url": "https://github.com/sponsors/willfarrell"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@middy/util": "7.3.
|
|
65
|
+
"@middy/util": "7.3.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@middy/core": "7.3.
|
|
68
|
+
"@middy/core": "7.3.2",
|
|
69
69
|
"@types/aws-lambda": "^8.0.0",
|
|
70
70
|
"@types/node": "^22.0.0"
|
|
71
71
|
}
|