@geekmidas/constructs 0.0.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/README.md +614 -0
- package/dist/AWSLambdaFunction-CpHFE2m6.d.mts +27 -0
- package/dist/AWSLambdaFunction-CwagvPG3.d.cts +27 -0
- package/dist/AWSLambdaFunction-DWIZYsCy.mjs +79 -0
- package/dist/AWSLambdaFunction-DWIZYsCy.mjs.map +1 -0
- package/dist/AWSLambdaFunction-qA5LqPsv.cjs +85 -0
- package/dist/AWSLambdaFunction-qA5LqPsv.cjs.map +1 -0
- package/dist/AWSLambdaSubscriberAdaptor-C1wQuucQ.d.mts +32 -0
- package/dist/AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs +138 -0
- package/dist/AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs.map +1 -0
- package/dist/AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs +132 -0
- package/dist/AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs.map +1 -0
- package/dist/AWSLambdaSubscriberAdaptor-QKVxR6qh.d.cts +32 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-BoBh7vvD.d.mts +61 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-Cx1oqcqh.mjs +124 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-Cx1oqcqh.mjs.map +1 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-DtzgQ9Vb.d.cts +61 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-i74DEUbc.cjs +130 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-i74DEUbc.cjs.map +1 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-CLmBDYsl.mjs +42 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-CLmBDYsl.mjs.map +1 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-EhMd1YqV.d.mts +21 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-GkMAUPL5.cjs +47 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-GkMAUPL5.cjs.map +1 -0
- package/dist/AmazonApiGatewayV1EndpointAdaptor-Gw-j61qM.d.cts +21 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-3RqegmJC.mjs +41 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-3RqegmJC.mjs.map +1 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-LUlpwmUW.d.cts +21 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-YlFoFSS9.cjs +46 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-YlFoFSS9.cjs.map +1 -0
- package/dist/AmazonApiGatewayV2EndpointAdaptor-zfd1gqXA.d.mts +21 -0
- package/dist/BaseFunctionBuilder-5QCHkchp.d.cts +31 -0
- package/dist/BaseFunctionBuilder-BFPVGnKi.d.mts +31 -0
- package/dist/BaseFunctionBuilder-BPE9JBbT.mjs +56 -0
- package/dist/BaseFunctionBuilder-BPE9JBbT.mjs.map +1 -0
- package/dist/BaseFunctionBuilder-DtO4Nwxm.cjs +62 -0
- package/dist/BaseFunctionBuilder-DtO4Nwxm.cjs.map +1 -0
- package/dist/Construct-BSEs6uwW.cjs +75 -0
- package/dist/Construct-BSEs6uwW.cjs.map +1 -0
- package/dist/Construct-BbKCIPQm.mjs +63 -0
- package/dist/Construct-BbKCIPQm.mjs.map +1 -0
- package/dist/Construct-Bm-PSO2V.d.cts +42 -0
- package/dist/Construct-DIguIyw4.d.mts +42 -0
- package/dist/Construct.cjs +4 -0
- package/dist/Construct.d.cts +2 -0
- package/dist/Construct.d.mts +2 -0
- package/dist/Construct.mjs +3 -0
- package/dist/Cron-Bgs6EQOb.mjs +20 -0
- package/dist/Cron-Bgs6EQOb.mjs.map +1 -0
- package/dist/Cron-DQiCj3ef.cjs +25 -0
- package/dist/Cron-DQiCj3ef.cjs.map +1 -0
- package/dist/Cron-FpAw03k6.d.mts +25 -0
- package/dist/Cron-ztnK6zgU.d.cts +25 -0
- package/dist/CronBuilder-B2clNQSP.d.mts +24 -0
- package/dist/CronBuilder-Cje9K8lZ.d.cts +24 -0
- package/dist/CronBuilder-DIBqJkh_.cjs +60 -0
- package/dist/CronBuilder-DIBqJkh_.cjs.map +1 -0
- package/dist/CronBuilder-DecAvvcn.mjs +54 -0
- package/dist/CronBuilder-DecAvvcn.mjs.map +1 -0
- package/dist/Endpoint-BaHC9y4Z.cjs +291 -0
- package/dist/Endpoint-BaHC9y4Z.cjs.map +1 -0
- package/dist/Endpoint-C7z9YJHK.d.cts +405 -0
- package/dist/Endpoint-DCn53Vd8.d.mts +405 -0
- package/dist/Endpoint-ierdM62O.mjs +279 -0
- package/dist/Endpoint-ierdM62O.mjs.map +1 -0
- package/dist/EndpointBuilder-BHFSpbPR.cjs +107 -0
- package/dist/EndpointBuilder-BHFSpbPR.cjs.map +1 -0
- package/dist/EndpointBuilder-BLUsoK3l.mjs +101 -0
- package/dist/EndpointBuilder-BLUsoK3l.mjs.map +1 -0
- package/dist/EndpointBuilder-Bfnb2oJr.d.mts +49 -0
- package/dist/EndpointBuilder-CP9RGwZH.d.cts +49 -0
- package/dist/EndpointFactory-BYdDVCNj.mjs +127 -0
- package/dist/EndpointFactory-BYdDVCNj.mjs.map +1 -0
- package/dist/EndpointFactory-CNtMXgIh.d.mts +52 -0
- package/dist/EndpointFactory-CXX4E6Gx.cjs +139 -0
- package/dist/EndpointFactory-CXX4E6Gx.cjs.map +1 -0
- package/dist/EndpointFactory-D2zgWbXZ.d.cts +52 -0
- package/dist/Function-BP58p9Mp.d.cts +59 -0
- package/dist/Function-BsBxc2wA.d.mts +59 -0
- package/dist/Function-C5mW-38v.mjs +72 -0
- package/dist/Function-C5mW-38v.mjs.map +1 -0
- package/dist/Function-CbO2NZx-.cjs +84 -0
- package/dist/Function-CbO2NZx-.cjs.map +1 -0
- package/dist/FunctionBuilder-BS1KgxA_.d.cts +24 -0
- package/dist/FunctionBuilder-C-PfPN3r.d.mts +24 -0
- package/dist/FunctionBuilder-CosgPmMl.mjs +53 -0
- package/dist/FunctionBuilder-CosgPmMl.mjs.map +1 -0
- package/dist/FunctionBuilder-DuOeWCAl.cjs +59 -0
- package/dist/FunctionBuilder-DuOeWCAl.cjs.map +1 -0
- package/dist/FunctionExecutionWrapper-Bx-Dl-2a.d.cts +24 -0
- package/dist/FunctionExecutionWrapper-CElXEjPe.cjs +42 -0
- package/dist/FunctionExecutionWrapper-CElXEjPe.cjs.map +1 -0
- package/dist/FunctionExecutionWrapper-DvglBBjE.d.mts +24 -0
- package/dist/FunctionExecutionWrapper-XGrSAAPD.mjs +36 -0
- package/dist/FunctionExecutionWrapper-XGrSAAPD.mjs.map +1 -0
- package/dist/HonoEndpointAdaptor-B0IO1zj2.d.mts +41 -0
- package/dist/HonoEndpointAdaptor-B4snrp7v.cjs +154 -0
- package/dist/HonoEndpointAdaptor-B4snrp7v.cjs.map +1 -0
- package/dist/HonoEndpointAdaptor-B6lW9Q1k.d.cts +41 -0
- package/dist/HonoEndpointAdaptor-D-M4-6Tf.mjs +148 -0
- package/dist/HonoEndpointAdaptor-D-M4-6Tf.mjs.map +1 -0
- package/dist/Subscriber-BoFm12i_.d.cts +33 -0
- package/dist/Subscriber-BwuCaC9G.mjs +28 -0
- package/dist/Subscriber-BwuCaC9G.mjs.map +1 -0
- package/dist/Subscriber-THGsj7Iy.d.mts +33 -0
- package/dist/Subscriber-iMRFG7ba.cjs +34 -0
- package/dist/Subscriber-iMRFG7ba.cjs.map +1 -0
- package/dist/SubscriberBuilder-CiPxgnKT.d.mts +26 -0
- package/dist/SubscriberBuilder-Dhz0C_t-.mjs +54 -0
- package/dist/SubscriberBuilder-Dhz0C_t-.mjs.map +1 -0
- package/dist/SubscriberBuilder-DuIgxuzc.d.cts +26 -0
- package/dist/SubscriberBuilder-wthr-FL9.cjs +60 -0
- package/dist/SubscriberBuilder-wthr-FL9.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +19 -0
- package/dist/adaptors/aws.d.cts +15 -0
- package/dist/adaptors/aws.d.mts +15 -0
- package/dist/adaptors/aws.mjs +16 -0
- package/dist/adaptors/hono.cjs +12 -0
- package/dist/adaptors/hono.d.cts +9 -0
- package/dist/adaptors/hono.d.mts +9 -0
- package/dist/adaptors/hono.mjs +12 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/crons/Cron.cjs +8 -0
- package/dist/crons/Cron.d.cts +7 -0
- package/dist/crons/Cron.d.mts +7 -0
- package/dist/crons/Cron.mjs +8 -0
- package/dist/crons/CronBuilder.cjs +9 -0
- package/dist/crons/CronBuilder.d.cts +8 -0
- package/dist/crons/CronBuilder.d.mts +8 -0
- package/dist/crons/CronBuilder.mjs +9 -0
- package/dist/crons/index.cjs +16 -0
- package/dist/crons/index.cjs.map +1 -0
- package/dist/crons/index.d.cts +16 -0
- package/dist/crons/index.d.mts +16 -0
- package/dist/crons/index.mjs +14 -0
- package/dist/crons/index.mjs.map +1 -0
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +10 -0
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +9 -0
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +9 -0
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +10 -0
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +12 -0
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +10 -0
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +10 -0
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.mjs +12 -0
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.cjs +12 -0
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +10 -0
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +10 -0
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +12 -0
- package/dist/endpoints/Endpoint.cjs +9 -0
- package/dist/endpoints/Endpoint.d.cts +8 -0
- package/dist/endpoints/Endpoint.d.mts +8 -0
- package/dist/endpoints/Endpoint.mjs +8 -0
- package/dist/endpoints/EndpointBuilder.cjs +9 -0
- package/dist/endpoints/EndpointBuilder.d.cts +9 -0
- package/dist/endpoints/EndpointBuilder.d.mts +9 -0
- package/dist/endpoints/EndpointBuilder.mjs +9 -0
- package/dist/endpoints/EndpointFactory.cjs +11 -0
- package/dist/endpoints/EndpointFactory.d.cts +10 -0
- package/dist/endpoints/EndpointFactory.d.mts +10 -0
- package/dist/endpoints/EndpointFactory.mjs +10 -0
- package/dist/endpoints/HonoEndpointAdaptor.cjs +12 -0
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +9 -0
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -0
- package/dist/endpoints/HonoEndpointAdaptor.mjs +12 -0
- package/dist/endpoints/TestEndpointAdaptor.cjs +54 -0
- package/dist/endpoints/TestEndpointAdaptor.cjs.map +1 -0
- package/dist/endpoints/TestEndpointAdaptor.d.cts +29 -0
- package/dist/endpoints/TestEndpointAdaptor.d.mts +29 -0
- package/dist/endpoints/TestEndpointAdaptor.mjs +53 -0
- package/dist/endpoints/TestEndpointAdaptor.mjs.map +1 -0
- package/dist/endpoints/helpers.cjs +10 -0
- package/dist/endpoints/helpers.d.cts +58 -0
- package/dist/endpoints/helpers.d.mts +58 -0
- package/dist/endpoints/helpers.mjs +9 -0
- package/dist/endpoints/index.cjs +16 -0
- package/dist/endpoints/index.cjs.map +1 -0
- package/dist/endpoints/index.d.cts +16 -0
- package/dist/endpoints/index.d.mts +16 -0
- package/dist/endpoints/index.mjs +15 -0
- package/dist/endpoints/index.mjs.map +1 -0
- package/dist/endpoints/parseHonoQuery.cjs +3 -0
- package/dist/endpoints/parseHonoQuery.d.cts +12 -0
- package/dist/endpoints/parseHonoQuery.d.mts +12 -0
- package/dist/endpoints/parseHonoQuery.mjs +3 -0
- package/dist/endpoints/parseQueryParams.cjs +3 -0
- package/dist/endpoints/parseQueryParams.d.cts +13 -0
- package/dist/endpoints/parseQueryParams.d.mts +13 -0
- package/dist/endpoints/parseQueryParams.mjs +3 -0
- package/dist/functions/AWSLambdaFunction.cjs +9 -0
- package/dist/functions/AWSLambdaFunction.d.cts +5 -0
- package/dist/functions/AWSLambdaFunction.d.mts +5 -0
- package/dist/functions/AWSLambdaFunction.mjs +9 -0
- package/dist/functions/BaseFunctionBuilder.cjs +4 -0
- package/dist/functions/BaseFunctionBuilder.d.cts +3 -0
- package/dist/functions/BaseFunctionBuilder.d.mts +3 -0
- package/dist/functions/BaseFunctionBuilder.mjs +4 -0
- package/dist/functions/Function.cjs +5 -0
- package/dist/functions/Function.d.cts +3 -0
- package/dist/functions/Function.d.mts +3 -0
- package/dist/functions/Function.mjs +4 -0
- package/dist/functions/FunctionBuilder.cjs +6 -0
- package/dist/functions/FunctionBuilder.d.cts +5 -0
- package/dist/functions/FunctionBuilder.d.mts +5 -0
- package/dist/functions/FunctionBuilder.mjs +6 -0
- package/dist/functions/FunctionExecutionWrapper.cjs +8 -0
- package/dist/functions/FunctionExecutionWrapper.d.cts +4 -0
- package/dist/functions/FunctionExecutionWrapper.d.mts +4 -0
- package/dist/functions/FunctionExecutionWrapper.mjs +8 -0
- package/dist/functions/TestFunctionAdaptor.cjs +38 -0
- package/dist/functions/TestFunctionAdaptor.cjs.map +1 -0
- package/dist/functions/TestFunctionAdaptor.d.cts +26 -0
- package/dist/functions/TestFunctionAdaptor.d.mts +26 -0
- package/dist/functions/TestFunctionAdaptor.mjs +37 -0
- package/dist/functions/TestFunctionAdaptor.mjs.map +1 -0
- package/dist/functions/index.cjs +10 -0
- package/dist/functions/index.d.cts +6 -0
- package/dist/functions/index.d.mts +6 -0
- package/dist/functions/index.mjs +7 -0
- package/dist/functions-DVDb5wEA.cjs +13 -0
- package/dist/functions-DVDb5wEA.cjs.map +1 -0
- package/dist/functions-mM-jcphA.mjs +8 -0
- package/dist/functions-mM-jcphA.mjs.map +1 -0
- package/dist/helpers-BeGM4pP_.cjs +95 -0
- package/dist/helpers-BeGM4pP_.cjs.map +1 -0
- package/dist/helpers-DbpO95aE.mjs +83 -0
- package/dist/helpers-DbpO95aE.mjs.map +1 -0
- package/dist/index-CuGR4L7O.d.mts +9 -0
- package/dist/index-Fg3N3EKD.d.cts +9 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +3 -0
- package/dist/parseHonoQuery-DopC24vB.cjs +37 -0
- package/dist/parseHonoQuery-DopC24vB.cjs.map +1 -0
- package/dist/parseHonoQuery-znDKBhdE.mjs +31 -0
- package/dist/parseHonoQuery-znDKBhdE.mjs.map +1 -0
- package/dist/parseQueryParams-BJaRh3OB.mjs +32 -0
- package/dist/parseQueryParams-BJaRh3OB.mjs.map +1 -0
- package/dist/parseQueryParams-BzPop4I1.cjs +38 -0
- package/dist/parseQueryParams-BzPop4I1.cjs.map +1 -0
- package/dist/publisher-Bw4770Hi.mjs +41 -0
- package/dist/publisher-Bw4770Hi.mjs.map +1 -0
- package/dist/publisher-lFQleddL.cjs +53 -0
- package/dist/publisher-lFQleddL.cjs.map +1 -0
- package/dist/publisher.cjs +4 -0
- package/dist/publisher.d.cts +13 -0
- package/dist/publisher.d.mts +13 -0
- package/dist/publisher.mjs +3 -0
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.cjs +3 -0
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.cts +4 -0
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +4 -0
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.mjs +3 -0
- package/dist/subscribers/Subscriber.cjs +4 -0
- package/dist/subscribers/Subscriber.d.cts +3 -0
- package/dist/subscribers/Subscriber.d.mts +3 -0
- package/dist/subscribers/Subscriber.mjs +4 -0
- package/dist/subscribers/SubscriberBuilder.cjs +5 -0
- package/dist/subscribers/SubscriberBuilder.d.cts +4 -0
- package/dist/subscribers/SubscriberBuilder.d.mts +4 -0
- package/dist/subscribers/SubscriberBuilder.mjs +5 -0
- package/dist/subscribers/index.cjs +12 -0
- package/dist/subscribers/index.cjs.map +1 -0
- package/dist/subscribers/index.d.cts +10 -0
- package/dist/subscribers/index.d.mts +10 -0
- package/dist/subscribers/index.mjs +10 -0
- package/dist/subscribers/index.mjs.map +1 -0
- package/dist/types-Bp9ysFXd.d.cts +7 -0
- package/dist/types-DBKNYvsW.d.mts +7 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +0 -0
- package/package.json +91 -0
- package/src/Construct.ts +98 -0
- package/src/__tests__/Construct.environment.spec.ts +360 -0
- package/src/__tests__/publisher.setting.spec.ts +511 -0
- package/src/__tests__/publisher.spec.ts +454 -0
- package/src/adaptors/aws.ts +4 -0
- package/src/adaptors/hono.ts +1 -0
- package/src/crons/Cron.ts +137 -0
- package/src/crons/CronBuilder.ts +192 -0
- package/src/crons/__tests__/Cron.spec.ts +464 -0
- package/src/crons/index.ts +11 -0
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +315 -0
- package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +101 -0
- package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +95 -0
- package/src/endpoints/Endpoint.ts +771 -0
- package/src/endpoints/EndpointBuilder.ts +308 -0
- package/src/endpoints/EndpointFactory.ts +329 -0
- package/src/endpoints/HonoEndpointAdaptor.ts +365 -0
- package/src/endpoints/TestEndpointAdaptor.ts +130 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +553 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +927 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +721 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +296 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +441 -0
- package/src/endpoints/__tests__/Endpoint.spec.ts +800 -0
- package/src/endpoints/__tests__/EndpointBuilder.spec.ts +488 -0
- package/src/endpoints/__tests__/EndpointFactory.spec.ts +479 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +569 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +313 -0
- package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +1078 -0
- package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +236 -0
- package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +54 -0
- package/src/endpoints/__tests__/endpoint-types.test.ts +88 -0
- package/src/endpoints/helpers.ts +99 -0
- package/src/endpoints/index.ts +5 -0
- package/src/endpoints/parseHonoQuery.ts +51 -0
- package/src/endpoints/parseQueryParams.ts +51 -0
- package/src/functions/AWSLambdaFunction.ts +222 -0
- package/src/functions/BaseFunctionBuilder.ts +110 -0
- package/src/functions/Function.ts +160 -0
- package/src/functions/FunctionBuilder.ts +182 -0
- package/src/functions/FunctionExecutionWrapper.ts +86 -0
- package/src/functions/TestFunctionAdaptor.ts +125 -0
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +376 -0
- package/src/functions/__tests__/Function.spec.ts +402 -0
- package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +398 -0
- package/src/functions/index.ts +10 -0
- package/src/index.ts +14 -0
- package/src/publisher.ts +83 -0
- package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +269 -0
- package/src/subscribers/Subscriber.ts +112 -0
- package/src/subscribers/SubscriberBuilder.ts +150 -0
- package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +623 -0
- package/src/subscribers/__tests__/Subscriber.spec.ts +432 -0
- package/src/subscribers/index.ts +5 -0
- package/src/types.ts +13 -0
- package/tsdown.config.ts +3 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import { EnvironmentParser } from '@geekmidas/envkit';
|
|
2
|
+
import type {
|
|
3
|
+
EventPublisher,
|
|
4
|
+
MappedEvent,
|
|
5
|
+
PublishableMessage,
|
|
6
|
+
} from '@geekmidas/events';
|
|
7
|
+
import type { Logger } from '@geekmidas/logger';
|
|
8
|
+
import type { Service } from '@geekmidas/services';
|
|
9
|
+
import {
|
|
10
|
+
createMockContext,
|
|
11
|
+
createMockV1Event as createMockEvent,
|
|
12
|
+
} from '@geekmidas/testkit/aws';
|
|
13
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
|
|
16
|
+
import { createMockLogger } from '@geekmidas/testkit/logger';
|
|
17
|
+
import { AmazonApiGatewayV1Endpoint } from '../AmazonApiGatewayV1EndpointAdaptor';
|
|
18
|
+
import { Endpoint } from '../Endpoint';
|
|
19
|
+
|
|
20
|
+
// Test event types
|
|
21
|
+
type TestEvent =
|
|
22
|
+
| PublishableMessage<'user.created', { userId: string; email: string }>
|
|
23
|
+
| PublishableMessage<'user.updated', { userId: string; changes: string[] }>
|
|
24
|
+
| PublishableMessage<'notification.sent', { userId: string; type: string }>;
|
|
25
|
+
|
|
26
|
+
// Mock functions are now imported from shared utilities
|
|
27
|
+
|
|
28
|
+
describe('AmazonApiGatewayV1Endpoint Events', () => {
|
|
29
|
+
let mockLogger: Logger;
|
|
30
|
+
let envParser: EnvironmentParser<{}>;
|
|
31
|
+
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
vi.clearAllMocks();
|
|
34
|
+
mockLogger = createMockLogger();
|
|
35
|
+
envParser = new EnvironmentParser({});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should publish events after successful endpoint execution', async () => {
|
|
39
|
+
const mockPublisher: EventPublisher<TestEvent> = {
|
|
40
|
+
publish: vi.fn().mockResolvedValue(undefined),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const mockPublisherService: Service<
|
|
44
|
+
'publisher',
|
|
45
|
+
EventPublisher<TestEvent>
|
|
46
|
+
> = {
|
|
47
|
+
serviceName: 'publisher' as const,
|
|
48
|
+
register: vi.fn().mockResolvedValue(mockPublisher),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const outputSchema = z.object({ id: z.string(), email: z.string() });
|
|
52
|
+
|
|
53
|
+
const events: MappedEvent<
|
|
54
|
+
EventPublisher<TestEvent>,
|
|
55
|
+
typeof outputSchema
|
|
56
|
+
>[] = [
|
|
57
|
+
{
|
|
58
|
+
type: 'user.created',
|
|
59
|
+
payload: (response) => ({ userId: response.id, email: response.email }),
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const endpoint = new Endpoint({
|
|
64
|
+
route: '/users',
|
|
65
|
+
method: 'POST',
|
|
66
|
+
fn: async () => ({ id: '123', email: 'test@example.com' }),
|
|
67
|
+
input: undefined,
|
|
68
|
+
output: outputSchema,
|
|
69
|
+
services: [],
|
|
70
|
+
logger: mockLogger,
|
|
71
|
+
timeout: undefined,
|
|
72
|
+
status: 200,
|
|
73
|
+
getSession: undefined,
|
|
74
|
+
authorize: undefined,
|
|
75
|
+
description: undefined,
|
|
76
|
+
events,
|
|
77
|
+
publisherService: mockPublisherService,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
81
|
+
const handler = adapter.handler;
|
|
82
|
+
|
|
83
|
+
const event = createMockEvent({
|
|
84
|
+
httpMethod: 'POST',
|
|
85
|
+
body: JSON.stringify({}),
|
|
86
|
+
});
|
|
87
|
+
const context = createMockContext();
|
|
88
|
+
const response = await handler(event, context);
|
|
89
|
+
|
|
90
|
+
expect(response.statusCode).toBe(200);
|
|
91
|
+
expect(response.body).toBe(
|
|
92
|
+
JSON.stringify({ id: '123', email: 'test@example.com' }),
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
expect(mockPublisher.publish).toHaveBeenCalledWith([
|
|
96
|
+
{
|
|
97
|
+
type: 'user.created',
|
|
98
|
+
payload: { userId: '123', email: 'test@example.com' },
|
|
99
|
+
},
|
|
100
|
+
]);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should publish multiple events after successful endpoint execution', async () => {
|
|
104
|
+
const mockPublisher: EventPublisher<TestEvent> = {
|
|
105
|
+
publish: vi.fn().mockResolvedValue(undefined),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const mockPublisherService: Service<string, EventPublisher<TestEvent>> = {
|
|
109
|
+
serviceName: Math.random().toString(),
|
|
110
|
+
register: vi.fn().mockResolvedValue(mockPublisher),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const outputSchema = z.object({ id: z.string(), email: z.string() });
|
|
114
|
+
|
|
115
|
+
const events: MappedEvent<
|
|
116
|
+
EventPublisher<TestEvent>,
|
|
117
|
+
typeof outputSchema
|
|
118
|
+
>[] = [
|
|
119
|
+
{
|
|
120
|
+
type: 'user.created',
|
|
121
|
+
payload: (response) => ({ userId: response.id, email: response.email }),
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: 'notification.sent',
|
|
125
|
+
payload: (response) => ({ userId: response.id, type: 'welcome' }),
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
const endpoint = new Endpoint({
|
|
130
|
+
route: '/users',
|
|
131
|
+
method: 'POST',
|
|
132
|
+
fn: async () => ({ id: '456', email: 'user@example.com' }),
|
|
133
|
+
input: undefined,
|
|
134
|
+
output: outputSchema,
|
|
135
|
+
services: [],
|
|
136
|
+
logger: mockLogger,
|
|
137
|
+
timeout: undefined,
|
|
138
|
+
status: 201,
|
|
139
|
+
getSession: undefined,
|
|
140
|
+
authorize: undefined,
|
|
141
|
+
description: undefined,
|
|
142
|
+
events,
|
|
143
|
+
publisherService: mockPublisherService,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
147
|
+
const handler = adapter.handler;
|
|
148
|
+
|
|
149
|
+
const event = createMockEvent({
|
|
150
|
+
httpMethod: 'POST',
|
|
151
|
+
body: JSON.stringify({}),
|
|
152
|
+
});
|
|
153
|
+
const context = createMockContext();
|
|
154
|
+
const response = await handler(event, context);
|
|
155
|
+
|
|
156
|
+
expect(response.statusCode).toBe(201);
|
|
157
|
+
expect(response.body).toBe(
|
|
158
|
+
JSON.stringify({ id: '456', email: 'user@example.com' }),
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
expect(mockPublisher.publish).toHaveBeenCalledWith([
|
|
162
|
+
{
|
|
163
|
+
type: 'user.created',
|
|
164
|
+
payload: { userId: '456', email: 'user@example.com' },
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
type: 'notification.sent',
|
|
168
|
+
payload: { userId: '456', type: 'welcome' },
|
|
169
|
+
},
|
|
170
|
+
]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('should respect when conditions for events', async () => {
|
|
174
|
+
const mockPublisher: EventPublisher<TestEvent> = {
|
|
175
|
+
publish: vi.fn().mockResolvedValue(undefined),
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const mockPublisherService: Service<string, EventPublisher<TestEvent>> = {
|
|
179
|
+
serviceName: Math.random().toString(),
|
|
180
|
+
register: vi.fn().mockResolvedValue(mockPublisher),
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const outputSchema = z.object({
|
|
184
|
+
id: z.string(),
|
|
185
|
+
email: z.string(),
|
|
186
|
+
isNew: z.boolean(),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const events: MappedEvent<
|
|
190
|
+
EventPublisher<TestEvent>,
|
|
191
|
+
typeof outputSchema
|
|
192
|
+
>[] = [
|
|
193
|
+
{
|
|
194
|
+
type: 'user.created',
|
|
195
|
+
payload: (response) => ({ userId: response.id, email: response.email }),
|
|
196
|
+
when: (response) => response.isNew === true,
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
type: 'user.updated',
|
|
200
|
+
payload: (response) => ({ userId: response.id, changes: ['email'] }),
|
|
201
|
+
when: (response) => response.isNew === false,
|
|
202
|
+
},
|
|
203
|
+
];
|
|
204
|
+
|
|
205
|
+
const endpoint = new Endpoint({
|
|
206
|
+
route: '/users/:id',
|
|
207
|
+
method: 'PUT',
|
|
208
|
+
fn: async () => ({
|
|
209
|
+
id: '789',
|
|
210
|
+
email: 'updated@example.com',
|
|
211
|
+
isNew: false,
|
|
212
|
+
}),
|
|
213
|
+
input: undefined,
|
|
214
|
+
output: outputSchema,
|
|
215
|
+
services: [],
|
|
216
|
+
logger: mockLogger,
|
|
217
|
+
timeout: undefined,
|
|
218
|
+
status: 200,
|
|
219
|
+
getSession: undefined,
|
|
220
|
+
authorize: undefined,
|
|
221
|
+
description: undefined,
|
|
222
|
+
events,
|
|
223
|
+
publisherService: mockPublisherService,
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
227
|
+
const handler = adapter.handler;
|
|
228
|
+
|
|
229
|
+
const event = createMockEvent({
|
|
230
|
+
httpMethod: 'PUT',
|
|
231
|
+
pathParameters: { id: '789' },
|
|
232
|
+
body: JSON.stringify({}),
|
|
233
|
+
});
|
|
234
|
+
const context = createMockContext();
|
|
235
|
+
const response = await handler(event, context);
|
|
236
|
+
|
|
237
|
+
expect(response.statusCode).toBe(200);
|
|
238
|
+
expect(response.body).toBe(
|
|
239
|
+
JSON.stringify({
|
|
240
|
+
id: '789',
|
|
241
|
+
email: 'updated@example.com',
|
|
242
|
+
isNew: false,
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
// Only user.updated event should be published due to when condition
|
|
247
|
+
expect(mockPublisher.publish).toHaveBeenCalledWith([
|
|
248
|
+
{
|
|
249
|
+
type: 'user.updated',
|
|
250
|
+
payload: { userId: '789', changes: ['email'] },
|
|
251
|
+
},
|
|
252
|
+
]);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('should not publish events when no publisher is configured', async () => {
|
|
256
|
+
const outputSchema = z.object({ id: z.string(), email: z.string() });
|
|
257
|
+
|
|
258
|
+
const events: MappedEvent<
|
|
259
|
+
EventPublisher<TestEvent>,
|
|
260
|
+
typeof outputSchema
|
|
261
|
+
>[] = [
|
|
262
|
+
{
|
|
263
|
+
type: 'user.created',
|
|
264
|
+
payload: (response) => ({ userId: response.id, email: response.email }),
|
|
265
|
+
},
|
|
266
|
+
];
|
|
267
|
+
|
|
268
|
+
const endpoint = new Endpoint({
|
|
269
|
+
route: '/users',
|
|
270
|
+
method: 'POST',
|
|
271
|
+
fn: async () => ({ id: '999', email: 'test@example.com' }),
|
|
272
|
+
input: undefined,
|
|
273
|
+
output: outputSchema,
|
|
274
|
+
services: [],
|
|
275
|
+
logger: mockLogger,
|
|
276
|
+
timeout: undefined,
|
|
277
|
+
status: 200,
|
|
278
|
+
getSession: undefined,
|
|
279
|
+
authorize: undefined,
|
|
280
|
+
description: undefined,
|
|
281
|
+
events,
|
|
282
|
+
publisherService: undefined, // No publisher service
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
286
|
+
const handler = adapter.handler;
|
|
287
|
+
|
|
288
|
+
const event = createMockEvent({
|
|
289
|
+
httpMethod: 'POST',
|
|
290
|
+
body: JSON.stringify({}),
|
|
291
|
+
});
|
|
292
|
+
const context = createMockContext();
|
|
293
|
+
const response = await handler(event, context);
|
|
294
|
+
|
|
295
|
+
expect(response.statusCode).toBe(200);
|
|
296
|
+
expect(response.body).toBe(
|
|
297
|
+
JSON.stringify({ id: '999', email: 'test@example.com' }),
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
// No publisher calls should be made
|
|
301
|
+
expect(mockLogger.warn).toHaveBeenCalledWith(
|
|
302
|
+
'No publisher service available',
|
|
303
|
+
);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('should not publish events when no events are configured', async () => {
|
|
307
|
+
const mockPublisher: EventPublisher<TestEvent> = {
|
|
308
|
+
publish: vi.fn().mockResolvedValue(undefined),
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const mockPublisherService: Service<string, EventPublisher<TestEvent>> = {
|
|
312
|
+
serviceName: Math.random().toString(),
|
|
313
|
+
register: vi.fn().mockResolvedValue(mockPublisher),
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const outputSchema = z.object({ id: z.string(), email: z.string() });
|
|
317
|
+
|
|
318
|
+
const endpoint = new Endpoint({
|
|
319
|
+
route: '/users',
|
|
320
|
+
method: 'POST',
|
|
321
|
+
fn: async () => ({ id: '111', email: 'test@example.com' }),
|
|
322
|
+
input: undefined,
|
|
323
|
+
output: outputSchema,
|
|
324
|
+
services: [],
|
|
325
|
+
logger: mockLogger,
|
|
326
|
+
timeout: undefined,
|
|
327
|
+
status: 200,
|
|
328
|
+
getSession: undefined,
|
|
329
|
+
authorize: undefined,
|
|
330
|
+
description: undefined,
|
|
331
|
+
events: undefined, // No events
|
|
332
|
+
publisherService: mockPublisherService,
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
336
|
+
const handler = adapter.handler;
|
|
337
|
+
|
|
338
|
+
const event = createMockEvent({
|
|
339
|
+
httpMethod: 'POST',
|
|
340
|
+
body: JSON.stringify({}),
|
|
341
|
+
});
|
|
342
|
+
const context = createMockContext();
|
|
343
|
+
const response = await handler(event, context);
|
|
344
|
+
|
|
345
|
+
expect(response.statusCode).toBe(200);
|
|
346
|
+
expect(response.body).toBe(
|
|
347
|
+
JSON.stringify({ id: '111', email: 'test@example.com' }),
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
// No events should be published
|
|
351
|
+
expect(mockPublisher.publish).not.toHaveBeenCalled();
|
|
352
|
+
expect(mockLogger.debug).toHaveBeenCalledWith('No events to publish');
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it('should continue processing even when event publishing fails', async () => {
|
|
356
|
+
const publishError = new Error('Event bus connection failed');
|
|
357
|
+
const mockPublisher: EventPublisher<TestEvent> = {
|
|
358
|
+
publish: vi.fn().mockRejectedValue(publishError),
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
const mockPublisherService: Service<string, EventPublisher<TestEvent>> = {
|
|
362
|
+
serviceName: Math.random().toString(),
|
|
363
|
+
register: vi.fn().mockResolvedValue(mockPublisher),
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
const outputSchema = z.object({ id: z.string(), email: z.string() });
|
|
367
|
+
|
|
368
|
+
const events: MappedEvent<
|
|
369
|
+
EventPublisher<TestEvent>,
|
|
370
|
+
typeof outputSchema
|
|
371
|
+
>[] = [
|
|
372
|
+
{
|
|
373
|
+
type: 'user.created',
|
|
374
|
+
payload: (response) => ({ userId: response.id, email: response.email }),
|
|
375
|
+
},
|
|
376
|
+
];
|
|
377
|
+
|
|
378
|
+
const endpoint = new Endpoint({
|
|
379
|
+
route: '/users',
|
|
380
|
+
method: 'POST',
|
|
381
|
+
fn: async () => ({ id: '888', email: 'error@example.com' }),
|
|
382
|
+
input: undefined,
|
|
383
|
+
output: outputSchema,
|
|
384
|
+
services: [],
|
|
385
|
+
logger: mockLogger,
|
|
386
|
+
timeout: undefined,
|
|
387
|
+
status: 200,
|
|
388
|
+
getSession: undefined,
|
|
389
|
+
authorize: undefined,
|
|
390
|
+
description: undefined,
|
|
391
|
+
events,
|
|
392
|
+
publisherService: mockPublisherService,
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
396
|
+
const handler = adapter.handler;
|
|
397
|
+
|
|
398
|
+
const event = createMockEvent({
|
|
399
|
+
httpMethod: 'POST',
|
|
400
|
+
body: JSON.stringify({}),
|
|
401
|
+
});
|
|
402
|
+
const context = createMockContext();
|
|
403
|
+
const response = await handler(event, context);
|
|
404
|
+
|
|
405
|
+
// The endpoint should still succeed despite event publishing failure
|
|
406
|
+
expect(response.statusCode).toBe(200);
|
|
407
|
+
expect(response.body).toBe(
|
|
408
|
+
JSON.stringify({ id: '888', email: 'error@example.com' }),
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
expect(mockPublisher.publish).toHaveBeenCalled();
|
|
412
|
+
expect(mockLogger.error).toHaveBeenCalledWith(
|
|
413
|
+
publishError,
|
|
414
|
+
'Failed to publish events',
|
|
415
|
+
);
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
it('should publish events with input data context', async () => {
|
|
419
|
+
const mockPublisher: EventPublisher<TestEvent> = {
|
|
420
|
+
publish: vi.fn().mockResolvedValue(undefined),
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const mockPublisherService: Service<string, EventPublisher<TestEvent>> = {
|
|
424
|
+
serviceName: Math.random().toString(),
|
|
425
|
+
register: vi.fn().mockResolvedValue(mockPublisher),
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
const bodySchema = z.object({ name: z.string(), email: z.string() });
|
|
429
|
+
const outputSchema = z.object({
|
|
430
|
+
id: z.string(),
|
|
431
|
+
name: z.string(),
|
|
432
|
+
email: z.string(),
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
const events: MappedEvent<
|
|
436
|
+
EventPublisher<TestEvent>,
|
|
437
|
+
typeof outputSchema
|
|
438
|
+
>[] = [
|
|
439
|
+
{
|
|
440
|
+
type: 'user.created',
|
|
441
|
+
payload: (response) => ({ userId: response.id, email: response.email }),
|
|
442
|
+
},
|
|
443
|
+
];
|
|
444
|
+
|
|
445
|
+
const endpoint = new Endpoint({
|
|
446
|
+
route: '/users',
|
|
447
|
+
method: 'POST',
|
|
448
|
+
fn: async ({ body }) => ({
|
|
449
|
+
id: '777',
|
|
450
|
+
name: body.name,
|
|
451
|
+
email: body.email,
|
|
452
|
+
}),
|
|
453
|
+
input: { body: bodySchema },
|
|
454
|
+
output: outputSchema,
|
|
455
|
+
services: [],
|
|
456
|
+
logger: mockLogger,
|
|
457
|
+
timeout: undefined,
|
|
458
|
+
status: 201,
|
|
459
|
+
getSession: undefined,
|
|
460
|
+
authorize: undefined,
|
|
461
|
+
description: undefined,
|
|
462
|
+
events,
|
|
463
|
+
publisherService: mockPublisherService,
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
467
|
+
const handler = adapter.handler;
|
|
468
|
+
|
|
469
|
+
const event = createMockEvent({
|
|
470
|
+
httpMethod: 'POST',
|
|
471
|
+
body: JSON.stringify({ name: 'John Doe', email: 'john@example.com' }),
|
|
472
|
+
});
|
|
473
|
+
const context = createMockContext();
|
|
474
|
+
const response = await handler(event, context);
|
|
475
|
+
|
|
476
|
+
expect(response.statusCode).toBe(201);
|
|
477
|
+
expect(response.body).toBe(
|
|
478
|
+
JSON.stringify({
|
|
479
|
+
id: '777',
|
|
480
|
+
name: 'John Doe',
|
|
481
|
+
email: 'john@example.com',
|
|
482
|
+
}),
|
|
483
|
+
);
|
|
484
|
+
|
|
485
|
+
expect(mockPublisher.publish).toHaveBeenCalledWith([
|
|
486
|
+
{
|
|
487
|
+
type: 'user.created',
|
|
488
|
+
payload: { userId: '777', email: 'john@example.com' },
|
|
489
|
+
},
|
|
490
|
+
]);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it('should not publish events when handler throws an error', async () => {
|
|
494
|
+
const mockPublisher: EventPublisher<TestEvent> = {
|
|
495
|
+
publish: vi.fn().mockResolvedValue(undefined),
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
const mockPublisherService: Service<
|
|
499
|
+
'publisher',
|
|
500
|
+
EventPublisher<TestEvent>
|
|
501
|
+
> = {
|
|
502
|
+
serviceName: 'publisher' as const,
|
|
503
|
+
register: vi.fn().mockResolvedValue(mockPublisher),
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
const outputSchema = z.object({ id: z.string(), email: z.string() });
|
|
507
|
+
|
|
508
|
+
const events: MappedEvent<
|
|
509
|
+
EventPublisher<TestEvent>,
|
|
510
|
+
typeof outputSchema
|
|
511
|
+
>[] = [
|
|
512
|
+
{
|
|
513
|
+
type: 'user.created',
|
|
514
|
+
payload: (response) => ({ userId: response.id, email: response.email }),
|
|
515
|
+
},
|
|
516
|
+
];
|
|
517
|
+
|
|
518
|
+
const endpoint = new Endpoint({
|
|
519
|
+
route: '/users',
|
|
520
|
+
method: 'POST',
|
|
521
|
+
fn: async () => {
|
|
522
|
+
throw new Error('Database connection failed');
|
|
523
|
+
},
|
|
524
|
+
input: undefined,
|
|
525
|
+
output: outputSchema,
|
|
526
|
+
services: [],
|
|
527
|
+
logger: mockLogger,
|
|
528
|
+
timeout: undefined,
|
|
529
|
+
status: 200,
|
|
530
|
+
getSession: undefined,
|
|
531
|
+
authorize: undefined,
|
|
532
|
+
description: undefined,
|
|
533
|
+
events,
|
|
534
|
+
publisherService: mockPublisherService,
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
538
|
+
const handler = adapter.handler;
|
|
539
|
+
|
|
540
|
+
const event = createMockEvent({
|
|
541
|
+
httpMethod: 'POST',
|
|
542
|
+
body: JSON.stringify({}),
|
|
543
|
+
});
|
|
544
|
+
const context = createMockContext();
|
|
545
|
+
const response = await handler(event, context);
|
|
546
|
+
|
|
547
|
+
// The endpoint should return an error response
|
|
548
|
+
expect(response.statusCode).toBe(500);
|
|
549
|
+
|
|
550
|
+
// Events should not be published when handler fails
|
|
551
|
+
expect(mockPublisher.publish).not.toHaveBeenCalled();
|
|
552
|
+
});
|
|
553
|
+
});
|