@middy/cloudformation-router 7.1.1 → 7.1.3
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 +17 -0
- package/index.d.ts +12 -5
- package/index.js +5 -6
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -30,6 +30,23 @@
|
|
|
30
30
|
<p>You can read the documentation at: <a href="https://middy.js.org/docs/routers/cloudformation-router">https://middy.js.org/docs/routers/cloudformation-router</a></p>
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install --save @middy/cloudformation-router
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Documentation and examples
|
|
41
|
+
|
|
42
|
+
For documentation and examples, refer to the main [Middy monorepo on GitHub](https://github.com/middyjs/middy) or [Middy official website](https://middy.js.org/docs/routers/cloudformation-router).
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Contributing
|
|
46
|
+
|
|
47
|
+
Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/middyjs/middy/issues) or to [submit Pull Requests](https://github.com/middyjs/middy/pulls).
|
|
48
|
+
|
|
49
|
+
|
|
33
50
|
## License
|
|
34
51
|
|
|
35
52
|
Licensed under [MIT License](LICENSE). Copyright (c) 2017-2026 [will Farrell](https://github.com/willfarrell), [Luciano Mammino](https://github.com/lmammino), and [Middy contributors](https://github.com/middyjs/middy/graphs/contributors).
|
package/index.d.ts
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
// Copyright 2017 - 2026 will Farrell, Luciano Mammino, and Middy contributors.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import type middy from "@middy/core";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
CloudFormationCustomResourceEvent,
|
|
6
|
+
CloudFormationCustomResourceHandler,
|
|
7
|
+
} from "aws-lambda";
|
|
5
8
|
|
|
6
|
-
interface Route<
|
|
9
|
+
export interface Route<TResult = never> {
|
|
7
10
|
requestType: string;
|
|
8
|
-
handler: CloudFormationCustomResourceHandler<
|
|
11
|
+
handler: CloudFormationCustomResourceHandler<TResult>;
|
|
9
12
|
}
|
|
10
13
|
|
|
14
|
+
export type RouteNotFoundResponseFn = (input: {
|
|
15
|
+
requestType: string;
|
|
16
|
+
}) => unknown;
|
|
17
|
+
|
|
11
18
|
export interface Options {
|
|
12
19
|
routes: Route[];
|
|
13
|
-
notFoundResponse?:
|
|
20
|
+
notFoundResponse?: RouteNotFoundResponseFn;
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
declare function cloudformationRouterHandler(
|
|
17
24
|
options: Options | Route[],
|
|
18
|
-
): middy.MiddyfiedHandler
|
|
25
|
+
): middy.MiddyfiedHandler<CloudFormationCustomResourceEvent, void>;
|
|
19
26
|
|
|
20
27
|
export default cloudformationRouterHandler;
|
package/index.js
CHANGED
|
@@ -13,15 +13,14 @@ const defaults = {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
const cloudformationCustomResourceRouteHandler = (opts = {}) => {
|
|
16
|
-
|
|
16
|
+
let options;
|
|
17
17
|
if (Array.isArray(opts)) {
|
|
18
|
-
|
|
19
|
-
} else {
|
|
20
|
-
Object.assign(options, opts);
|
|
18
|
+
options = { routes: opts };
|
|
21
19
|
}
|
|
22
|
-
|
|
20
|
+
options ??= opts;
|
|
21
|
+
const { routes, notFoundResponse } = { ...defaults, ...options };
|
|
23
22
|
|
|
24
|
-
const routesStatic =
|
|
23
|
+
const routesStatic = Object.create(null);
|
|
25
24
|
for (const route of routes) {
|
|
26
25
|
const { requestType, handler } = route;
|
|
27
26
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/cloudformation-router",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.3",
|
|
4
4
|
"description": "CloudFormation Custom Response event router for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"url": "https://github.com/sponsors/willfarrell"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@middy/core": "7.1.
|
|
69
|
-
"@types/aws-lambda": "^8.0.0"
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
"@middy/core": "7.1.3",
|
|
69
|
+
"@types/aws-lambda": "^8.0.0",
|
|
70
|
+
"@types/node": "^22.0.0"
|
|
71
|
+
}
|
|
72
72
|
}
|