@middy/http-router 7.1.0 → 7.1.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.
- package/README.md +1 -1
- package/index.js +7 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<h1>Middy http-router
|
|
2
|
+
<h1>Middy `http-router` router</h1>
|
|
3
3
|
<img alt="Middy logo" src="https://raw.githubusercontent.com/middyjs/middy/main/docs/img/middy-logo.svg"/>
|
|
4
4
|
<p><strong>HTTP router for the middy framework, the stylish Node.js middleware engine for AWS Lambda</strong></p>
|
|
5
5
|
<p>
|
package/index.js
CHANGED
|
@@ -11,6 +11,9 @@ const defaults = {
|
|
|
11
11
|
throw err;
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
|
+
|
|
15
|
+
const methods = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]; // ANY excluded by design
|
|
16
|
+
|
|
14
17
|
const httpRouteHandler = (opts = {}) => {
|
|
15
18
|
let options;
|
|
16
19
|
if (Array.isArray(opts)) {
|
|
@@ -47,16 +50,16 @@ const httpRouteHandler = (opts = {}) => {
|
|
|
47
50
|
attachDynamicRoute(method, path, handler, routesDynamic);
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
const handler = (event, context, abort) => {
|
|
51
54
|
const { method, path } = getVersionRoute[pickVersion(event)](event);
|
|
52
55
|
|
|
53
56
|
if (!method) {
|
|
54
|
-
throw new Error("Unknown
|
|
57
|
+
throw new Error("Unknown HTTP event format", {
|
|
55
58
|
cause: { package: "@middy/http-router", data: { method } },
|
|
56
59
|
});
|
|
57
60
|
}
|
|
58
61
|
if (!path) {
|
|
59
|
-
throw new Error("Unknown
|
|
62
|
+
throw new Error("Unknown HTTP event format", {
|
|
60
63
|
cause: { package: "@middy/http-router", data: { path } },
|
|
61
64
|
});
|
|
62
65
|
}
|
|
@@ -87,13 +90,12 @@ const httpRouteHandler = (opts = {}) => {
|
|
|
87
90
|
// Not Found
|
|
88
91
|
return notFoundResponse({ method, path });
|
|
89
92
|
};
|
|
93
|
+
return handler;
|
|
90
94
|
};
|
|
91
95
|
|
|
92
96
|
const regExpDynamicWildcards = /\/\{(proxy)\+\}$/;
|
|
93
97
|
const regExpDynamicParameters = /\/\{([^/]+)\}/g;
|
|
94
98
|
|
|
95
|
-
const methods = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]; // ANY excluded by design
|
|
96
|
-
|
|
97
99
|
const attachStaticRoute = (method, path, handler, routesType) => {
|
|
98
100
|
if (method === "ANY") {
|
|
99
101
|
for (const method of methods) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-router",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.1",
|
|
4
4
|
"description": "HTTP event router for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
"url": "https://github.com/sponsors/willfarrell"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@middy/util": "7.1.
|
|
68
|
+
"@middy/util": "7.1.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@middy/core": "7.1.
|
|
72
|
-
"@types/aws-lambda": "^8.
|
|
71
|
+
"@middy/core": "7.1.1",
|
|
72
|
+
"@types/aws-lambda": "^8.0.0"
|
|
73
73
|
},
|
|
74
74
|
"gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
|
|
75
75
|
}
|