@webiny/handler-aws 0.0.0-unstable.d7f521b032 → 0.0.0-unstable.de38392959
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/createHandler.d.ts +2 -0
- package/createHandler.js +29 -0
- package/createHandler.js.map +1 -0
- package/dynamodb/index.d.ts +5 -8
- package/dynamodb/index.js +20 -30
- package/dynamodb/index.js.map +1 -1
- package/dynamodb/plugins/DynamoDBEventHandler.d.ts +6 -5
- package/dynamodb/plugins/DynamoDBEventHandler.js +3 -12
- package/dynamodb/plugins/DynamoDBEventHandler.js.map +1 -1
- package/dynamodb/register.d.ts +1 -0
- package/dynamodb/register.js +28 -0
- package/dynamodb/register.js.map +1 -0
- package/eventBridge/index.d.ts +7 -10
- package/eventBridge/index.js +21 -31
- package/eventBridge/index.js.map +1 -1
- package/eventBridge/plugins/EventBridgeEventHandler.d.ts +6 -5
- package/eventBridge/plugins/EventBridgeEventHandler.js +3 -12
- package/eventBridge/plugins/EventBridgeEventHandler.js.map +1 -1
- package/eventBridge/register.d.ts +4 -0
- package/eventBridge/register.js +21 -0
- package/eventBridge/register.js.map +1 -0
- package/execute.js +7 -14
- package/execute.js.map +1 -1
- package/gateway/index.d.ts +6 -10
- package/gateway/index.js +14 -30
- package/gateway/index.js.map +1 -1
- package/gateway/register.d.ts +1 -0
- package/gateway/register.js +21 -0
- package/gateway/register.js.map +1 -0
- package/index.d.ts +33 -5
- package/index.js +146 -29
- package/index.js.map +1 -1
- package/package.json +17 -15
- package/plugins/handlerClient.js +9 -18
- package/plugins/handlerClient.js.map +1 -1
- package/plugins/index.js +2 -3
- package/plugins/index.js.map +1 -1
- package/raw/index.d.ts +1 -5
- package/raw/index.js +15 -30
- package/raw/index.js.map +1 -1
- package/raw/plugins/RawEventHandler.d.ts +2 -2
- package/raw/plugins/RawEventHandler.js +6 -6
- package/raw/plugins/RawEventHandler.js.map +1 -1
- package/registry.d.ts +11 -0
- package/registry.js +38 -0
- package/registry.js.map +1 -0
- package/s3/index.d.ts +7 -9
- package/s3/index.js +23 -33
- package/s3/index.js.map +1 -1
- package/s3/plugins/S3EventHandler.d.ts +6 -5
- package/s3/plugins/S3EventHandler.js +3 -12
- package/s3/plugins/S3EventHandler.js.map +1 -1
- package/s3/register.d.ts +4 -0
- package/s3/register.js +25 -0
- package/s3/register.js.map +1 -0
- package/sns/index.d.ts +9 -0
- package/sns/index.js +77 -0
- package/sns/index.js.map +1 -0
- package/sns/plugins/SNSEventHandler.d.ts +20 -0
- package/sns/plugins/SNSEventHandler.js +21 -0
- package/sns/plugins/SNSEventHandler.js.map +1 -0
- package/sns/register.d.ts +1 -0
- package/sns/register.js +25 -0
- package/sns/register.js.map +1 -0
- package/sourceHandler.d.ts +2 -0
- package/sourceHandler.js +12 -0
- package/sourceHandler.js.map +1 -0
- package/sqs/index.d.ts +7 -9
- package/sqs/index.js +23 -33
- package/sqs/index.js.map +1 -1
- package/sqs/plugins/SQSEventHandler.d.ts +6 -5
- package/sqs/plugins/SQSEventHandler.js +3 -12
- package/sqs/plugins/SQSEventHandler.js.map +1 -1
- package/sqs/register.d.ts +1 -0
- package/sqs/register.js +28 -0
- package/sqs/register.js.map +1 -0
- package/types.d.ts +25 -1
- package/types.js +37 -9
- package/types.js.map +1 -1
- package/utils/composedHandler.d.ts +6 -0
- package/utils/composedHandler.js +24 -0
- package/utils/composedHandler.js.map +1 -0
package/plugins/handlerClient.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.createHandlerClientPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _lambda = _interopRequireDefault(require("aws-sdk/clients/lambda"));
|
|
11
|
-
|
|
7
|
+
var _clientLambda = require("@webiny/aws-sdk/client-lambda");
|
|
12
8
|
var _handlerClient = require("@webiny/handler-client");
|
|
13
|
-
|
|
14
9
|
const createHandlerClientPlugin = () => {
|
|
15
10
|
const plugin = new _handlerClient.HandlerClientPlugin({
|
|
16
11
|
invoke: async params => {
|
|
@@ -19,27 +14,24 @@ const createHandlerClientPlugin = () => {
|
|
|
19
14
|
name,
|
|
20
15
|
payload
|
|
21
16
|
} = params;
|
|
22
|
-
const lambdaClient = new
|
|
17
|
+
const lambdaClient = new _clientLambda.LambdaClient({
|
|
23
18
|
region: process.env.AWS_REGION
|
|
24
19
|
});
|
|
25
|
-
const response = await lambdaClient.
|
|
20
|
+
const response = await lambdaClient.send(new _clientLambda.InvokeCommand({
|
|
26
21
|
FunctionName: name,
|
|
27
22
|
InvocationType: useAwait === false ? "Event" : "RequestResponse",
|
|
28
23
|
Payload: JSON.stringify(payload)
|
|
29
|
-
})
|
|
30
|
-
|
|
24
|
+
}));
|
|
31
25
|
if (useAwait === false) {
|
|
32
26
|
return null;
|
|
33
27
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return JSON.parse(Payload);
|
|
28
|
+
const decoder = new TextDecoder("utf-8");
|
|
29
|
+
return JSON.parse(decoder.decode(response.Payload));
|
|
37
30
|
},
|
|
38
31
|
canUse: params => {
|
|
39
|
-
if (!
|
|
32
|
+
if (!params?.name) {
|
|
40
33
|
return true;
|
|
41
34
|
}
|
|
42
|
-
|
|
43
35
|
const {
|
|
44
36
|
name
|
|
45
37
|
} = params;
|
|
@@ -47,16 +39,15 @@ const createHandlerClientPlugin = () => {
|
|
|
47
39
|
* In case we are invoking currently active lambda, let's use this plugin as well.
|
|
48
40
|
* When invoking some other lambda, name starts with arn.
|
|
49
41
|
*/
|
|
50
|
-
|
|
51
42
|
if (name === process.env.AWS_LAMBDA_FUNCTION_NAME) {
|
|
52
43
|
return true;
|
|
53
44
|
}
|
|
54
|
-
|
|
55
45
|
return name.match("arn:") !== null;
|
|
56
46
|
}
|
|
57
47
|
});
|
|
58
48
|
plugin.name = "handler-client";
|
|
59
49
|
return plugin;
|
|
60
50
|
};
|
|
51
|
+
exports.createHandlerClientPlugin = createHandlerClientPlugin;
|
|
61
52
|
|
|
62
|
-
|
|
53
|
+
//# sourceMappingURL=handlerClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createHandlerClientPlugin","plugin","HandlerClientPlugin","invoke","params","await","useAwait","name","payload","lambdaClient","LambdaClient","region","process","env","AWS_REGION","response","FunctionName","InvocationType","Payload","JSON","stringify","
|
|
1
|
+
{"version":3,"names":["_clientLambda","require","_handlerClient","createHandlerClientPlugin","plugin","HandlerClientPlugin","invoke","params","await","useAwait","name","payload","lambdaClient","LambdaClient","region","process","env","AWS_REGION","response","send","InvokeCommand","FunctionName","InvocationType","Payload","JSON","stringify","decoder","TextDecoder","parse","decode","canUse","AWS_LAMBDA_FUNCTION_NAME","match","exports"],"sources":["handlerClient.ts"],"sourcesContent":["import { LambdaClient, InvokeCommand } from \"@webiny/aws-sdk/client-lambda\";\nimport { HandlerClientPlugin } from \"@webiny/handler-client\";\n\nexport const createHandlerClientPlugin = () => {\n const plugin = new HandlerClientPlugin({\n invoke: async params => {\n const { await: useAwait, name, payload } = params;\n const lambdaClient = new LambdaClient({\n region: process.env.AWS_REGION\n });\n const response = await lambdaClient.send(\n new InvokeCommand({\n FunctionName: name,\n InvocationType: useAwait === false ? \"Event\" : \"RequestResponse\",\n Payload: JSON.stringify(payload)\n })\n );\n\n if (useAwait === false) {\n return null;\n }\n\n const decoder = new TextDecoder(\"utf-8\");\n return JSON.parse(decoder.decode(response.Payload));\n },\n canUse: params => {\n if (!params?.name) {\n return true;\n }\n const { name } = params;\n /**\n * In case we are invoking currently active lambda, let's use this plugin as well.\n * When invoking some other lambda, name starts with arn.\n */\n if (name === process.env.AWS_LAMBDA_FUNCTION_NAME) {\n return true;\n }\n return name.match(\"arn:\") !== null;\n }\n });\n\n plugin.name = \"handler-client\";\n\n return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,IAAI,GAAG,gBAAgB;EAE9B,OAAON,MAAM;AACjB,CAAC;AAAC6B,OAAA,CAAA9B,yBAAA,GAAAA,yBAAA"}
|
package/plugins/index.js
CHANGED
|
@@ -4,11 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.registerDefaultPlugins = void 0;
|
|
7
|
-
|
|
8
7
|
var _handlerClient = require("./handlerClient");
|
|
9
|
-
|
|
10
8
|
const registerDefaultPlugins = context => {
|
|
11
9
|
context.plugins.register([(0, _handlerClient.createHandlerClientPlugin)()]);
|
|
12
10
|
};
|
|
11
|
+
exports.registerDefaultPlugins = registerDefaultPlugins;
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerDefaultPlugins","context","plugins","register","createHandlerClientPlugin"],"sources":["index.ts"],"sourcesContent":["import { createHandlerClientPlugin } from \"./handlerClient\";\nimport { Context } from \"@webiny/handler/types\";\n\nexport const registerDefaultPlugins = (context: Context): void => {\n context.plugins.register([createHandlerClientPlugin()]);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_handlerClient","require","registerDefaultPlugins","context","plugins","register","createHandlerClientPlugin","exports"],"sources":["index.ts"],"sourcesContent":["import { createHandlerClientPlugin } from \"./handlerClient\";\nimport { Context } from \"@webiny/handler/types\";\n\nexport const registerDefaultPlugins = (context: Context): void => {\n context.plugins.register([createHandlerClientPlugin()]);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAGO,MAAMC,sBAAsB,GAAIC,OAAgB,IAAW;EAC9DA,OAAO,CAACC,OAAO,CAACC,QAAQ,CAAC,CAAC,IAAAC,wCAAyB,EAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAACC,OAAA,CAAAL,sBAAA,GAAAA,sBAAA"}
|
package/raw/index.d.ts
CHANGED
|
@@ -10,10 +10,6 @@ import { APIGatewayProxyResult } from "aws-lambda/trigger/api-gateway-proxy";
|
|
|
10
10
|
export interface HandlerCallable<Payload, Response = APIGatewayProxyResult> {
|
|
11
11
|
(payload: Payload, context: LambdaContext): Promise<Response>;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
14
|
-
http?: {
|
|
15
|
-
debug?: boolean;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
13
|
+
export declare type CreateHandlerParams = BaseCreateHandlerParams;
|
|
18
14
|
export declare const createHandler: <Payload = any, Response_1 = APIGatewayProxyResult>(params: CreateHandlerParams) => HandlerCallable<Payload, Response_1>;
|
|
19
15
|
export * from "./plugins/RawEventHandler";
|
package/raw/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,13 +7,8 @@ var _exportNames = {
|
|
|
9
7
|
createHandler: true
|
|
10
8
|
};
|
|
11
9
|
exports.createHandler = void 0;
|
|
12
|
-
|
|
13
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
14
|
-
|
|
15
10
|
var _handler = require("@webiny/handler");
|
|
16
|
-
|
|
17
11
|
var _RawEventHandler = require("./plugins/RawEventHandler");
|
|
18
|
-
|
|
19
12
|
Object.keys(_RawEventHandler).forEach(function (key) {
|
|
20
13
|
if (key === "default" || key === "__esModule") return;
|
|
21
14
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -27,46 +20,39 @@ Object.keys(_RawEventHandler).forEach(function (key) {
|
|
|
27
20
|
}
|
|
28
21
|
});
|
|
29
22
|
});
|
|
30
|
-
|
|
31
23
|
var _plugins = require("../plugins");
|
|
32
|
-
|
|
33
24
|
var _execute = require("../execute");
|
|
34
|
-
|
|
25
|
+
var _composedHandler = require("../utils/composedHandler");
|
|
35
26
|
/**
|
|
36
27
|
* This is the handler implementation for @webiny/handler/plugins/EventPlugin.
|
|
37
28
|
* This is mostly meant for some custom lambda calls as we are sometimes invoking lambdas directly.
|
|
38
29
|
*
|
|
39
30
|
* We should try to have some kind of standardized event type implementation at some point.
|
|
40
31
|
*/
|
|
41
|
-
const Reply = require("fastify/lib/reply");
|
|
42
32
|
|
|
33
|
+
const Reply = require("fastify/lib/reply");
|
|
43
34
|
const url = "/webiny-raw-event";
|
|
44
|
-
|
|
45
35
|
const createHandler = params => {
|
|
46
36
|
return (payload, context) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
})
|
|
37
|
+
const app = (0, _handler.createHandler)({
|
|
38
|
+
...params,
|
|
39
|
+
options: {
|
|
40
|
+
logger: params.debug === true,
|
|
41
|
+
...(params.options || {})
|
|
42
|
+
}
|
|
43
|
+
});
|
|
54
44
|
/**
|
|
55
45
|
* We always must add our default plugins to the app.
|
|
56
46
|
*/
|
|
57
|
-
|
|
58
47
|
(0, _plugins.registerDefaultPlugins)(app.webiny);
|
|
59
48
|
/**
|
|
60
49
|
* There must be an event plugin for this handler to work.
|
|
61
50
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const handler = plugins.shift();
|
|
65
|
-
|
|
66
|
-
if (!handler) {
|
|
51
|
+
const plugins = app.webiny.plugins.byType(_RawEventHandler.RawEventHandler.type).reverse();
|
|
52
|
+
if (plugins.length === 0) {
|
|
67
53
|
throw new Error(`To run @webiny/handler-aws/raw, you must have RawEventHandler set.`);
|
|
68
54
|
}
|
|
69
|
-
|
|
55
|
+
const handler = (0, _composedHandler.createComposedHandler)(plugins);
|
|
70
56
|
app.post(url, async (request, reply) => {
|
|
71
57
|
const params = {
|
|
72
58
|
request,
|
|
@@ -75,12 +61,10 @@ const createHandler = params => {
|
|
|
75
61
|
payload,
|
|
76
62
|
lambdaContext: context
|
|
77
63
|
};
|
|
78
|
-
const result = await handler
|
|
79
|
-
|
|
64
|
+
const result = await handler(params);
|
|
80
65
|
if (result instanceof Reply) {
|
|
81
66
|
return result;
|
|
82
67
|
}
|
|
83
|
-
|
|
84
68
|
app.__webiny_raw_result = result;
|
|
85
69
|
return reply.send({});
|
|
86
70
|
});
|
|
@@ -91,5 +75,6 @@ const createHandler = params => {
|
|
|
91
75
|
});
|
|
92
76
|
};
|
|
93
77
|
};
|
|
78
|
+
exports.createHandler = createHandler;
|
|
94
79
|
|
|
95
|
-
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
package/raw/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_handler","require","_RawEventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_plugins","_execute","_composedHandler","Reply","url","createHandler","params","payload","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","RawEventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","__webiny_raw_result","send","execute"],"sources":["index.ts"],"sourcesContent":["/**\n * This is the handler implementation for @webiny/handler/plugins/EventPlugin.\n * This is mostly meant for some custom lambda calls as we are sometimes invoking lambdas directly.\n *\n * We should try to have some kind of standardized event type implementation at some point.\n */\nimport {\n createHandler as createBaseHandler,\n CreateHandlerParams as BaseCreateHandlerParams\n} from \"@webiny/handler\";\nimport { Context as LambdaContext } from \"aws-lambda\";\nimport { APIGatewayProxyResult } from \"aws-lambda/trigger/api-gateway-proxy\";\nimport { RawEventHandler } from \"~/raw/plugins/RawEventHandler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport { execute } from \"~/execute\";\nimport { createComposedHandler } from \"~/utils/composedHandler\";\nimport { Context, Request } from \"@webiny/handler/types\";\n\nconst Reply = require(\"fastify/lib/reply\");\n\nconst url = \"/webiny-raw-event\";\n\nexport interface HandlerCallable<Payload, Response = APIGatewayProxyResult> {\n (payload: Payload, context: LambdaContext): Promise<Response>;\n}\n\nexport type CreateHandlerParams = BaseCreateHandlerParams;\n\ninterface HandlerParams<Payload = any> {\n request: Request;\n context: Context;\n payload: Payload;\n lambdaContext: LambdaContext;\n reply: Record<string, any>;\n next: () => Promise<Payload>;\n}\n\nexport const createHandler = <Payload = any, Response = APIGatewayProxyResult>(\n params: CreateHandlerParams\n): HandlerCallable<Payload, Response> => {\n return (payload, context) => {\n const app = createBaseHandler({\n ...params,\n options: {\n logger: params.debug === true,\n ...(params.options || {})\n }\n });\n /**\n * We always must add our default plugins to the app.\n */\n registerDefaultPlugins(app.webiny);\n /**\n * There must be an event plugin for this handler to work.\n */\n const plugins = app.webiny.plugins\n .byType<RawEventHandler<Payload, any, Response>>(RawEventHandler.type)\n .reverse();\n if (plugins.length === 0) {\n throw new Error(`To run @webiny/handler-aws/raw, you must have RawEventHandler set.`);\n }\n\n const handler = createComposedHandler<\n RawEventHandler<Payload, any, Response>,\n HandlerParams,\n Response\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<HandlerParams, \"next\"> = {\n request,\n reply,\n context: app.webiny,\n payload,\n lambdaContext: context\n };\n const result = await handler(params as unknown as HandlerParams);\n\n if (result instanceof Reply) {\n return result;\n }\n\n app.__webiny_raw_result = result;\n return reply.send({});\n });\n return execute({\n app,\n url,\n payload\n });\n };\n};\n\nexport * from \"./plugins/RawEventHandler\";\n"],"mappings":";;;;;;;;;AAMA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,gBAAA,GAAAD,OAAA;AAiFAE,MAAA,CAAAC,IAAA,CAAAF,gBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAA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G;QACxCoB,OAAO;QACPC,KAAK;QACLnB,OAAO,EAAEC,GAAG,CAACM,MAAM;QACnBR,OAAO;QACPqB,aAAa,EAAEpB;MACnB,CAAC;MACD,MAAMqB,MAAM,GAAG,MAAMN,OAAO,CAACjB,MAAkC,CAAC;MAEhE,IAAIuB,MAAM,YAAY1B,KAAK,EAAE;QACzB,OAAO0B,MAAM;MACjB;MAEApB,GAAG,CAACqB,mBAAmB,GAAGD,MAAM;MAChC,OAAOF,KAAK,CAACI,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAO,IAAAC,gBAAO,EAAC;MACXvB,GAAG;MACHL,GAAG;MACHG;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context as BaseContext, Reply } from "@webiny/handler/types";
|
|
2
2
|
import { Context as LambdaContext } from "aws-lambda";
|
|
3
3
|
import { EventPlugin, EventPluginCallableParams } from "@webiny/handler";
|
|
4
4
|
export interface RawEventHandlerCallableParams<Event, Context extends BaseContext> extends EventPluginCallableParams<Event, Context> {
|
|
@@ -7,7 +7,7 @@ export interface RawEventHandlerCallableParams<Event, Context extends BaseContex
|
|
|
7
7
|
export interface RawEventHandlerCallable<Event, Context extends BaseContext, Response> {
|
|
8
8
|
(params: RawEventHandlerCallableParams<Event, Context>): Promise<Response | Reply>;
|
|
9
9
|
}
|
|
10
|
-
export declare class RawEventHandler<Event = any, Context extends BaseContext = BaseContext, Response = any> extends EventPlugin {
|
|
10
|
+
export declare class RawEventHandler<Event = any, Context extends BaseContext = BaseContext, Response = any> extends EventPlugin<Event, Context, Response> {
|
|
11
11
|
constructor(cb: RawEventHandlerCallable<Event, Context, Response>);
|
|
12
12
|
}
|
|
13
13
|
export declare const createEventHandler: <Event_1 = any, Context extends BaseContext = BaseContext, Response_1 = any>(cb: RawEventHandlerCallable<Event_1, Context, Response_1>) => RawEventHandler<Event_1, Context, Response_1>;
|
|
@@ -4,20 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createEventHandler = exports.RawEventHandler = void 0;
|
|
7
|
-
|
|
8
7
|
var _handler = require("@webiny/handler");
|
|
9
|
-
|
|
10
8
|
class RawEventHandler extends _handler.EventPlugin {
|
|
11
9
|
constructor(cb) {
|
|
10
|
+
/**
|
|
11
|
+
* Callable is correct, TS is just having problems with the override.
|
|
12
|
+
*/
|
|
13
|
+
// @ts-expect-error
|
|
12
14
|
super(cb);
|
|
13
15
|
}
|
|
14
|
-
|
|
15
16
|
}
|
|
16
|
-
|
|
17
17
|
exports.RawEventHandler = RawEventHandler;
|
|
18
|
-
|
|
19
18
|
const createEventHandler = cb => {
|
|
20
19
|
return new RawEventHandler(cb);
|
|
21
20
|
};
|
|
21
|
+
exports.createEventHandler = createEventHandler;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
//# sourceMappingURL=RawEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RawEventHandler","EventPlugin","constructor","cb","createEventHandler"],"sources":["RawEventHandler.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"names":["_handler","require","RawEventHandler","EventPlugin","constructor","cb","exports","createEventHandler"],"sources":["RawEventHandler.ts"],"sourcesContent":["import { Context as BaseContext, Reply } from \"@webiny/handler/types\";\nimport { Context as LambdaContext } from \"aws-lambda\";\nimport { EventPlugin, EventPluginCallableParams } from \"@webiny/handler\";\n\nexport interface RawEventHandlerCallableParams<Event, Context extends BaseContext>\n extends EventPluginCallableParams<Event, Context> {\n lambdaContext: LambdaContext;\n}\nexport interface RawEventHandlerCallable<Event, Context extends BaseContext, Response> {\n (params: RawEventHandlerCallableParams<Event, Context>): Promise<Response | Reply>;\n}\n\nexport class RawEventHandler<\n Event = any,\n Context extends BaseContext = BaseContext,\n Response = any\n> extends EventPlugin<Event, Context, Response> {\n public constructor(cb: RawEventHandlerCallable<Event, Context, Response>) {\n /**\n * Callable is correct, TS is just having problems with the override.\n */\n // @ts-expect-error\n super(cb);\n }\n}\n\nexport const createEventHandler = <\n Event = any,\n Context extends BaseContext = BaseContext,\n Response = any\n>(\n cb: RawEventHandlerCallable<Event, Context, Response>\n) => {\n return new RawEventHandler<Event, Context, Response>(cb);\n};\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAUO,MAAMC,eAAe,SAIlBC,oBAAW,CAA2B;EACrCC,WAAWA,CAACC,EAAqD,EAAE;IACtE;AACR;AACA;IACQ;IACA,KAAK,CAACA,EAAE,CAAC;EACb;AACJ;AAACC,OAAA,CAAAJ,eAAA,GAAAA,eAAA;AAEM,MAAMK,kBAAkB,GAK3BF,EAAqD,IACpD;EACD,OAAO,IAAIH,eAAe,CAA2BG,EAAE,CAAC;AAC5D,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA"}
|
package/registry.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HandlerEvent, SourceHandler } from "./types";
|
|
2
|
+
import { Context as LambdaContext } from "aws-lambda/handler";
|
|
3
|
+
declare class HandlerRegistry {
|
|
4
|
+
private readonly handlers;
|
|
5
|
+
private constructor();
|
|
6
|
+
static create(): HandlerRegistry;
|
|
7
|
+
register(handler: SourceHandler<any>): void;
|
|
8
|
+
getHandler(event: HandlerEvent, context: LambdaContext): SourceHandler;
|
|
9
|
+
}
|
|
10
|
+
export type { HandlerRegistry };
|
|
11
|
+
export declare const registry: HandlerRegistry;
|
package/registry.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.registry = void 0;
|
|
7
|
+
class HandlerRegistry {
|
|
8
|
+
handlers = new Map();
|
|
9
|
+
constructor() {
|
|
10
|
+
/**
|
|
11
|
+
* We don't want this class to be constructed outside the static create() method
|
|
12
|
+
*/
|
|
13
|
+
}
|
|
14
|
+
static create() {
|
|
15
|
+
return new HandlerRegistry();
|
|
16
|
+
}
|
|
17
|
+
register(handler) {
|
|
18
|
+
if (this.handlers.has(handler.name)) {
|
|
19
|
+
/**
|
|
20
|
+
* This should only happen during the development phase.
|
|
21
|
+
*/
|
|
22
|
+
throw new Error(`Handler "${handler.name}" is already registered.`);
|
|
23
|
+
}
|
|
24
|
+
this.handlers.set(handler.name, handler);
|
|
25
|
+
}
|
|
26
|
+
getHandler(event, context) {
|
|
27
|
+
for (const handler of this.handlers.values()) {
|
|
28
|
+
if (handler.canUse(event, context)) {
|
|
29
|
+
return handler;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`There is no handler for the event: ${JSON.stringify(event)}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const registry = HandlerRegistry.create();
|
|
36
|
+
exports.registry = registry;
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=registry.js.map
|
package/registry.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["HandlerRegistry","handlers","Map","constructor","create","register","handler","has","name","Error","set","getHandler","event","context","values","canUse","JSON","stringify","registry","exports"],"sources":["registry.ts"],"sourcesContent":["import { HandlerEvent, SourceHandler } from \"~/types\";\nimport { Context as LambdaContext } from \"aws-lambda/handler\";\n\nclass HandlerRegistry {\n private readonly handlers = new Map<string, SourceHandler>();\n\n private constructor() {\n /**\n * We don't want this class to be constructed outside the static create() method\n */\n }\n\n public static create() {\n return new HandlerRegistry();\n }\n\n public register(handler: SourceHandler<any>) {\n if (this.handlers.has(handler.name)) {\n /**\n * This should only happen during the development phase.\n */\n throw new Error(`Handler \"${handler.name}\" is already registered.`);\n }\n this.handlers.set(handler.name, handler);\n }\n\n public getHandler(event: HandlerEvent, context: LambdaContext): SourceHandler {\n for (const handler of this.handlers.values()) {\n if (handler.canUse(event, context)) {\n return handler;\n }\n }\n throw new Error(`There is no handler for the event: ${JSON.stringify(event)}`);\n }\n}\n\nexport type { HandlerRegistry };\n\nexport const registry = HandlerRegistry.create();\n"],"mappings":";;;;;;AAGA,MAAMA,eAAe,CAAC;EACDC,QAAQ,GAAG,IAAIC,GAAG,CAAwB,CAAC;EAEpDC,WAAWA,CAAA,EAAG;IAClB;AACR;AACA;EAFQ;EAKJ,OAAcC,MAAMA,CAAA,EAAG;IACnB,OAAO,IAAIJ,eAAe,CAAC,CAAC;EAChC;EAEOK,QAAQA,CAACC,OAA2B,EAAE;IACzC,IAAI,IAAI,CAACL,QAAQ,CAACM,GAAG,CAACD,OAAO,CAACE,IAAI,CAAC,EAAE;MACjC;AACZ;AACA;MACY,MAAM,IAAIC,KAAK,CAAE,YAAWH,OAAO,CAACE,IAAK,0BAAyB,CAAC;IACvE;IACA,IAAI,CAACP,QAAQ,CAACS,GAAG,CAACJ,OAAO,CAACE,IAAI,EAAEF,OAAO,CAAC;EAC5C;EAEOK,UAAUA,CAACC,KAAmB,EAAEC,OAAsB,EAAiB;IAC1E,KAAK,MAAMP,OAAO,IAAI,IAAI,CAACL,QAAQ,CAACa,MAAM,CAAC,CAAC,EAAE;MAC1C,IAAIR,OAAO,CAACS,MAAM,CAACH,KAAK,EAAEC,OAAO,CAAC,EAAE;QAChC,OAAOP,OAAO;MAClB;IACJ;IACA,MAAM,IAAIG,KAAK,CAAE,sCAAqCO,IAAI,CAACC,SAAS,CAACL,KAAK,CAAE,EAAC,CAAC;EAClF;AACJ;AAIO,MAAMM,QAAQ,GAAGlB,eAAe,CAACI,MAAM,CAAC,CAAC;AAACe,OAAA,CAAAD,QAAA,GAAAA,QAAA"}
|
package/s3/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { HandlerFactoryParams } from "../types";
|
|
2
|
+
import { APIGatewayProxyResult, S3Event } from "aws-lambda";
|
|
3
|
+
import { Context as LambdaContext } from "aws-lambda/handler";
|
|
4
|
+
export * from "./plugins/S3EventHandler";
|
|
4
5
|
export interface HandlerCallable {
|
|
5
|
-
(
|
|
6
|
-
}
|
|
7
|
-
export interface CreateHandlerParams extends BaseCreateHandlerParams {
|
|
8
|
-
debug?: boolean;
|
|
6
|
+
(event: S3Event, context: LambdaContext): Promise<APIGatewayProxyResult>;
|
|
9
7
|
}
|
|
10
|
-
export declare
|
|
11
|
-
export
|
|
8
|
+
export declare type HandlerParams = HandlerFactoryParams;
|
|
9
|
+
export declare const createHandler: (params: HandlerParams) => HandlerCallable;
|
package/s3/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -9,13 +8,9 @@ var _exportNames = {
|
|
|
9
8
|
createHandler: true
|
|
10
9
|
};
|
|
11
10
|
exports.createHandler = void 0;
|
|
12
|
-
|
|
13
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
14
|
-
|
|
15
11
|
var _handler = require("@webiny/handler");
|
|
16
|
-
|
|
12
|
+
var _plugins = require("../plugins");
|
|
17
13
|
var _S3EventHandler = require("./plugins/S3EventHandler");
|
|
18
|
-
|
|
19
14
|
Object.keys(_S3EventHandler).forEach(function (key) {
|
|
20
15
|
if (key === "default" || key === "__esModule") return;
|
|
21
16
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -27,61 +22,56 @@ Object.keys(_S3EventHandler).forEach(function (key) {
|
|
|
27
22
|
}
|
|
28
23
|
});
|
|
29
24
|
});
|
|
30
|
-
|
|
31
|
-
var _plugins = require("../plugins");
|
|
32
|
-
|
|
33
25
|
var _execute = require("../execute");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
var _reply = _interopRequireDefault(require("fastify/lib/reply"));
|
|
27
|
+
var _composedHandler = require("../utils/composedHandler");
|
|
28
|
+
/**
|
|
29
|
+
* We need a class, not an interface exported from types.
|
|
30
|
+
*/ // @ts-expect-error
|
|
37
31
|
const url = "/webiny-s3-event";
|
|
38
|
-
|
|
39
32
|
const createHandler = params => {
|
|
40
|
-
return (
|
|
41
|
-
const app = (0, _handler.createHandler)(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
return async (event, context) => {
|
|
34
|
+
const app = (0, _handler.createHandler)({
|
|
35
|
+
...params,
|
|
36
|
+
options: {
|
|
37
|
+
logger: params.debug === true,
|
|
38
|
+
...(params.options || {})
|
|
39
|
+
}
|
|
40
|
+
});
|
|
46
41
|
/**
|
|
47
42
|
* We always must add our default plugins to the app.
|
|
48
43
|
*/
|
|
49
|
-
|
|
50
44
|
(0, _plugins.registerDefaultPlugins)(app.webiny);
|
|
51
45
|
/**
|
|
52
46
|
* There must be an event plugin for this handler to work.
|
|
53
47
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const handler = plugins.shift();
|
|
57
|
-
|
|
58
|
-
if (!handler) {
|
|
48
|
+
const plugins = app.webiny.plugins.byType(_S3EventHandler.S3EventHandler.type).reverse();
|
|
49
|
+
if (plugins.length === 0) {
|
|
59
50
|
throw new Error(`To run @webiny/handler-aws/s3, you must have S3EventHandler set.`);
|
|
60
51
|
}
|
|
61
|
-
|
|
52
|
+
const handler = (0, _composedHandler.createComposedHandler)(plugins);
|
|
62
53
|
app.post(url, async (request, reply) => {
|
|
63
54
|
const params = {
|
|
64
55
|
request,
|
|
65
56
|
reply,
|
|
66
57
|
context: app.webiny,
|
|
67
|
-
event
|
|
58
|
+
event,
|
|
68
59
|
lambdaContext: context
|
|
69
60
|
};
|
|
70
|
-
const result = await handler
|
|
71
|
-
|
|
72
|
-
if (result instanceof Reply) {
|
|
61
|
+
const result = await handler(params);
|
|
62
|
+
if (result instanceof _reply.default) {
|
|
73
63
|
return result;
|
|
74
64
|
}
|
|
75
|
-
|
|
76
65
|
app.__webiny_raw_result = result;
|
|
77
66
|
return reply.send({});
|
|
78
67
|
});
|
|
79
68
|
return (0, _execute.execute)({
|
|
80
69
|
app,
|
|
81
70
|
url,
|
|
82
|
-
payload
|
|
71
|
+
payload: event
|
|
83
72
|
});
|
|
84
73
|
};
|
|
85
74
|
};
|
|
75
|
+
exports.createHandler = createHandler;
|
|
86
76
|
|
|
87
|
-
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
package/s3/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_handler","require","_plugins","_S3EventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_execute","_reply","_interopRequireDefault","_composedHandler","url","createHandler","params","event","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","S3EventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","Reply","__webiny_raw_result","send","execute","payload"],"sources":["index.ts"],"sourcesContent":["import { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport { S3EventHandler, S3EventHandlerCallableParams } from \"~/s3/plugins/S3EventHandler\";\nimport { execute } from \"~/execute\";\nimport { HandlerFactoryParams } from \"~/types\";\n/**\n * We need a class, not an interface exported from types.\n */\n// @ts-expect-error\nimport Reply from \"fastify/lib/reply\";\nimport { APIGatewayProxyResult, S3Event } from \"aws-lambda\";\nimport { Context as LambdaContext } from \"aws-lambda/handler\";\nimport { createComposedHandler } from \"~/utils/composedHandler\";\n\nexport * from \"./plugins/S3EventHandler\";\n\nexport interface HandlerCallable {\n (event: S3Event, context: LambdaContext): Promise<APIGatewayProxyResult>;\n}\n\nexport type HandlerParams = HandlerFactoryParams;\n\nconst url = \"/webiny-s3-event\";\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return async (event, context) => {\n const app = createBaseHandler({\n ...params,\n options: {\n logger: params.debug === true,\n ...(params.options || {})\n }\n });\n /**\n * We always must add our default plugins to the app.\n */\n registerDefaultPlugins(app.webiny);\n /**\n * There must be an event plugin for this handler to work.\n */\n const plugins = app.webiny.plugins.byType<S3EventHandler>(S3EventHandler.type).reverse();\n if (plugins.length === 0) {\n throw new Error(`To run @webiny/handler-aws/s3, you must have S3EventHandler set.`);\n }\n\n const handler = createComposedHandler<\n S3EventHandler,\n S3EventHandlerCallableParams<APIGatewayProxyResult>,\n APIGatewayProxyResult\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<S3EventHandlerCallableParams<APIGatewayProxyResult>, \"next\"> = {\n request,\n reply,\n context: app.webiny,\n event,\n lambdaContext: context\n };\n const result = await handler(\n params as unknown as S3EventHandlerCallableParams<APIGatewayProxyResult>\n );\n\n if (result instanceof Reply) {\n return result;\n }\n\n app.__webiny_raw_result = result;\n return reply.send({});\n });\n return execute({\n app,\n url,\n payload: event\n });\n };\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAYAG,MAAA,CAAAC,IAAA,CAAAF,eAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,eAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA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M;MACjB;MAEApB,GAAG,CAACsB,mBAAmB,GAAGF,MAAM;MAChC,OAAOF,KAAK,CAACK,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAO,IAAAC,gBAAO,EAAC;MACXxB,GAAG;MACHL,GAAG;MACH8B,OAAO,EAAE3B;IACb,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export interface S3EventHandlerCallableParams {
|
|
2
|
+
import { Context, Reply, Request } from "@webiny/handler/types";
|
|
3
|
+
import { Context as LambdaContext, S3Event } from "aws-lambda";
|
|
4
|
+
export interface S3EventHandlerCallableParams<Response = Reply> {
|
|
5
5
|
request: Request;
|
|
6
6
|
context: Context;
|
|
7
7
|
event: S3Event;
|
|
8
8
|
lambdaContext: LambdaContext;
|
|
9
9
|
reply: Reply;
|
|
10
|
+
next: () => Promise<Response>;
|
|
10
11
|
}
|
|
11
|
-
export interface S3EventHandlerCallable<Response> {
|
|
12
|
-
(params: S3EventHandlerCallableParams): Promise<Response
|
|
12
|
+
export interface S3EventHandlerCallable<Response = Reply> {
|
|
13
|
+
(params: S3EventHandlerCallableParams<Response>): Promise<Response>;
|
|
13
14
|
}
|
|
14
15
|
export declare class S3EventHandler<Response = any> extends Plugin {
|
|
15
16
|
static type: string;
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.createEventHandler = exports.S3EventHandler = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
var _Plugin = require("@webiny/plugins/Plugin");
|
|
13
|
-
|
|
14
8
|
class S3EventHandler extends _Plugin.Plugin {
|
|
9
|
+
static type = "handler.fastify.aws.s3.eventHandler";
|
|
15
10
|
constructor(cb) {
|
|
16
11
|
super();
|
|
17
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
18
12
|
this.cb = cb;
|
|
19
13
|
}
|
|
20
|
-
|
|
21
14
|
}
|
|
22
|
-
|
|
23
15
|
exports.S3EventHandler = S3EventHandler;
|
|
24
|
-
(0, _defineProperty2.default)(S3EventHandler, "type", "handler.fastify.aws.s3.eventHandler");
|
|
25
|
-
|
|
26
16
|
const createEventHandler = cb => {
|
|
27
17
|
return new S3EventHandler(cb);
|
|
28
18
|
};
|
|
19
|
+
exports.createEventHandler = createEventHandler;
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
//# sourceMappingURL=S3EventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["S3EventHandler","Plugin","constructor","cb","createEventHandler"],"sources":["S3EventHandler.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport {
|
|
1
|
+
{"version":3,"names":["_Plugin","require","S3EventHandler","Plugin","type","constructor","cb","exports","createEventHandler"],"sources":["S3EventHandler.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { Context, Reply, Request } from \"@webiny/handler/types\";\nimport { Context as LambdaContext, S3Event } from \"aws-lambda\";\n\nexport interface S3EventHandlerCallableParams<Response = Reply> {\n request: Request;\n context: Context;\n event: S3Event;\n lambdaContext: LambdaContext;\n reply: Reply;\n next: () => Promise<Response>;\n}\n\nexport interface S3EventHandlerCallable<Response = Reply> {\n (params: S3EventHandlerCallableParams<Response>): Promise<Response>;\n}\n\nexport class S3EventHandler<Response = any> extends Plugin {\n public static override type = \"handler.fastify.aws.s3.eventHandler\";\n\n public readonly cb: S3EventHandlerCallable<Response>;\n\n public constructor(cb: S3EventHandlerCallable<Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <Response>(cb: S3EventHandlerCallable<Response>) => {\n return new S3EventHandler<Response>(cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAiBO,MAAMC,cAAc,SAAyBC,cAAM,CAAC;EACvD,OAAuBC,IAAI,GAAG,qCAAqC;EAI5DC,WAAWA,CAACC,EAAoC,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,cAAA,GAAAA,cAAA;AAEM,MAAMM,kBAAkB,GAAcF,EAAoC,IAAK;EAClF,OAAO,IAAIJ,cAAc,CAAWI,EAAE,CAAC;AAC3C,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA"}
|
package/s3/register.d.ts
ADDED