@webiny/handler-aws 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9

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.
Files changed (101) hide show
  1. package/README.md +10 -14
  2. package/createHandler.d.ts +2 -0
  3. package/createHandler.js +23 -0
  4. package/createHandler.js.map +1 -0
  5. package/dynamodb/index.d.ts +5 -8
  6. package/dynamodb/index.js +41 -87
  7. package/dynamodb/index.js.map +1 -1
  8. package/dynamodb/plugins/DynamoDBEventHandler.d.ts +8 -7
  9. package/dynamodb/plugins/DynamoDBEventHandler.js +12 -28
  10. package/dynamodb/plugins/DynamoDBEventHandler.js.map +1 -1
  11. package/dynamodb/register.d.ts +1 -0
  12. package/dynamodb/register.js +16 -0
  13. package/dynamodb/register.js.map +1 -0
  14. package/eventBridge/index.d.ts +7 -10
  15. package/eventBridge/index.js +42 -88
  16. package/eventBridge/index.js.map +1 -1
  17. package/eventBridge/plugins/EventBridgeEventHandler.d.ts +8 -7
  18. package/eventBridge/plugins/EventBridgeEventHandler.js +12 -28
  19. package/eventBridge/plugins/EventBridgeEventHandler.js.map +1 -1
  20. package/eventBridge/register.d.ts +4 -0
  21. package/eventBridge/register.js +11 -0
  22. package/eventBridge/register.js.map +1 -0
  23. package/execute.d.ts +1 -1
  24. package/execute.js +54 -67
  25. package/execute.js.map +1 -1
  26. package/gateway/index.d.ts +7 -11
  27. package/gateway/index.js +43 -102
  28. package/gateway/index.js.map +1 -1
  29. package/gateway/register.d.ts +1 -0
  30. package/gateway/register.js +11 -0
  31. package/gateway/register.js.map +1 -0
  32. package/index.d.ts +35 -6
  33. package/index.js +17 -245
  34. package/package.json +22 -25
  35. package/plugins/index.d.ts +1 -1
  36. package/plugins/index.js +4 -12
  37. package/plugins/index.js.map +1 -1
  38. package/raw/index.d.ts +5 -10
  39. package/raw/index.js +44 -95
  40. package/raw/index.js.map +1 -1
  41. package/raw/plugins/RawEventHandler.d.ts +17 -6
  42. package/raw/plugins/RawEventHandler.js +14 -21
  43. package/raw/plugins/RawEventHandler.js.map +1 -1
  44. package/registry.d.ts +17 -0
  45. package/registry.js +23 -0
  46. package/registry.js.map +1 -0
  47. package/s3/index.d.ts +6 -9
  48. package/s3/index.js +41 -87
  49. package/s3/index.js.map +1 -1
  50. package/s3/plugins/S3EventHandler.d.ts +8 -7
  51. package/s3/plugins/S3EventHandler.js +12 -28
  52. package/s3/plugins/S3EventHandler.js.map +1 -1
  53. package/s3/register.d.ts +4 -0
  54. package/s3/register.js +15 -0
  55. package/s3/register.js.map +1 -0
  56. package/sns/index.d.ts +8 -0
  57. package/sns/index.js +42 -0
  58. package/sns/index.js.map +1 -0
  59. package/sns/plugins/SNSEventHandler.d.ts +20 -0
  60. package/sns/plugins/SNSEventHandler.js +14 -0
  61. package/sns/plugins/SNSEventHandler.js.map +1 -0
  62. package/sns/register.d.ts +1 -0
  63. package/sns/register.js +15 -0
  64. package/sns/register.js.map +1 -0
  65. package/sourceHandler.d.ts +2 -0
  66. package/sourceHandler.js +4 -0
  67. package/sourceHandler.js.map +1 -0
  68. package/sqs/index.d.ts +6 -9
  69. package/sqs/index.js +42 -87
  70. package/sqs/index.js.map +1 -1
  71. package/sqs/plugins/SQSEventHandler.d.ts +8 -7
  72. package/sqs/plugins/SQSEventHandler.js +12 -28
  73. package/sqs/plugins/SQSEventHandler.js.map +1 -1
  74. package/sqs/register.d.ts +1 -0
  75. package/sqs/register.js +16 -0
  76. package/sqs/register.js.map +1 -0
  77. package/types.d.ts +28 -5
  78. package/types.js +10 -32
  79. package/types.js.map +1 -1
  80. package/utils/composedHandler.d.ts +6 -0
  81. package/utils/composedHandler.js +8 -0
  82. package/utils/composedHandler.js.map +1 -0
  83. package/utils/index.d.ts +2 -0
  84. package/utils/index.js +2 -0
  85. package/utils/timer/CustomTimer.d.ts +5 -0
  86. package/utils/timer/CustomTimer.js +13 -0
  87. package/utils/timer/CustomTimer.js.map +1 -0
  88. package/utils/timer/Timer.d.ts +10 -0
  89. package/utils/timer/Timer.js +16 -0
  90. package/utils/timer/Timer.js.map +1 -0
  91. package/utils/timer/abstractions/ITimer.d.ts +10 -0
  92. package/utils/timer/abstractions/ITimer.js +0 -0
  93. package/utils/timer/factory.d.ts +4 -0
  94. package/utils/timer/factory.js +12 -0
  95. package/utils/timer/factory.js.map +1 -0
  96. package/utils/timer/index.d.ts +4 -0
  97. package/utils/timer/index.js +3 -0
  98. package/index.js.map +0 -1
  99. package/plugins/handlerClient.d.ts +0 -2
  100. package/plugins/handlerClient.js +0 -62
  101. package/plugins/handlerClient.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["EventBridgeEventHandler","Plugin","constructor","cb","createEventHandler"],"sources":["EventBridgeEventHandler.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { Request, Reply, Context } from \"@webiny/handler/types\";\nimport { EventBridgeEvent, Context as LambdaContext } from \"aws-lambda\";\n\nexport interface EventBridgeEventHandlerCallableParams<DetailType extends string, Detail> {\n request: Request;\n reply: Reply;\n context: Context;\n payload: EventBridgeEvent<DetailType, Detail>;\n lambdaContext: LambdaContext;\n}\nexport interface EventBridgeEventHandlerCallable<DetailType extends string, Detail, Response> {\n (params: EventBridgeEventHandlerCallableParams<DetailType, Detail>): Promise<Response | Reply>;\n}\n\nexport class EventBridgeEventHandler<\n DetailType extends string,\n Detail,\n Response = any\n> extends Plugin {\n public static override type = \"handler.fastify.aws.sqs.eventHandler\";\n\n public readonly cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>;\n\n public constructor(cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <DetailType extends string, Detail, Response = any>(\n cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>\n) => {\n return new EventBridgeEventHandler<DetailType, Detail, Response>(cb);\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAeO,MAAMA,uBAAN,SAIGC,cAJH,CAIU;EAKNC,WAAW,CAACC,EAAD,EAAoE;IAClF;IADkF;IAElF,KAAKA,EAAL,GAAUA,EAAV;EACH;;AARY;;;8BAJJH,uB,UAKqB,sC;;AAU3B,MAAMI,kBAAkB,GAC3BD,EAD8B,IAE7B;EACD,OAAO,IAAIH,uBAAJ,CAA0DG,EAA1D,CAAP;AACH,CAJM"}
