@middy/http-router 4.0.8 → 4.0.10
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/LICENSE +1 -1
- package/README.md +1 -1
- package/index.cjs +22 -13
- package/index.d.ts +5 -2
- package/index.js +13 -10
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2017-
|
|
3
|
+
Copyright (c) 2017-2023 [Luciano Mammino](https://github.com/lmammino), [will Farrell](https://github.com/willfarrell) and the [Middy team](https://github.com/middyjs/middy/graphs/contributors)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
|
|
39
39
|
## License
|
|
40
40
|
|
|
41
|
-
Licensed under [MIT License](LICENSE). Copyright (c) 2017-
|
|
41
|
+
Licensed under [MIT License](LICENSE). Copyright (c) 2017-2023 [Luciano Mammino](https://github.com/lmammino), [will Farrell](https://github.com/willfarrell), and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
|
|
42
42
|
|
|
43
43
|
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy?ref=badge_large">
|
|
44
44
|
<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.cjs
CHANGED
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
Method: ()=>Method,
|
|
13
|
+
default: ()=>_default
|
|
8
14
|
});
|
|
9
15
|
const _util = require("@middy/util");
|
|
10
16
|
const httpRouteHandler = (routes)=>{
|
|
@@ -37,8 +43,9 @@ const httpRouteHandler = (routes)=>{
|
|
|
37
43
|
for (const route of routesDynamic[method] ?? []){
|
|
38
44
|
const match = path.match(route.path);
|
|
39
45
|
if (match) {
|
|
40
|
-
event.pathParameters
|
|
41
|
-
...match.groups
|
|
46
|
+
event.pathParameters = {
|
|
47
|
+
...match.groups,
|
|
48
|
+
...event.pathParameters
|
|
42
49
|
};
|
|
43
50
|
return route.handler(event, context, abort);
|
|
44
51
|
}
|
|
@@ -48,14 +55,16 @@ const httpRouteHandler = (routes)=>{
|
|
|
48
55
|
};
|
|
49
56
|
const regexpDynamicWildcards = /\/\{(proxy)\+\}$/;
|
|
50
57
|
const regexpDynamicParameters = /\/\{([^/]+)\}/g;
|
|
51
|
-
const
|
|
52
|
-
'GET',
|
|
53
|
-
'POST',
|
|
54
|
-
'PUT',
|
|
55
|
-
'PATCH',
|
|
56
|
-
'DELETE',
|
|
57
|
-
'OPTIONS'
|
|
58
|
-
|
|
58
|
+
const Method = {
|
|
59
|
+
Get: 'GET',
|
|
60
|
+
Post: 'POST',
|
|
61
|
+
Put: 'PUT',
|
|
62
|
+
Patch: 'PATCH',
|
|
63
|
+
Delete: 'DELETE',
|
|
64
|
+
Options: 'OPTIONS',
|
|
65
|
+
Any: 'ANY'
|
|
66
|
+
};
|
|
67
|
+
const methods = Object.values(Method).filter((method)=>method !== 'ANY');
|
|
59
68
|
const attachStaticRoute = (method, path, handler, routesType)=>{
|
|
60
69
|
if (method === 'ANY') {
|
|
61
70
|
for (const method1 of methods){
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import middy from '@middy/core'
|
|
1
|
+
import middy, { MiddyfiedHandler } from '@middy/core'
|
|
2
2
|
import {
|
|
3
3
|
ALBEvent,
|
|
4
|
+
ALBResult,
|
|
4
5
|
APIGatewayProxyEvent,
|
|
5
6
|
APIGatewayProxyEventV2,
|
|
6
7
|
APIGatewayProxyResult,
|
|
@@ -17,10 +18,12 @@ export enum Method {
|
|
|
17
18
|
Any = 'ANY'
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
type TResult = ALBResult | APIGatewayProxyResult
|
|
22
|
+
|
|
20
23
|
export interface Route<TEvent> {
|
|
21
24
|
method: Method
|
|
22
25
|
path: string
|
|
23
|
-
handler: LambdaHandler<TEvent,
|
|
26
|
+
handler: LambdaHandler<TEvent, TResult> | MiddyfiedHandler<TEvent, TResult, any, any>
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
declare function httpRouterHandler<
|
package/index.js
CHANGED
|
@@ -29,8 +29,9 @@ const httpRouteHandler = (routes)=>{
|
|
|
29
29
|
for (const route of routesDynamic[method] ?? []){
|
|
30
30
|
const match = path.match(route.path);
|
|
31
31
|
if (match) {
|
|
32
|
-
event.pathParameters
|
|
33
|
-
...match.groups
|
|
32
|
+
event.pathParameters = {
|
|
33
|
+
...match.groups,
|
|
34
|
+
...event.pathParameters
|
|
34
35
|
};
|
|
35
36
|
return route.handler(event, context, abort);
|
|
36
37
|
}
|
|
@@ -40,14 +41,16 @@ const httpRouteHandler = (routes)=>{
|
|
|
40
41
|
};
|
|
41
42
|
const regexpDynamicWildcards = /\/\{(proxy)\+\}$/;
|
|
42
43
|
const regexpDynamicParameters = /\/\{([^/]+)\}/g;
|
|
43
|
-
const
|
|
44
|
-
'GET',
|
|
45
|
-
'POST',
|
|
46
|
-
'PUT',
|
|
47
|
-
'PATCH',
|
|
48
|
-
'DELETE',
|
|
49
|
-
'OPTIONS'
|
|
50
|
-
|
|
44
|
+
export const Method = {
|
|
45
|
+
Get: 'GET',
|
|
46
|
+
Post: 'POST',
|
|
47
|
+
Put: 'PUT',
|
|
48
|
+
Patch: 'PATCH',
|
|
49
|
+
Delete: 'DELETE',
|
|
50
|
+
Options: 'OPTIONS',
|
|
51
|
+
Any: 'ANY'
|
|
52
|
+
};
|
|
53
|
+
const methods = Object.values(Method).filter((method)=>method !== 'ANY');
|
|
51
54
|
const attachStaticRoute = (method, path, handler, routesType)=>{
|
|
52
55
|
if (method === 'ANY') {
|
|
53
56
|
for (const method1 of methods){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-router",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.10",
|
|
4
4
|
"description": "HTTP event router for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -62,11 +62,11 @@
|
|
|
62
62
|
},
|
|
63
63
|
"homepage": "https://middy.js.org",
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@middy/util": "4.0.
|
|
65
|
+
"@middy/util": "4.0.10"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@middy/core": "4.0.
|
|
68
|
+
"@middy/core": "4.0.10",
|
|
69
69
|
"@types/aws-lambda": "^8.10.97"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "e2a97d380fc4150781004092ea054f5d0fc7a8c0"
|
|
72
72
|
}
|