@middy/http-router 7.0.0-alpha.2 → 7.0.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.
- package/index.js +6 -10
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -87,8 +87,8 @@ const httpRouteHandler = (opts = {}) => {
|
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
const
|
|
91
|
-
const
|
|
90
|
+
const regExpDynamicWildcards = /\/\{(proxy)\+\}$/;
|
|
91
|
+
const regExpDynamicParameters = /\/\{([^/]+)\}/g;
|
|
92
92
|
|
|
93
93
|
const methods = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]; // ANY excluded by design
|
|
94
94
|
|
|
@@ -99,9 +99,7 @@ const attachStaticRoute = (method, path, handler, routesType) => {
|
|
|
99
99
|
}
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
routesType[method] = {};
|
|
104
|
-
}
|
|
102
|
+
routesType[method] ??= {};
|
|
105
103
|
routesType[method][path] = handler;
|
|
106
104
|
routesType[method][`${path}/`] = handler; // Optional `/`
|
|
107
105
|
};
|
|
@@ -113,12 +111,10 @@ const attachDynamicRoute = (method, path, handler, routesType) => {
|
|
|
113
111
|
}
|
|
114
112
|
return;
|
|
115
113
|
}
|
|
116
|
-
|
|
117
|
-
routesType[method] = [];
|
|
118
|
-
}
|
|
114
|
+
routesType[method] ??= [];
|
|
119
115
|
const pathPartialRegExp = path
|
|
120
|
-
.replace(
|
|
121
|
-
.replace(
|
|
116
|
+
.replace(regExpDynamicWildcards, "/?(?<$1>.*)")
|
|
117
|
+
.replace(regExpDynamicParameters, "/(?<$1>[^/]+)");
|
|
122
118
|
// SAST Skipped: Not accessible by users
|
|
123
119
|
// nosemgrep: javascript.lang.security.audit.detect-non-literal-regexp.detect-non-literal-regexp
|
|
124
120
|
const pathRegExp = new RegExp(`^${pathPartialRegExp}/?$`); // Adds in optional `/`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-router",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "HTTP event router for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"url": "https://github.com/sponsors/willfarrell"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@middy/util": "7.0.0
|
|
67
|
+
"@middy/util": "7.0.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@middy/core": "7.0.0
|
|
70
|
+
"@middy/core": "7.0.0",
|
|
71
71
|
"@types/aws-lambda": "^8.10.97"
|
|
72
72
|
},
|
|
73
73
|
"gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
|