@middy/core 7.3.0 → 7.3.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/index.d.ts +5 -3
- package/index.js +25 -11
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -8,9 +8,11 @@ import type { DurableContext as LambdaContextDurable } from "@aws/durable-execut
|
|
|
8
8
|
|
|
9
9
|
declare type PluginHook = () => void;
|
|
10
10
|
declare type PluginHookWithMiddlewareName = (middlewareName: string) => void;
|
|
11
|
+
declare type PluginHookWithRequest = (request: Request) => void;
|
|
11
12
|
declare type PluginHookPromise = (
|
|
12
13
|
request: Request,
|
|
13
14
|
) => Promise<unknown> | unknown;
|
|
15
|
+
declare type PluginTimeoutEarlyResponse = () => unknown;
|
|
14
16
|
export type PluginExecutionMode = () => void;
|
|
15
17
|
export declare const executionModeStandard: PluginExecutionMode;
|
|
16
18
|
export declare const executionModeDurableContext: PluginExecutionMode;
|
|
@@ -19,14 +21,14 @@ export declare const executionModeStreamifyResponse: PluginExecutionMode;
|
|
|
19
21
|
interface PluginObject {
|
|
20
22
|
internal?: Record<string, unknown>;
|
|
21
23
|
beforePrefetch?: PluginHook;
|
|
22
|
-
requestStart?:
|
|
24
|
+
requestStart?: PluginHookWithRequest;
|
|
23
25
|
beforeMiddleware?: PluginHookWithMiddlewareName;
|
|
24
26
|
afterMiddleware?: PluginHookWithMiddlewareName;
|
|
25
27
|
beforeHandler?: PluginHook;
|
|
26
|
-
timeoutEarlyInMillis?: number;
|
|
27
|
-
timeoutEarlyResponse?: PluginHook;
|
|
28
28
|
afterHandler?: PluginHook;
|
|
29
29
|
requestEnd?: PluginHookPromise;
|
|
30
|
+
timeoutEarlyInMillis?: number;
|
|
31
|
+
timeoutEarlyResponse?: PluginTimeoutEarlyResponse;
|
|
30
32
|
executionMode?: PluginExecutionMode;
|
|
31
33
|
}
|
|
32
34
|
|
package/index.js
CHANGED
|
@@ -18,18 +18,32 @@ const defaultPluginConfig = {
|
|
|
18
18
|
executionMode: executionModeStandard,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
// JSON-Schema for `pluginConfig` passed to `middy(handler, pluginConfig)`.
|
|
22
|
+
// All options are optional; `additionalProperties: false` catches typos
|
|
23
|
+
// (e.g. `timeoutEarlyMillis` instead of `timeoutEarlyInMillis`).
|
|
24
|
+
// Properties listed in hook execution order.
|
|
21
25
|
const optionSchema = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
// Pre-computed request state seeded into `request.internal`.
|
|
29
|
+
internal: { type: "object", additionalProperties: true },
|
|
30
|
+
// Lifecycle hooks (see docs/intro/hooks).
|
|
31
|
+
beforePrefetch: { instanceof: "Function" },
|
|
32
|
+
requestStart: { instanceof: "Function" },
|
|
33
|
+
beforeMiddleware: { instanceof: "Function" },
|
|
34
|
+
afterMiddleware: { instanceof: "Function" },
|
|
35
|
+
beforeHandler: { instanceof: "Function" },
|
|
36
|
+
afterHandler: { instanceof: "Function" },
|
|
37
|
+
requestEnd: { instanceof: "Function" },
|
|
38
|
+
// Early-timeout configuration. `timeoutEarlyInMillis` reserves N ms
|
|
39
|
+
// before Lambda timeout for `timeoutEarlyResponse` to run.
|
|
40
|
+
timeoutEarlyInMillis: { type: "integer", minimum: 0 },
|
|
41
|
+
timeoutEarlyResponse: { instanceof: "Function" },
|
|
42
|
+
// Execution mode (standard, durable-context, streamify-response, or custom).
|
|
43
|
+
executionMode: { instanceof: "Function" },
|
|
44
|
+
},
|
|
45
|
+
required: [],
|
|
46
|
+
additionalProperties: false,
|
|
33
47
|
};
|
|
34
48
|
|
|
35
49
|
export const middyValidateOptions = (options) =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/core",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda (core package)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"url": "https://github.com/sponsors/willfarrell"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@middy/util": "7.3.
|
|
88
|
+
"@middy/util": "7.3.1"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"@aws/durable-execution-sdk-js": "^1.0.0"
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@aws/durable-execution-sdk-js": "^1.0.0",
|
|
100
100
|
"@aws/durable-execution-sdk-js-testing": "^1.0.0",
|
|
101
|
-
"@datastream/core": "0.
|
|
101
|
+
"@datastream/core": "0.4.0",
|
|
102
102
|
"@types/aws-lambda": "^8.0.0",
|
|
103
103
|
"@types/node": "^22.0.0"
|
|
104
104
|
}
|