@middy/http-router 6.0.0-beta.1 → 6.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 +22 -11
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
## License
|
|
41
41
|
|
|
42
|
-
Licensed under [MIT License](LICENSE). Copyright (c) 2017-
|
|
42
|
+
Licensed under [MIT License](LICENSE). Copyright (c) 2017-2025 [Luciano Mammino](https://github.com/lmammino), [will Farrell](https://github.com/willfarrell), and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
|
|
43
43
|
|
|
44
44
|
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy?ref=badge_large">
|
|
45
45
|
<img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy.svg?type=large" alt="FOSSA Status" style="max-width:100%;">
|
package/index.js
CHANGED
|
@@ -24,7 +24,7 @@ const httpRouteHandler = (opts = {}) => {
|
|
|
24
24
|
// Prevents `routesType[method][path] = handler` from flagging: This assignment may alter Object.prototype if a malicious '__proto__' string is injected from library input.
|
|
25
25
|
if (!enumMethods.includes(method)) {
|
|
26
26
|
throw new Error('Method not allowed', {
|
|
27
|
-
cause: { package: '@middy/http-router' }
|
|
27
|
+
cause: { package: '@middy/http-router', data: { method } }
|
|
28
28
|
})
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -45,27 +45,38 @@ const httpRouteHandler = (opts = {}) => {
|
|
|
45
45
|
|
|
46
46
|
return (event, context, abort) => {
|
|
47
47
|
const { method, path } = getVersionRoute[pickVersion(event)]?.(event)
|
|
48
|
+
|
|
48
49
|
if (!method) {
|
|
49
50
|
throw new Error('Unknown http event format', {
|
|
50
|
-
cause: { package: '@middy/http-router', data:
|
|
51
|
+
cause: { package: '@middy/http-router', data: { method } }
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
if (!path) {
|
|
55
|
+
throw new Error('Unknown http event format', {
|
|
56
|
+
cause: { package: '@middy/http-router', data: { path } }
|
|
51
57
|
})
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
// Static
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
if (
|
|
62
|
+
Object.hasOwnProperty.call(routesStatic, method) &&
|
|
63
|
+
Object.hasOwnProperty.call(routesStatic[method], path)
|
|
64
|
+
) {
|
|
65
|
+
const handler = routesStatic[method][path]
|
|
57
66
|
return handler(event, context, abort)
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
// Dynamic
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
if (Object.hasOwnProperty.call(routesDynamic, method)) {
|
|
71
|
+
for (const route of routesDynamic[method] ?? []) {
|
|
72
|
+
const match = path.match(route.path)
|
|
73
|
+
if (match) {
|
|
74
|
+
event.pathParameters = {
|
|
75
|
+
...match.groups,
|
|
76
|
+
...event.pathParameters
|
|
77
|
+
}
|
|
78
|
+
return route.handler(event, context, abort)
|
|
67
79
|
}
|
|
68
|
-
return route.handler(event, context, abort)
|
|
69
80
|
}
|
|
70
81
|
}
|
|
71
82
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-router",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "HTTP event router for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
"index.d.ts"
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
|
-
"test": "npm run test:unit",
|
|
31
|
+
"test": "npm run test:unit && npm run test:fuzz",
|
|
32
32
|
"test:unit": "node --test __tests__/index.js",
|
|
33
|
+
"test:fuzz": "node --test __tests__/fuzz.js",
|
|
33
34
|
"test:benchmark": "node __benchmarks__/index.js"
|
|
34
35
|
},
|
|
35
36
|
"license": "MIT",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
},
|
|
52
53
|
"repository": {
|
|
53
54
|
"type": "git",
|
|
54
|
-
"url": "github
|
|
55
|
+
"url": "git+https://github.com/middyjs/middy.git",
|
|
55
56
|
"directory": "packages/http-router"
|
|
56
57
|
},
|
|
57
58
|
"bugs": {
|
|
@@ -63,10 +64,10 @@
|
|
|
63
64
|
"url": "https://github.com/sponsors/willfarrell"
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {
|
|
66
|
-
"@middy/util": "6.
|
|
67
|
+
"@middy/util": "6.1.0"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
|
-
"@middy/core": "6.
|
|
70
|
+
"@middy/core": "6.1.0",
|
|
70
71
|
"@types/aws-lambda": "^8.10.97"
|
|
71
72
|
},
|
|
72
73
|
"gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
|