1
+ {"version":3,"file":"eventBridge/plugins/EventBridgeEventHandler.js","sources":["../../../src/eventBridge/plugins/EventBridgeEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, EventBridgeEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { Context, Reply, Request } from \"@webiny/handler/types.js\";\n\nexport interface EventBridgeEventHandlerCallableParams<\n DetailType extends string,\n Detail,\n Response = Reply\n> {\n request: Request;\n reply: Reply;\n context: Context;\n payload: EventBridgeEvent<DetailType, Detail>;\n lambdaContext: LambdaContext;\n next: () => Promise<Response>;\n}\nexport interface EventBridgeEventHandlerCallable<\n DetailType extends string,\n Detail,\n Response = Reply\n> {\n (\n params: EventBridgeEventHandlerCallableParams<DetailType, Detail, Response>\n ): Promise<Response>;\n}\n\nexport class EventBridgeEventHandler<\n DetailType extends string,\n Detail,\n Response = any\n> extends Plugin {\n public static override type = \"handler.fastify.aws.eventBridge.eventHandler\";\n\n public readonly cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>;\n\n public constructor(cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <DetailType extends string, Detail, Response = any>(\n cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>\n) => {\n return new EventBridgeEventHandler<DetailType, Detail, Response>(cb);\n};\n"],"names":["EventBridgeEventHandler","Plugin","cb","createEventHandler"],"mappings":";AA0BO,MAAMA,gCAIHC;;aACiB,IAAI,GAAG;;IAI9B,YAAmBC,EAAiE,CAAE;QAClF,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;AACJ;AAEO,MAAMC,qBAAqB,CAC9BD,KAEO,IAAIF,wBAAsDE"}
@@ -0,0 +1,4 @@
1
+ import type { HandlerFactoryParams } from "../types.js";
2
+ export interface HandlerParams extends HandlerFactoryParams {
3
+ debug?: boolean;
4
+ }
@@ -0,0 +1,11 @@
1
+ import { registry } from "../registry.js";
2
+ import { createSourceHandler } from "../sourceHandler.js";
3
+ import { createHandler } from "./index.js";
4
+ const handler = createSourceHandler({
5
+ name: "handler-aws-event-bridge",
6
+ canUse: (event)=>!!event.source,
7
+ handle: async ({ params, event, context })=>createHandler(params)(event, context)
8
+ });
9
+ registry.register(handler);
10
+
11
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventBridge/register.js","sources":["../../src/eventBridge/register.ts"],"sourcesContent":["import type { EventBridgeEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { registry } from \"~/registry.js\";\nimport type { HandlerFactoryParams } from \"~/types.js\";\nimport { createSourceHandler } from \"~/sourceHandler.js\";\nimport { createHandler } from \"~/eventBridge/index.js\";\n\nexport interface HandlerParams extends HandlerFactoryParams {\n debug?: boolean;\n}\n\nconst handler = createSourceHandler<EventBridgeEvent<string, string>, HandlerParams>({\n name: \"handler-aws-event-bridge\",\n canUse: event => {\n return !!event.source;\n },\n handle: async ({ params, event, context }) => {\n return createHandler(params)(event, context);\n }\n});\n\nregistry.register(handler);\n"],"names":["handler","createSourceHandler","event","params","context","createHandler","registry"],"mappings":";;;AAUA,MAAMA,UAAUC,oBAAqE;IACjF,MAAM;IACN,QAAQC,CAAAA,QACG,CAAC,CAACA,MAAM,MAAM;IAEzB,QAAQ,OAAO,EAAEC,MAAM,EAAED,KAAK,EAAEE,OAAO,EAAE,GAC9BC,cAAcF,QAAQD,OAAOE;AAE5C;AAEAE,SAAS,QAAQ,CAACN"}
package/execute.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FastifyInstance } from "@webiny/handler/types";
1
+ import type { FastifyInstance } from "@webiny/handler/types.js";
2
2
  export interface ExecuteParams {
3
3
  app: FastifyInstance;
4
4
  url: string;
package/execute.js CHANGED
@@ -1,71 +1,58 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.execute = void 0;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
- var _types = require("./types");
13
-
14
- const createHandleResponse = (app, resolve) => {
15
- return (err, result) => {
16
- if (err) {
17
- return resolve({
18
- statusCode: 500,
19
- body: JSON.stringify(err),
20
- headers: {}
21
- });
22
- }
23
-
24
- if (app.__webiny_raw_result) {
25
- return resolve(app.__webiny_raw_result);
26
- }
27
-
28
- const isBase64Encoded = !!result.headers[_types.Base64EncodeHeader.encoded] || !!result.headers[_types.Base64EncodeHeader.binary];
29
- const response = {
30
- statusCode: result.statusCode,
31
- body: isBase64Encoded ? result.rawPayload.toString("base64") : result.payload,
32
- headers: result.headers,
33
- isBase64Encoded
1
+ import { Base64EncodeHeader } from "./types.js";
2
+ const createHandleResponse = (app, resolve)=>(err, result)=>{
3
+ if (err) return resolve({
4
+ statusCode: 500,
5
+ body: JSON.stringify(err),
6
+ headers: {}
7
+ });
8
+ if (app.__webiny_raw_result) return resolve(app.__webiny_raw_result);
9
+ if (!result) {
10
+ const response = {
11
+ statusCode: 200,
12
+ body: "",
13
+ headers: {},
14
+ isBase64Encoded: false
15
+ };
16
+ return resolve(response);
17
+ }
18
+ const isBase64Encoded = !!result.headers[Base64EncodeHeader.encoded] || !!result.headers[Base64EncodeHeader.binary];
19
+ const response = {
20
+ statusCode: result.statusCode,
21
+ body: isBase64Encoded ? result.rawPayload.toString("base64") : result.payload,
22
+ headers: result.headers,
23
+ isBase64Encoded
24
+ };
25
+ return resolve(response);
34
26
  };
35
- return resolve(response);
36
- };
37
- };
38
-
39
- const getPayloadProperty = (payload, prop, defaults = {}) => {
40
- if (typeof payload === "object") {
41
- const value = payload[prop] ? payload[prop] : {};
42
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaults), value);
43
- }
44
-
45
- return defaults;
27
+ const getPayloadProperty = (payload, prop, defaults = {})=>{
28
+ if (payload && "object" == typeof payload) {
29
+ const value = payload[prop] ? payload[prop] : {};
30
+ return {
31
+ ...defaults,
32
+ ...value
33
+ };
34
+ }
35
+ return defaults;
46
36
  };
47
-
48
- const execute = params => {
49
- const {
50
- app,
51
- url,
52
- payload
53
- } = params;
54
- const query = getPayloadProperty(payload, "query", {});
55
- const headers = getPayloadProperty(payload, "headers", {
56
- ["content-type"]: "application/json"
57
- });
58
- const cookies = getPayloadProperty(payload, "cookies", {});
59
- return new Promise(resolve => {
60
- app.inject({
61
- method: "POST",
62
- url,
63
- payload: payload || {},
64
- query,
65
- headers,
66
- cookies
67
- }, createHandleResponse(app, resolve));
68
- });
37
+ const execute = (params)=>{
38
+ const { app, url, payload } = params;
39
+ const query = getPayloadProperty(payload, "query", {});
40
+ const headers = getPayloadProperty(payload, "headers", {
41
+ ["content-type"]: "application/json"
42
+ });
43
+ const cookies = getPayloadProperty(payload, "cookies", {});
44
+ return new Promise((resolve)=>{
45
+ app.inject({
46
+ method: "POST",
47
+ url,
48
+ payload: payload || {},
49
+ body: payload || {},
50
+ query,
51
+ headers,
52
+ cookies
53
+ }, createHandleResponse(app, resolve));
54
+ });
69
55
  };
56
+ export { execute };
70
57
 
71
- exports.execute = execute;
58
+ //# sourceMappingURL=execute.js.map
package/execute.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["createHandleResponse","app","resolve","err","result","statusCode","body","JSON","stringify","headers","__webiny_raw_result","isBase64Encoded","Base64EncodeHeader","encoded","binary","response","rawPayload","toString","payload","getPayloadProperty","prop","defaults","value","execute","params","url","query","cookies","Promise","inject","method"],"sources":["execute.ts"],"sourcesContent":["import { FastifyInstance } from \"@webiny/handler/types\";\nimport { APIGatewayProxyResult } from \"aws-lambda/trigger/api-gateway-proxy\";\nimport { LightMyRequestCallback } from \"fastify\";\nimport { Base64EncodeHeader } from \"~/types\";\n\ninterface Resolve {\n (response: APIGatewayProxyResult | any): void;\n}\nconst createHandleResponse = (app: FastifyInstance, resolve: Resolve): LightMyRequestCallback => {\n return (err, result) => {\n if (err) {\n return resolve({\n statusCode: 500,\n body: JSON.stringify(err),\n headers: {}\n });\n }\n if (app.__webiny_raw_result) {\n return resolve(app.__webiny_raw_result);\n }\n const isBase64Encoded =\n !!result.headers[Base64EncodeHeader.encoded] ||\n !!result.headers[Base64EncodeHeader.binary];\n const response: APIGatewayProxyResult = {\n statusCode: result.statusCode,\n body: isBase64Encoded ? result.rawPayload.toString(\"base64\") : result.payload,\n headers: result.headers as APIGatewayProxyResult[\"headers\"],\n isBase64Encoded\n };\n return resolve(response);\n };\n};\n\nconst getPayloadProperty = (\n payload: any,\n prop: string,\n defaults: Record<string, any> = {}\n): Record<string, any> => {\n if (typeof payload === \"object\") {\n const value = payload[prop] ? payload[prop] : {};\n\n return {\n ...defaults,\n ...value\n };\n }\n return defaults;\n};\n\nexport interface ExecuteParams {\n app: FastifyInstance;\n url: string;\n payload: any;\n}\n\nexport const execute = (params: ExecuteParams): Promise<any> => {\n const { app, url, payload } = params;\n\n const query = getPayloadProperty(payload, \"query\", {});\n const headers = getPayloadProperty(payload, \"headers\", {\n [\"content-type\"]: \"application/json\"\n });\n const cookies = getPayloadProperty(payload, \"cookies\", {});\n\n return new Promise(resolve => {\n app.inject(\n {\n method: \"POST\",\n url,\n payload: payload || {},\n query,\n headers,\n cookies\n },\n createHandleResponse(app, resolve)\n );\n });\n};\n"],"mappings":";;;;;;;;;;;AAGA;;AAKA,MAAMA,oBAAoB,GAAG,CAACC,GAAD,EAAuBC,OAAvB,KAAoE;EAC7F,OAAO,CAACC,GAAD,EAAMC,MAAN,KAAiB;IACpB,IAAID,GAAJ,EAAS;MACL,OAAOD,OAAO,CAAC;QACXG,UAAU,EAAE,GADD;QAEXC,IAAI,EAAEC,IAAI,CAACC,SAAL,CAAeL,GAAf,CAFK;QAGXM,OAAO,EAAE;MAHE,CAAD,CAAd;IAKH;;IACD,IAAIR,GAAG,CAACS,mBAAR,EAA6B;MACzB,OAAOR,OAAO,CAACD,GAAG,CAACS,mBAAL,CAAd;IACH;;IACD,MAAMC,eAAe,GACjB,CAAC,CAACP,MAAM,CAACK,OAAP,CAAeG,yBAAA,CAAmBC,OAAlC,CAAF,IACA,CAAC,CAACT,MAAM,CAACK,OAAP,CAAeG,yBAAA,CAAmBE,MAAlC,CAFN;IAGA,MAAMC,QAA+B,GAAG;MACpCV,UAAU,EAAED,MAAM,CAACC,UADiB;MAEpCC,IAAI,EAAEK,eAAe,GAAGP,MAAM,CAACY,UAAP,CAAkBC,QAAlB,CAA2B,QAA3B,CAAH,GAA0Cb,MAAM,CAACc,OAFlC;MAGpCT,OAAO,EAAEL,MAAM,CAACK,OAHoB;MAIpCE;IAJoC,CAAxC;IAMA,OAAOT,OAAO,CAACa,QAAD,CAAd;EACH,CArBD;AAsBH,CAvBD;;AAyBA,MAAMI,kBAAkB,GAAG,CACvBD,OADuB,EAEvBE,IAFuB,EAGvBC,QAA6B,GAAG,EAHT,KAID;EACtB,IAAI,OAAOH,OAAP,KAAmB,QAAvB,EAAiC;IAC7B,MAAMI,KAAK,GAAGJ,OAAO,CAACE,IAAD,CAAP,GAAgBF,OAAO,CAACE,IAAD,CAAvB,GAAgC,EAA9C;IAEA,mEACOC,QADP,GAEOC,KAFP;EAIH;;EACD,OAAOD,QAAP;AACH,CAdD;;AAsBO,MAAME,OAAO,GAAIC,MAAD,IAAyC;EAC5D,MAAM;IAAEvB,GAAF;IAAOwB,GAAP;IAAYP;EAAZ,IAAwBM,MAA9B;EAEA,MAAME,KAAK,GAAGP,kBAAkB,CAACD,OAAD,EAAU,OAAV,EAAmB,EAAnB,CAAhC;EACA,MAAMT,OAAO,GAAGU,kBAAkB,CAACD,OAAD,EAAU,SAAV,EAAqB;IACnD,CAAC,cAAD,GAAkB;EADiC,CAArB,CAAlC;EAGA,MAAMS,OAAO,GAAGR,kBAAkB,CAACD,OAAD,EAAU,SAAV,EAAqB,EAArB,CAAlC;EAEA,OAAO,IAAIU,OAAJ,CAAY1B,OAAO,IAAI;IAC1BD,GAAG,CAAC4B,MAAJ,CACI;MACIC,MAAM,EAAE,MADZ;MAEIL,GAFJ;MAGIP,OAAO,EAAEA,OAAO,IAAI,EAHxB;MAIIQ,KAJJ;MAKIjB,OALJ;MAMIkB;IANJ,CADJ,EASI3B,oBAAoB,CAACC,GAAD,EAAMC,OAAN,CATxB;EAWH,CAZM,CAAP;AAaH,CAtBM"}
1
+ {"version":3,"file":"execute.js","sources":["../src/execute.ts"],"sourcesContent":["import type { FastifyInstance } from \"@webiny/handler/types.js\";\nimport type { APIGatewayProxyResult } from \"@webiny/aws-sdk/types/index.js\";\nimport type { LightMyRequestCallback } from \"fastify\";\nimport { Base64EncodeHeader } from \"~/types.js\";\n\ninterface Resolve {\n (response: APIGatewayProxyResult | any): void;\n}\nconst createHandleResponse = (app: FastifyInstance, resolve: Resolve): LightMyRequestCallback => {\n return (err, result) => {\n if (err) {\n return resolve({\n statusCode: 500,\n body: JSON.stringify(err),\n headers: {}\n });\n }\n if (app.__webiny_raw_result) {\n return resolve(app.__webiny_raw_result);\n } else if (!result) {\n const response: APIGatewayProxyResult = {\n statusCode: 200,\n body: \"\",\n headers: {},\n isBase64Encoded: false\n };\n return resolve(response);\n }\n\n const isBase64Encoded =\n !!result.headers[Base64EncodeHeader.encoded] ||\n !!result.headers[Base64EncodeHeader.binary];\n const response: APIGatewayProxyResult = {\n statusCode: result.statusCode,\n body: isBase64Encoded ? result.rawPayload.toString(\"base64\") : result.payload,\n headers: result.headers as APIGatewayProxyResult[\"headers\"],\n isBase64Encoded\n };\n return resolve(response);\n };\n};\n\nconst getPayloadProperty = (\n payload: any,\n prop: string,\n defaults: Record<string, any> = {}\n): Record<string, any> => {\n if (payload && typeof payload === \"object\") {\n const value = payload[prop] ? payload[prop] : {};\n\n return {\n ...defaults,\n ...value\n };\n }\n return defaults;\n};\n\nexport interface ExecuteParams {\n app: FastifyInstance;\n url: string;\n payload: any;\n}\n\nexport const execute = (params: ExecuteParams): Promise<any> => {\n const { app, url, payload } = params;\n\n const query = getPayloadProperty(payload, \"query\", {});\n const headers = getPayloadProperty(payload, \"headers\", {\n [\"content-type\"]: \"application/json\"\n });\n\n const cookies = getPayloadProperty(payload, \"cookies\", {});\n\n return new Promise(resolve => {\n app.inject(\n {\n method: \"POST\",\n url,\n payload: payload || {},\n body: payload || {},\n query,\n headers,\n cookies\n },\n createHandleResponse(app, resolve)\n );\n });\n};\n"],"names":["createHandleResponse","app","resolve","err","result","JSON","response","isBase64Encoded","Base64EncodeHeader","getPayloadProperty","payload","prop","defaults","value","execute","params","url","query","headers","cookies","Promise"],"mappings":";AAQA,MAAMA,uBAAuB,CAACC,KAAsBC,UACzC,CAACC,KAAKC;QACT,IAAID,KACA,OAAOD,QAAQ;YACX,YAAY;YACZ,MAAMG,KAAK,SAAS,CAACF;YACrB,SAAS,CAAC;QACd;QAEJ,IAAIF,IAAI,mBAAmB,EACvB,OAAOC,QAAQD,IAAI,mBAAmB;QACnC,IAAI,CAACG,QAAQ;YAChB,MAAME,WAAkC;gBACpC,YAAY;gBACZ,MAAM;gBACN,SAAS,CAAC;gBACV,iBAAiB;YACrB;YACA,OAAOJ,QAAQI;QACnB;QAEA,MAAMC,kBACF,CAAC,CAACH,OAAO,OAAO,CAACI,mBAAmB,OAAO,CAAC,IAC5C,CAAC,CAACJ,OAAO,OAAO,CAACI,mBAAmB,MAAM,CAAC;QAC/C,MAAMF,WAAkC;YACpC,YAAYF,OAAO,UAAU;YAC7B,MAAMG,kBAAkBH,OAAO,UAAU,CAAC,QAAQ,CAAC,YAAYA,OAAO,OAAO;YAC7E,SAASA,OAAO,OAAO;YACvBG;QACJ;QACA,OAAOL,QAAQI;IACnB;AAGJ,MAAMG,qBAAqB,CACvBC,SACAC,MACAC,WAAgC,CAAC,CAAC;IAElC,IAAIF,WAAW,AAAmB,YAAnB,OAAOA,SAAsB;QACxC,MAAMG,QAAQH,OAAO,CAACC,KAAK,GAAGD,OAAO,CAACC,KAAK,GAAG,CAAC;QAE/C,OAAO;YACH,GAAGC,QAAQ;YACX,GAAGC,KAAK;QACZ;IACJ;IACA,OAAOD;AACX;AAQO,MAAME,UAAU,CAACC;IACpB,MAAM,EAAEd,GAAG,EAAEe,GAAG,EAAEN,OAAO,EAAE,GAAGK;IAE9B,MAAME,QAAQR,mBAAmBC,SAAS,SAAS,CAAC;IACpD,MAAMQ,UAAUT,mBAAmBC,SAAS,WAAW;QACnD,CAAC,eAAe,EAAE;IACtB;IAEA,MAAMS,UAAUV,mBAAmBC,SAAS,WAAW,CAAC;IAExD,OAAO,IAAIU,QAAQlB,CAAAA;QACfD,IAAI,MAAM,CACN;YACI,QAAQ;YACRe;YACA,SAASN,WAAW,CAAC;YACrB,MAAMA,WAAW,CAAC;YAClBO;YACAC;YACAC;QACJ,GACAnB,qBAAqBC,KAAKC;IAElC;AACJ"}
@@ -1,14 +1,10 @@
1
- import { LambdaFastifyOptions as LambdaOptions, LambdaResponse } from "@fastify/aws-lambda";
2
- import { APIGatewayEvent, Context as LambdaContext } from "aws-lambda";
3
- import { CreateHandlerParams as BaseCreateHandlerParams, RoutePlugin, createRoute } from "@webiny/handler";
1
+ import type { APIGatewayEvent, Context as LambdaContext } from "@webiny/aws-sdk/types/index.js";
2
+ import type { LambdaResponse } from "@fastify/aws-lambda";
3
+ import { createRoute, RoutePlugin } from "@webiny/handler";
4
+ import type { HandlerFactoryParams } from "../types.js";
5
+ export { RoutePlugin, createRoute };
6
+ export type HandlerParams = HandlerFactoryParams;
4
7
  export interface HandlerCallable {
5
8
  (event: APIGatewayEvent, ctx: LambdaContext): Promise<LambdaResponse>;
6
9
  }
7
- export interface CreateHandlerParams extends BaseCreateHandlerParams {
8
- http?: {
9
- debug?: boolean;
10
- };
11
- lambdaOptions?: LambdaOptions;
12
- }
13
- export declare const createHandler: (params: CreateHandlerParams) => HandlerCallable;
14
- export { RoutePlugin, createRoute };
10
+ export declare const createHandler: (params: HandlerParams) => HandlerCallable;
package/gateway/index.js CHANGED
@@ -1,107 +1,48 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- Object.defineProperty(exports, "RoutePlugin", {
9
- enumerable: true,
10
- get: function () {
11
- return _handler.RoutePlugin;
12
- }
13
- });
14
- exports.createHandler = void 0;
15
- Object.defineProperty(exports, "createRoute", {
16
- enumerable: true,
17
- get: function () {
18
- return _handler.createRoute;
19
- }
20
- });
21
-
22
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
23
-
24
- var _awsLambda = _interopRequireDefault(require("@fastify/aws-lambda"));
25
-
26
- var _handler = require("@webiny/handler");
27
-
28
- var _plugins = require("../plugins");
29
-
30
- var _types = require("../types");
31
-
32
- const getHeader = (headers, header) => {
33
- for (const key in headers) {
34
- if (key.toLowerCase() !== header) {
35
- continue;
36
- }
37
-
38
- return headers[key];
39
- }
40
-
41
- return undefined;
1
+ import aws_lambda from "@fastify/aws-lambda";
2
+ import { RoutePlugin, createHandler, createRoute } from "@webiny/handler";
3
+ import { registerDefaultPlugins } from "../plugins/index.js";
4
+ import { Base64EncodeHeader } from "../types.js";
5
+ const getHeader = (headers, header)=>{
6
+ for(const key in headers)if (key.toLowerCase() === header) return headers[key];
42
7
  };
43
-
44
8
  const defaultContentType = "application/json";
45
9
  const defaultCharset = "utf-8";
46
- /**
47
- * We need to attach default headers to the request, so it does not break if there is none sent.
48
- */
49
-
50
- const attachRequiredProperties = event => {
51
- /**
52
- * A possibility that headers are not defined?
53
- * Maybe during testing?
54
- */
55
- if (!event.headers) {
56
- event.headers = {};
57
- }
58
-
59
- const contentType = getHeader(event.headers, "content-type");
60
- /**
61
- * We check the existing content type and add the default one if it does not exist.
62
- *
63
- * Also, if the content-type is the application/json, and the body is not sent, we add it.
64
- */
65
-
66
- if (!contentType) {
67
- event.headers["content-type"] = [defaultContentType, `charset=${defaultCharset}`].join(";");
68
- event.body = "{}";
69
- } else if (!event.body && contentType.startsWith(defaultContentType)) {
70
- event.body = "{}";
71
- }
72
- };
73
-
74
- const createHandler = params => {
75
- return (event, context) => {
76
- var _params$http;
77
-
78
- const app = (0, _handler.createHandler)({
79
- plugins: params.plugins,
80
- options: (0, _objectSpread2.default)({
81
- logger: ((_params$http = params.http) === null || _params$http === void 0 ? void 0 : _params$http.debug) === true
82
- }, params.options || {})
83
- });
84
- /**
85
- * We always must add our default plugins to the app.
86
- */
87
-
88
- (0, _plugins.registerDefaultPlugins)(app.webiny);
89
-
90
- if (app.webiny.plugins.byType(_handler.RoutePlugin.type).length === 0) {
91
- throw new Error(`To run @webiny/handler-aws/gateway, you must have at least one RoutePlugin set.`);
10
+ const attachRequiredProperties = (event)=>{
11
+ const isOptions = "options" === event.httpMethod.toLowerCase();
12
+ if (!event.headers) event.headers = {};
13
+ const contentType = getHeader(event.headers, "content-type");
14
+ if (contentType) {
15
+ if (!event.body && contentType.startsWith(defaultContentType)) event.body = "{}";
16
+ } else {
17
+ event.headers["content-type"] = [
18
+ defaultContentType,
19
+ `charset=${defaultCharset}`
20
+ ].join(";");
21
+ event.body = "{}";
92
22
  }
93
-
94
- attachRequiredProperties(event);
95
- const appLambda = (0, _awsLambda.default)(app, (0, _objectSpread2.default)({
96
- decorateRequest: true,
97
- serializeLambdaArguments: true,
98
- decorationPropertyName: "awsLambda",
99
- enforceBase64: response => {
100
- return !!response.headers[_types.Base64EncodeHeader.encoded] || !!response.headers[_types.Base64EncodeHeader.binary];
101
- }
102
- }, params.lambdaOptions || {}));
103
- return appLambda(event, context);
104
- };
23
+ if (!isOptions) return;
24
+ event.body = null;
105
25
  };
106
-
107
- exports.createHandler = createHandler;
26
+ const gateway_createHandler = (params)=>async (event, context)=>{
27
+ const app = createHandler({
28
+ ...params,
29
+ options: {
30
+ logger: true === params.debug,
31
+ ...params.options || {}
32
+ }
33
+ });
34
+ registerDefaultPlugins(app.webiny);
35
+ if (0 === app.webiny.plugins.byType(RoutePlugin.type).length) throw new Error("To run @webiny/handler-aws/gateway, you must have at least one RoutePlugin set.");
36
+ attachRequiredProperties(event);
37
+ const appLambda = aws_lambda(app, {
38
+ decorateRequest: true,
39
+ serializeLambdaArguments: true,
40
+ decorationPropertyName: "awsLambda",
41
+ enforceBase64: (response)=>!!response.headers[Base64EncodeHeader.encoded] || !!response.headers[Base64EncodeHeader.binary],
42
+ ...params.lambdaOptions || {}
43
+ });
44
+ return appLambda(event, context);
45
+ };
46
+ export { RoutePlugin, createRoute, gateway_createHandler as createHandler };
47
+
48
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getHeader","headers","header","key","toLowerCase","undefined","defaultContentType","defaultCharset","attachRequiredProperties","event","contentType","join","body","startsWith","createHandler","params","context","app","createBaseHandler","plugins","options","logger","http","debug","registerDefaultPlugins","webiny","byType","RoutePlugin","type","length","Error","appLambda","awsLambdaFastify","decorateRequest","serializeLambdaArguments","decorationPropertyName","enforceBase64","response","Base64EncodeHeader","encoded","binary","lambdaOptions"],"sources":["index.ts"],"sourcesContent":["import awsLambdaFastify, {\n LambdaFastifyOptions as LambdaOptions,\n LambdaResponse\n} from \"@fastify/aws-lambda\";\nimport { APIGatewayEvent, Context as LambdaContext } from \"aws-lambda\";\nimport {\n createHandler as createBaseHandler,\n CreateHandlerParams as BaseCreateHandlerParams,\n RoutePlugin,\n createRoute\n} from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport { Base64EncodeHeader } from \"~/types\";\nimport { APIGatewayProxyEventHeaders } from \"aws-lambda/trigger/api-gateway-proxy\";\n\nexport interface HandlerCallable {\n (event: APIGatewayEvent, ctx: LambdaContext): Promise<LambdaResponse>;\n}\n\nexport interface CreateHandlerParams extends BaseCreateHandlerParams {\n http?: {\n debug?: boolean;\n };\n lambdaOptions?: LambdaOptions;\n}\n\nconst getHeader = (headers: APIGatewayProxyEventHeaders, header: string): string | undefined => {\n for (const key in headers) {\n if (key.toLowerCase() !== header) {\n continue;\n }\n return headers[key];\n }\n return undefined;\n};\n\nconst defaultContentType = \"application/json\";\nconst defaultCharset = \"utf-8\";\n/**\n * We need to attach default headers to the request, so it does not break if there is none sent.\n */\nconst attachRequiredProperties = (event: APIGatewayEvent): void => {\n /**\n * A possibility that headers are not defined?\n * Maybe during testing?\n */\n if (!event.headers) {\n event.headers = {};\n }\n const contentType = getHeader(event.headers, \"content-type\");\n /**\n * We check the existing content type and add the default one if it does not exist.\n *\n * Also, if the content-type is the application/json, and the body is not sent, we add it.\n */\n if (!contentType) {\n event.headers[\"content-type\"] = [defaultContentType, `charset=${defaultCharset}`].join(\";\");\n event.body = \"{}\";\n } else if (!event.body && contentType.startsWith(defaultContentType)) {\n event.body = \"{}\";\n }\n};\n\nexport const createHandler = (params: CreateHandlerParams): HandlerCallable => {\n return (event, context) => {\n const app = createBaseHandler({\n plugins: params.plugins,\n options: {\n logger: params.http?.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 if (app.webiny.plugins.byType<RoutePlugin>(RoutePlugin.type).length === 0) {\n throw new Error(\n `To run @webiny/handler-aws/gateway, you must have at least one RoutePlugin set.`\n );\n }\n attachRequiredProperties(event);\n\n const appLambda = awsLambdaFastify(app, {\n decorateRequest: true,\n serializeLambdaArguments: true,\n decorationPropertyName: \"awsLambda\",\n enforceBase64: response => {\n return (\n !!response.headers[Base64EncodeHeader.encoded] ||\n !!response.headers[Base64EncodeHeader.binary]\n );\n },\n ...(params.lambdaOptions || {})\n });\n return appLambda(event, context);\n };\n};\n\nexport { RoutePlugin, createRoute };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAKA;;AAMA;;AACA;;AAcA,MAAMA,SAAS,GAAG,CAACC,OAAD,EAAuCC,MAAvC,KAA8E;EAC5F,KAAK,MAAMC,GAAX,IAAkBF,OAAlB,EAA2B;IACvB,IAAIE,GAAG,CAACC,WAAJ,OAAsBF,MAA1B,EAAkC;MAC9B;IACH;;IACD,OAAOD,OAAO,CAACE,GAAD,CAAd;EACH;;EACD,OAAOE,SAAP;AACH,CARD;;AAUA,MAAMC,kBAAkB,GAAG,kBAA3B;AACA,MAAMC,cAAc,GAAG,OAAvB;AACA;AACA;AACA;;AACA,MAAMC,wBAAwB,GAAIC,KAAD,IAAkC;EAC/D;AACJ;AACA;AACA;EACI,IAAI,CAACA,KAAK,CAACR,OAAX,EAAoB;IAChBQ,KAAK,CAACR,OAAN,GAAgB,EAAhB;EACH;;EACD,MAAMS,WAAW,GAAGV,SAAS,CAACS,KAAK,CAACR,OAAP,EAAgB,cAAhB,CAA7B;EACA;AACJ;AACA;AACA;AACA;;EACI,IAAI,CAACS,WAAL,EAAkB;IACdD,KAAK,CAACR,OAAN,CAAc,cAAd,IAAgC,CAACK,kBAAD,EAAsB,WAAUC,cAAe,EAA/C,EAAkDI,IAAlD,CAAuD,GAAvD,CAAhC;IACAF,KAAK,CAACG,IAAN,GAAa,IAAb;EACH,CAHD,MAGO,IAAI,CAACH,KAAK,CAACG,IAAP,IAAeF,WAAW,CAACG,UAAZ,CAAuBP,kBAAvB,CAAnB,EAA+D;IAClEG,KAAK,CAACG,IAAN,GAAa,IAAb;EACH;AACJ,CApBD;;AAsBO,MAAME,aAAa,GAAIC,MAAD,IAAkD;EAC3E,OAAO,CAACN,KAAD,EAAQO,OAAR,KAAoB;IAAA;;IACvB,MAAMC,GAAG,GAAG,IAAAC,sBAAA,EAAkB;MAC1BC,OAAO,EAAEJ,MAAM,CAACI,OADU;MAE1BC,OAAO;QACHC,MAAM,EAAE,iBAAAN,MAAM,CAACO,IAAP,8DAAaC,KAAb,MAAuB;MAD5B,GAECR,MAAM,CAACK,OAAP,IAAkB,EAFnB;IAFmB,CAAlB,CAAZ;IAOA;AACR;AACA;;IACQ,IAAAI,+BAAA,EAAuBP,GAAG,CAACQ,MAA3B;;IAEA,IAAIR,GAAG,CAACQ,MAAJ,CAAWN,OAAX,CAAmBO,MAAnB,CAAuCC,oBAAA,CAAYC,IAAnD,EAAyDC,MAAzD,KAAoE,CAAxE,EAA2E;MACvE,MAAM,IAAIC,KAAJ,CACD,iFADC,CAAN;IAGH;;IACDtB,wBAAwB,CAACC,KAAD,CAAxB;IAEA,MAAMsB,SAAS,GAAG,IAAAC,kBAAA,EAAiBf,GAAjB;MACdgB,eAAe,EAAE,IADH;MAEdC,wBAAwB,EAAE,IAFZ;MAGdC,sBAAsB,EAAE,WAHV;MAIdC,aAAa,EAAEC,QAAQ,IAAI;QACvB,OACI,CAAC,CAACA,QAAQ,CAACpC,OAAT,CAAiBqC,yBAAA,CAAmBC,OAApC,CAAF,IACA,CAAC,CAACF,QAAQ,CAACpC,OAAT,CAAiBqC,yBAAA,CAAmBE,MAApC,CAFN;MAIH;IATa,GAUVzB,MAAM,CAAC0B,aAAP,IAAwB,EAVd,EAAlB;IAYA,OAAOV,SAAS,CAACtB,KAAD,EAAQO,OAAR,CAAhB;EACH,CAjCD;AAkCH,CAnCM"}
1
+ {"version":3,"file":"gateway/index.js","sources":["../../src/gateway/index.ts"],"sourcesContent":["import type {\n APIGatewayEvent,\n APIGatewayProxyEventHeaders,\n Context as LambdaContext\n} from \"@webiny/aws-sdk/types/index.js\";\nimport type { LambdaResponse } from \"@fastify/aws-lambda\";\nimport awsLambdaFastify from \"@fastify/aws-lambda\";\nimport { createHandler as createBaseHandler, createRoute, RoutePlugin } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins/index.js\";\nimport type { HandlerFactoryParams } from \"~/types.js\";\nimport { Base64EncodeHeader } from \"~/types.js\";\n\nexport { RoutePlugin, createRoute };\n\nexport type HandlerParams = HandlerFactoryParams;\n\nexport interface HandlerCallable {\n (event: APIGatewayEvent, ctx: LambdaContext): Promise<LambdaResponse>;\n}\n\nconst getHeader = (headers: APIGatewayProxyEventHeaders, header: string): string | undefined => {\n for (const key in headers) {\n if (key.toLowerCase() !== header) {\n continue;\n }\n return headers[key];\n }\n return undefined;\n};\n\nconst defaultContentType = \"application/json\";\nconst defaultCharset = \"utf-8\";\n/**\n * We need to attach default headers to the request, so it does not break if there is none sent.\n */\nconst attachRequiredProperties = (event: APIGatewayEvent): void => {\n const isOptions = event.httpMethod.toLowerCase() === \"options\";\n /**\n * A possibility that headers are not defined?\n * Maybe during testing?\n */\n if (!event.headers) {\n event.headers = {};\n }\n const contentType = getHeader(event.headers, \"content-type\");\n /**\n * We check the existing content type and add the default one if it does not exist.\n *\n * Also, if the content-type is the application/json, and the body is not sent, we add it.\n */\n if (!contentType) {\n event.headers[\"content-type\"] = [defaultContentType, `charset=${defaultCharset}`].join(\";\");\n event.body = \"{}\";\n } else if (!event.body && contentType.startsWith(defaultContentType)) {\n event.body = \"{}\";\n }\n if (!isOptions) {\n return;\n }\n event.body = null;\n};\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 if (app.webiny.plugins.byType<RoutePlugin>(RoutePlugin.type).length === 0) {\n throw new Error(\n `To run @webiny/handler-aws/gateway, you must have at least one RoutePlugin set.`\n );\n }\n attachRequiredProperties(event);\n\n const appLambda = awsLambdaFastify(app, {\n decorateRequest: true,\n serializeLambdaArguments: true,\n decorationPropertyName: \"awsLambda\",\n enforceBase64: response => {\n return (\n !!response.headers[Base64EncodeHeader.encoded] ||\n !!response.headers[Base64EncodeHeader.binary]\n );\n },\n ...(params.lambdaOptions || {})\n });\n return appLambda(event, context);\n };\n};\n"],"names":["getHeader","headers","header","key","defaultContentType","defaultCharset","attachRequiredProperties","event","isOptions","contentType","createHandler","params","context","app","createBaseHandler","registerDefaultPlugins","RoutePlugin","Error","appLambda","awsLambdaFastify","response","Base64EncodeHeader"],"mappings":";;;;AAoBA,MAAMA,YAAY,CAACC,SAAsCC;IACrD,IAAK,MAAMC,OAAOF,QACd,IAAIE,IAAI,WAAW,OAAOD,QAG1B,OAAOD,OAAO,CAACE,IAAI;AAG3B;AAEA,MAAMC,qBAAqB;AAC3B,MAAMC,iBAAiB;AAIvB,MAAMC,2BAA2B,CAACC;IAC9B,MAAMC,YAAYD,AAAmC,cAAnCA,MAAM,UAAU,CAAC,WAAW;IAK9C,IAAI,CAACA,MAAM,OAAO,EACdA,MAAM,OAAO,GAAG,CAAC;IAErB,MAAME,cAAcT,UAAUO,MAAM,OAAO,EAAE;IAM7C,IAAKE,aAGE;QAAA,IAAI,CAACF,MAAM,IAAI,IAAIE,YAAY,UAAU,CAACL,qBAC7CG,MAAM,IAAI,GAAG;IACjB,OALkB;QACdA,MAAM,OAAO,CAAC,eAAe,GAAG;YAACH;YAAoB,CAAC,QAAQ,EAAEC,gBAAgB;SAAC,CAAC,IAAI,CAAC;QACvFE,MAAM,IAAI,GAAG;IACjB;IAGA,IAAI,CAACC,WACD;IAEJD,MAAM,IAAI,GAAG;AACjB;AAEO,MAAMG,wBAAgB,CAACC,SACnB,OAAOJ,OAAOK;QACjB,MAAMC,MAAMC,cAAkB;YAC1B,GAAGH,MAAM;YACT,SAAS;gBACL,QAAQA,AAAiB,SAAjBA,OAAO,KAAK;gBACpB,GAAIA,OAAO,OAAO,IAAI,CAAC,CAAC;YAC5B;QACJ;QAIAI,uBAAuBF,IAAI,MAAM;QAEjC,IAAIA,AAAoE,MAApEA,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAcG,YAAY,IAAI,EAAE,MAAM,EAC/D,MAAM,IAAIC,MACN;QAGRX,yBAAyBC;QAEzB,MAAMW,YAAYC,WAAiBN,KAAK;YACpC,iBAAiB;YACjB,0BAA0B;YAC1B,wBAAwB;YACxB,eAAeO,CAAAA,WAEP,CAAC,CAACA,SAAS,OAAO,CAACC,mBAAmB,OAAO,CAAC,IAC9C,CAAC,CAACD,SAAS,OAAO,CAACC,mBAAmB,MAAM,CAAC;YAGrD,GAAIV,OAAO,aAAa,IAAI,CAAC,CAAC;QAClC;QACA,OAAOO,UAAUX,OAAOK;IAC5B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { registry } from "../registry.js";
2
+ import { createSourceHandler } from "../sourceHandler.js";
3
+ import { createHandler } from "./index.js";
4
+ const handler = createSourceHandler({
5
+ name: "handler-aws-api-gateway",
6
+ canUse: (event)=>!!event.httpMethod,
7
+ handle: async ({ params, event, context })=>createHandler(params)(event, context)
8
+ });
9
+ registry.register(handler);
10
+
11
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway/register.js","sources":["../../src/gateway/register.ts"],"sourcesContent":["import type { APIGatewayEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { registry } from \"~/registry.js\";\nimport { createSourceHandler } from \"~/sourceHandler.js\";\nimport type { HandlerParams } from \"./index.js\";\nimport { createHandler } from \"./index.js\";\n\nconst handler = createSourceHandler<APIGatewayEvent, HandlerParams>({\n name: \"handler-aws-api-gateway\",\n canUse: event => {\n return !!event.httpMethod;\n },\n handle: async ({ params, event, context }) => {\n return createHandler(params)(event, context);\n }\n});\n\nregistry.register(handler);\n"],"names":["handler","createSourceHandler","event","params","context","createHandler","registry"],"mappings":";;;AAMA,MAAMA,UAAUC,oBAAoD;IAChE,MAAM;IACN,QAAQC,CAAAA,QACG,CAAC,CAACA,MAAM,UAAU;IAE7B,QAAQ,OAAO,EAAEC,MAAM,EAAED,KAAK,EAAEE,OAAO,EAAE,GAC9BC,cAAcF,QAAQD,OAAOE;AAE5C;AAEAE,SAAS,QAAQ,CAACN"}
package/index.d.ts CHANGED
@@ -1,6 +1,35 @@
1
- export { createHandler as createApiGatewayHandler, CreateHandlerParams as CreateApiGatewayHandlerParams, RoutePlugin, createRoute as createApiGatewayRoute } from "./gateway";
2
- export { createHandler as createS3Handler, CreateHandlerParams as CreateS3HandlerParams, S3EventHandler, S3EventHandlerCallable, S3EventHandlerCallableParams, createEventHandler as createS3EventHandler } from "./s3";
3
- export { createHandler as createDynamoDBHandler, CreateHandlerParams as CreateDynamoDBHandlerParams, DynamoDBEventHandler, DynamoDBEventHandlerCallable, DynamoDBEventHandlerCallableParams, createEventHandler as createDynamoDBEventHandler, HandlerCallable as DynamoDBHandlerCallable } from "./dynamodb";
4
- export { createHandler as createSQSHandler, CreateHandlerParams as CreateSQSHandlerParams, SQSEventHandler, SQSEventHandlerCallable, SQSEventHandlerCallableParams, createEventHandler as createSQSEventHandler, HandlerCallable as SQSHandlerCallable } from "./sqs";
5
- export { createHandler as createEventBridgeHandler, CreateHandlerParams as CreateEventBridgeHandlerParams, EventBridgeEventHandler, EventBridgeEventHandlerCallable, EventBridgeEventHandlerCallableParams, createEventHandler as createEventBridgeEventHandler, HandlerCallable as EventBridgeHandlerCallable } from "./eventBridge";
6
- export { createHandler as createRawHandler, CreateHandlerParams as CreateRawHandlerParams, HandlerCallable as RawHandlerCallable, createEventHandler as createRawEventHandler, RawEventHandlerCallableParams, RawEventHandlerCallable, RawEventHandler } from "./raw";
1
+ import "./gateway/register.js";
2
+ import "./s3/register.js";
3
+ import "./dynamodb/register.js";
4
+ import "./sqs/register.js";
5
+ import "./eventBridge/register.js";
6
+ import "./sns/register.js";
7
+ export * from "./utils/index.js";
8
+ /**
9
+ * API Gateway
10
+ */
11
+ export { createHandler as createApiGatewayHandler, type HandlerParams as CreateApiGatewayHandlerParams, type HandlerCallable as ApiGatewayHandlerCallable, RoutePlugin, createRoute as createApiGatewayRoute } from "./gateway/index.js";
12
+ /**
13
+ * S3
14
+ */
15
+ export { createHandler as createS3Handler, type HandlerParams as CreateS3HandlerParams, S3EventHandler, type S3EventHandlerCallable, type S3EventHandlerCallableParams, createEventHandler as createS3EventHandler } from "./s3/index.js";
16
+ /**
17
+ * DynamoDB Stream
18
+ */
19
+ export { createHandler as createDynamoDBHandler, type HandlerParams as CreateDynamoDBHandlerParams, DynamoDBEventHandler, type DynamoDBEventHandlerCallable, type DynamoDBEventHandlerCallableParams, createEventHandler as createDynamoDBEventHandler } from "./dynamodb/index.js";
20
+ /**
21
+ * SQS
22
+ */
23
+ export { createHandler as createSQSHandler, type HandlerParams as CreateSQSHandlerParams, SQSEventHandler, type SQSEventHandlerCallable, type SQSEventHandlerCallableParams, createEventHandler as createSQSEventHandler } from "./sqs/index.js";
24
+ /**
25
+ * SNS
26
+ */
27
+ export { createHandler as createSNSHandler, type HandlerParams as CreateSNSHandlerParams, SNSEventHandler, type SNSEventHandlerCallable, type SNSEventHandlerCallableParams, createEventHandler as createSNSEventHandler } from "./sns/index.js";
28
+ /**
29
+ * EventBridge
30
+ */
31
+ export { createHandler as createEventBridgeHandler, type HandlerParams as CreateEventBridgeHandlerParams, EventBridgeEventHandler, type EventBridgeEventHandlerCallable, type EventBridgeEventHandlerCallableParams, createEventHandler as createEventBridgeEventHandler } from "./eventBridge/index.js";
32
+ export { createHandler as createRawHandler, type CreateHandlerParams as CreateRawHandlerParams, type HandlerCallable as RawHandlerCallable, createEventHandler as createRawEventHandler, type RawEventHandlerCallableParams, type RawEventHandlerCallable, RawEventHandler } from "./raw/index.js";
33
+ export { ContextPlugin, createContextPlugin, type ContextPluginCallable } from "@webiny/handler";
34
+ export * from "./createHandler.js";
35
+ export * from "./sourceHandler.js";