@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
package/README.md
ADDED
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
# @geekmidas/constructs
|
|
2
|
+
|
|
3
|
+
A comprehensive framework for building type-safe HTTP endpoints, cloud functions, scheduled tasks, and event subscribers with full TypeScript support and AWS Lambda deployment capabilities.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Type-Safe Endpoints**: Build HTTP endpoints with full type inference
|
|
8
|
+
- **Cloud Functions**: Create serverless functions with schema validation
|
|
9
|
+
- **Scheduled Tasks**: Define cron jobs with type-safe handlers
|
|
10
|
+
- **Event Subscribers**: Handle events with structured message processing
|
|
11
|
+
- **Service Discovery**: Built-in dependency injection system
|
|
12
|
+
- **Multiple Adapters**: AWS Lambda, API Gateway (v1/v2), and Hono support
|
|
13
|
+
- **StandardSchema Validation**: Works with Zod, Valibot, and other validation libraries
|
|
14
|
+
- **Event Publishing**: Integrated event publishing from any construct
|
|
15
|
+
- **Rate Limiting**: Built-in rate limiting with configurable storage
|
|
16
|
+
- **OpenAPI Integration**: Generate OpenAPI specifications from endpoints
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm add @geekmidas/constructs
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Package Exports
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// Endpoints
|
|
28
|
+
import { e, EndpointBuilder } from '@geekmidas/constructs/endpoints';
|
|
29
|
+
|
|
30
|
+
// Functions
|
|
31
|
+
import { f, FunctionBuilder } from '@geekmidas/constructs/functions';
|
|
32
|
+
|
|
33
|
+
// Crons
|
|
34
|
+
import { cron, CronBuilder } from '@geekmidas/constructs/crons';
|
|
35
|
+
|
|
36
|
+
// Subscribers
|
|
37
|
+
import { SubscriberBuilder } from '@geekmidas/constructs/subscribers';
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
### HTTP Endpoints
|
|
43
|
+
|
|
44
|
+
Create type-safe HTTP endpoints with the fluent builder pattern:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { e } from '@geekmidas/constructs/endpoints';
|
|
48
|
+
import { z } from 'zod';
|
|
49
|
+
|
|
50
|
+
// Simple GET endpoint
|
|
51
|
+
export const getUsers = e
|
|
52
|
+
.get('/users')
|
|
53
|
+
.output(z.array(z.object({
|
|
54
|
+
id: z.string(),
|
|
55
|
+
name: z.string(),
|
|
56
|
+
email: z.string().email()
|
|
57
|
+
})))
|
|
58
|
+
.handle(async () => {
|
|
59
|
+
return [
|
|
60
|
+
{ id: '1', name: 'John Doe', email: 'john@example.com' }
|
|
61
|
+
];
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// POST endpoint with body validation
|
|
65
|
+
export const createUser = e
|
|
66
|
+
.post('/users')
|
|
67
|
+
.body(z.object({
|
|
68
|
+
name: z.string().min(1),
|
|
69
|
+
email: z.string().email()
|
|
70
|
+
}))
|
|
71
|
+
.output(z.object({
|
|
72
|
+
id: z.string(),
|
|
73
|
+
name: z.string(),
|
|
74
|
+
email: z.string()
|
|
75
|
+
}))
|
|
76
|
+
.handle(async ({ body }) => {
|
|
77
|
+
// body is fully typed as { name: string; email: string }
|
|
78
|
+
return {
|
|
79
|
+
id: crypto.randomUUID(),
|
|
80
|
+
name: body.name,
|
|
81
|
+
email: body.email
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Endpoint with query parameters
|
|
86
|
+
export const searchUsers = e
|
|
87
|
+
.get('/users/search')
|
|
88
|
+
.query(z.object({
|
|
89
|
+
q: z.string(),
|
|
90
|
+
limit: z.coerce.number().default(10)
|
|
91
|
+
}))
|
|
92
|
+
.output(z.array(z.object({
|
|
93
|
+
id: z.string(),
|
|
94
|
+
name: z.string()
|
|
95
|
+
})))
|
|
96
|
+
.handle(async ({ query }) => {
|
|
97
|
+
// query is typed as { q: string; limit: number }
|
|
98
|
+
return [];
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Cloud Functions
|
|
103
|
+
|
|
104
|
+
Create serverless functions with input/output validation:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { f } from '@geekmidas/constructs/functions';
|
|
108
|
+
import { z } from 'zod';
|
|
109
|
+
|
|
110
|
+
export const processOrder = f
|
|
111
|
+
.input(z.object({
|
|
112
|
+
orderId: z.string(),
|
|
113
|
+
items: z.array(z.object({
|
|
114
|
+
id: z.string(),
|
|
115
|
+
quantity: z.number().int().positive()
|
|
116
|
+
}))
|
|
117
|
+
}))
|
|
118
|
+
.output(z.object({
|
|
119
|
+
orderId: z.string(),
|
|
120
|
+
status: z.enum(['processing', 'completed', 'failed']),
|
|
121
|
+
processedAt: z.string().datetime()
|
|
122
|
+
}))
|
|
123
|
+
.timeout(300000) // 5 minutes
|
|
124
|
+
.handle(async ({ input, logger }) => {
|
|
125
|
+
logger.info(`Processing order ${input.orderId}`);
|
|
126
|
+
|
|
127
|
+
// Process order logic
|
|
128
|
+
for (const item of input.items) {
|
|
129
|
+
logger.info(`Processing item ${item.id}, quantity: ${item.quantity}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
orderId: input.orderId,
|
|
134
|
+
status: 'completed',
|
|
135
|
+
processedAt: new Date().toISOString()
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Scheduled Tasks (Crons)
|
|
141
|
+
|
|
142
|
+
Define cron jobs with schedules:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { cron } from '@geekmidas/constructs/crons';
|
|
146
|
+
|
|
147
|
+
// Daily report at 9 AM UTC
|
|
148
|
+
export const dailyReport = cron
|
|
149
|
+
.schedule('cron(0 9 * * ? *)')
|
|
150
|
+
.timeout(600000) // 10 minutes
|
|
151
|
+
.handle(async ({ logger }) => {
|
|
152
|
+
logger.info('Generating daily report');
|
|
153
|
+
|
|
154
|
+
const reportDate = new Date().toISOString().split('T')[0];
|
|
155
|
+
const reportData = {
|
|
156
|
+
date: reportDate,
|
|
157
|
+
totalOrders: 150,
|
|
158
|
+
totalRevenue: 12500.00
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
logger.info('Daily report generated', reportData);
|
|
162
|
+
return reportData;
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Hourly cleanup
|
|
166
|
+
export const hourlyCleanup = cron
|
|
167
|
+
.schedule('rate(1 hour)')
|
|
168
|
+
.timeout(300000) // 5 minutes
|
|
169
|
+
.handle(async ({ logger }) => {
|
|
170
|
+
logger.info('Running hourly cleanup');
|
|
171
|
+
|
|
172
|
+
const itemsCleaned = 42;
|
|
173
|
+
logger.info(`Cleaned ${itemsCleaned} items`);
|
|
174
|
+
|
|
175
|
+
return { itemsCleaned };
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Event Subscribers
|
|
180
|
+
|
|
181
|
+
Handle events with type-safe message processing:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import { SubscriberBuilder } from '@geekmidas/constructs/subscribers';
|
|
185
|
+
import { z } from 'zod';
|
|
186
|
+
|
|
187
|
+
export const userEventsSubscriber = new SubscriberBuilder()
|
|
188
|
+
.subscribe(['user.created', 'user.updated', 'user.deleted'])
|
|
189
|
+
.timeout(30000)
|
|
190
|
+
.output(z.object({
|
|
191
|
+
processed: z.number(),
|
|
192
|
+
success: z.boolean()
|
|
193
|
+
}))
|
|
194
|
+
.handle(async ({ events, logger }) => {
|
|
195
|
+
logger.info(
|
|
196
|
+
{ eventCount: events.length },
|
|
197
|
+
'Processing user events'
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
for (const event of events) {
|
|
201
|
+
try {
|
|
202
|
+
switch (event.type) {
|
|
203
|
+
case 'user.created':
|
|
204
|
+
logger.info({ userId: event.data.userId }, 'User created');
|
|
205
|
+
break;
|
|
206
|
+
case 'user.updated':
|
|
207
|
+
logger.info({ userId: event.data.userId }, 'User updated');
|
|
208
|
+
break;
|
|
209
|
+
case 'user.deleted':
|
|
210
|
+
logger.info({ userId: event.data.userId }, 'User deleted');
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
} catch (error) {
|
|
214
|
+
logger.error({ error, event }, 'Failed to process event');
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
processed: events.length,
|
|
221
|
+
success: true
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Advanced Features
|
|
227
|
+
|
|
228
|
+
### Service Discovery
|
|
229
|
+
|
|
230
|
+
Inject services into your constructs:
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
import { e } from '@geekmidas/constructs/endpoints';
|
|
234
|
+
import type { Service } from '@geekmidas/services';
|
|
235
|
+
import type { EnvironmentParser } from '@geekmidas/envkit';
|
|
236
|
+
import { Kysely } from 'kysely';
|
|
237
|
+
import { z } from 'zod';
|
|
238
|
+
|
|
239
|
+
// Define a database service
|
|
240
|
+
const databaseService = {
|
|
241
|
+
serviceName: 'database' as const,
|
|
242
|
+
async register(envParser: EnvironmentParser<{}>) {
|
|
243
|
+
const config = envParser.create((get) => ({
|
|
244
|
+
url: get('DATABASE_URL').string()
|
|
245
|
+
})).parse();
|
|
246
|
+
|
|
247
|
+
const db = new Kysely({ /* config */ });
|
|
248
|
+
return db;
|
|
249
|
+
}
|
|
250
|
+
} satisfies Service<'database', Kysely<Database>>;
|
|
251
|
+
|
|
252
|
+
// Use service in endpoint
|
|
253
|
+
export const getUserFromDb = e
|
|
254
|
+
.get('/users/:id')
|
|
255
|
+
.params(z.object({ id: z.string() }))
|
|
256
|
+
.services([databaseService])
|
|
257
|
+
.handle(async ({ params, services }) => {
|
|
258
|
+
// services.database is fully typed
|
|
259
|
+
const user = await services.database
|
|
260
|
+
.selectFrom('users')
|
|
261
|
+
.where('id', '=', params.id)
|
|
262
|
+
.selectAll()
|
|
263
|
+
.executeTakeFirst();
|
|
264
|
+
|
|
265
|
+
return user;
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Event Publishing
|
|
270
|
+
|
|
271
|
+
Publish events from any construct:
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
import { e } from '@geekmidas/constructs/endpoints';
|
|
275
|
+
import type { Service } from '@geekmidas/services';
|
|
276
|
+
import type { EventPublisher, PublishableMessage } from '@geekmidas/events';
|
|
277
|
+
import { z } from 'zod';
|
|
278
|
+
|
|
279
|
+
// Define event types
|
|
280
|
+
type UserEvents =
|
|
281
|
+
| PublishableMessage<'user.created', { userId: string; email: string }>
|
|
282
|
+
| PublishableMessage<'user.updated', { userId: string }>;
|
|
283
|
+
|
|
284
|
+
// Create event publisher service
|
|
285
|
+
const userEventPublisher = {
|
|
286
|
+
serviceName: 'userEventPublisher' as const,
|
|
287
|
+
async register(envParser: EnvironmentParser<{}>) {
|
|
288
|
+
const config = envParser.create((get) => ({
|
|
289
|
+
publisherUrl: get('EVENT_PUBLISHER_URL').string()
|
|
290
|
+
})).parse();
|
|
291
|
+
|
|
292
|
+
const { Publisher } = await import('@geekmidas/events');
|
|
293
|
+
return Publisher.fromConnectionString<UserEvents>(config.publisherUrl);
|
|
294
|
+
}
|
|
295
|
+
} satisfies Service<'userEventPublisher', EventPublisher<UserEvents>>;
|
|
296
|
+
|
|
297
|
+
// Use in endpoint with event publishing
|
|
298
|
+
export const createUser = e
|
|
299
|
+
.post('/users')
|
|
300
|
+
.body(z.object({
|
|
301
|
+
name: z.string(),
|
|
302
|
+
email: z.string().email()
|
|
303
|
+
}))
|
|
304
|
+
.publisher(userEventPublisher)
|
|
305
|
+
.event('user.created', (body, result) => ({
|
|
306
|
+
userId: result.id,
|
|
307
|
+
email: body.email
|
|
308
|
+
}))
|
|
309
|
+
.handle(async ({ body, publish }) => {
|
|
310
|
+
const user = {
|
|
311
|
+
id: crypto.randomUUID(),
|
|
312
|
+
name: body.name,
|
|
313
|
+
email: body.email
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// Events are automatically published after successful execution
|
|
317
|
+
return user;
|
|
318
|
+
});
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Rate Limiting
|
|
322
|
+
|
|
323
|
+
Add rate limiting to endpoints:
|
|
324
|
+
|
|
325
|
+
```typescript
|
|
326
|
+
import { e } from '@geekmidas/constructs/endpoints';
|
|
327
|
+
import { InMemoryCache } from '@geekmidas/cache/memory';
|
|
328
|
+
import { z } from 'zod';
|
|
329
|
+
|
|
330
|
+
export const sendMessage = e
|
|
331
|
+
.post('/api/messages')
|
|
332
|
+
.rateLimit({
|
|
333
|
+
limit: 10,
|
|
334
|
+
windowMs: 60000, // 1 minute
|
|
335
|
+
cache: new InMemoryCache(),
|
|
336
|
+
})
|
|
337
|
+
.body(z.object({
|
|
338
|
+
content: z.string()
|
|
339
|
+
}))
|
|
340
|
+
.handle(async ({ body }) => {
|
|
341
|
+
// Rate limited to 10 requests per minute
|
|
342
|
+
return { success: true };
|
|
343
|
+
});
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## AWS Lambda Adapters
|
|
347
|
+
|
|
348
|
+
Deploy your constructs to AWS Lambda:
|
|
349
|
+
|
|
350
|
+
### API Gateway v1 Adapter
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
import { AmazonApiGatewayV1Endpoint } from '@geekmidas/constructs/aws';
|
|
354
|
+
import { getUsers } from './endpoints';
|
|
355
|
+
import { envParser } from './env';
|
|
356
|
+
|
|
357
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, getUsers);
|
|
358
|
+
|
|
359
|
+
export const handler = adapter.handler;
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### API Gateway v2 Adapter
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
import { AmazonApiGatewayV2Endpoint } from '@geekmidas/constructs/aws';
|
|
366
|
+
import { getUsers } from './endpoints';
|
|
367
|
+
import { envParser } from './env';
|
|
368
|
+
|
|
369
|
+
const adapter = new AmazonApiGatewayV2Endpoint(envParser, getUsers);
|
|
370
|
+
|
|
371
|
+
export const handler = adapter.handler;
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### Lambda Function Adapter
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
import { AWSLambdaFunction } from '@geekmidas/constructs/aws';
|
|
378
|
+
import { processOrder } from './functions';
|
|
379
|
+
import { envParser } from './env';
|
|
380
|
+
|
|
381
|
+
const adapter = new AWSLambdaFunction(envParser, processOrder);
|
|
382
|
+
|
|
383
|
+
export const handler = adapter.handler;
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Lambda Cron Adapter
|
|
387
|
+
|
|
388
|
+
```typescript
|
|
389
|
+
import { AWSScheduledFunction } from '@geekmidas/constructs/aws';
|
|
390
|
+
import { dailyReport } from './crons';
|
|
391
|
+
import { envParser } from './env';
|
|
392
|
+
|
|
393
|
+
const adapter = new AWSScheduledFunction(envParser, dailyReport);
|
|
394
|
+
|
|
395
|
+
export const handler = adapter.handler;
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Lambda Subscriber Adapter
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
import { AWSLambdaSubscriber } from '@geekmidas/constructs/aws';
|
|
402
|
+
import { userEventsSubscriber } from './subscribers';
|
|
403
|
+
import { envParser } from './env';
|
|
404
|
+
|
|
405
|
+
const adapter = new AWSLambdaSubscriber(envParser, userEventsSubscriber);
|
|
406
|
+
|
|
407
|
+
export const handler = adapter.handler;
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
## Hono Server Adapter
|
|
411
|
+
|
|
412
|
+
Deploy your endpoints as a Hono server:
|
|
413
|
+
|
|
414
|
+
```typescript
|
|
415
|
+
import { HonoEndpoint } from '@geekmidas/constructs/endpoints';
|
|
416
|
+
import { ServiceDiscovery } from '@geekmidas/services';
|
|
417
|
+
import { Hono } from 'hono';
|
|
418
|
+
import { envParser } from './env';
|
|
419
|
+
import { logger } from './logger';
|
|
420
|
+
import { getUsers, createUser } from './endpoints';
|
|
421
|
+
|
|
422
|
+
export function createApp(app?: Hono): Hono {
|
|
423
|
+
const honoApp = app || new Hono();
|
|
424
|
+
|
|
425
|
+
const endpoints = [getUsers, createUser];
|
|
426
|
+
|
|
427
|
+
const serviceDiscovery = ServiceDiscovery.getInstance(logger, envParser);
|
|
428
|
+
|
|
429
|
+
HonoEndpoint.addRoutes(endpoints, serviceDiscovery, honoApp);
|
|
430
|
+
|
|
431
|
+
return honoApp;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// server.ts
|
|
435
|
+
import { serve } from '@hono/node-server';
|
|
436
|
+
import { createApp } from './app';
|
|
437
|
+
|
|
438
|
+
const app = createApp();
|
|
439
|
+
|
|
440
|
+
serve({
|
|
441
|
+
fetch: app.fetch,
|
|
442
|
+
port: 3000
|
|
443
|
+
}, () => {
|
|
444
|
+
console.log('Server running on http://localhost:3000');
|
|
445
|
+
});
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
## OpenAPI Support
|
|
449
|
+
|
|
450
|
+
Extract OpenAPI components from endpoints:
|
|
451
|
+
|
|
452
|
+
```typescript
|
|
453
|
+
import { OpenApiExtractor } from '@geekmidas/constructs/endpoints';
|
|
454
|
+
import { getUsers, createUser } from './endpoints';
|
|
455
|
+
|
|
456
|
+
const extractor = new OpenApiExtractor();
|
|
457
|
+
const components = extractor.extractComponents([getUsers, createUser]);
|
|
458
|
+
|
|
459
|
+
// Use with @geekmidas/cli to generate full OpenAPI spec
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
## Environment Variable Detection
|
|
463
|
+
|
|
464
|
+
All constructs support automatic environment variable detection for build-time infrastructure provisioning. This allows deployment tools to know exactly which environment variables each construct requires.
|
|
465
|
+
|
|
466
|
+
### Using `getEnvironment()`
|
|
467
|
+
|
|
468
|
+
Every construct has an async `getEnvironment()` method that returns the environment variables required by its services:
|
|
469
|
+
|
|
470
|
+
```typescript
|
|
471
|
+
import { e } from '@geekmidas/constructs/endpoints';
|
|
472
|
+
import { databaseService } from './services/database';
|
|
473
|
+
import { cacheService } from './services/cache';
|
|
474
|
+
|
|
475
|
+
const endpoint = e
|
|
476
|
+
.get('/users')
|
|
477
|
+
.services([databaseService, cacheService])
|
|
478
|
+
.handle(async ({ services }) => {
|
|
479
|
+
// Implementation
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
// Detect required environment variables
|
|
483
|
+
const envVars = await endpoint.getEnvironment();
|
|
484
|
+
// Returns: ['CACHE_URL', 'DATABASE_URL'] (sorted alphabetically)
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### How It Works
|
|
488
|
+
|
|
489
|
+
The detection works by:
|
|
490
|
+
|
|
491
|
+
1. Creating a "sniffer" `EnvironmentParser` with empty configuration
|
|
492
|
+
2. Calling each service's `register()` method with the sniffer
|
|
493
|
+
3. Tracking which environment variables are accessed via `get('VAR_NAME')`
|
|
494
|
+
4. Collecting and deduplicating the variable names
|
|
495
|
+
5. Returning a sorted array of variable names
|
|
496
|
+
|
|
497
|
+
**Important**: Environment variables are tracked when `get('VAR_NAME')` is called, **before** `.parse()` validates the values. This means detection works even when actual environment values don't exist (build time).
|
|
498
|
+
|
|
499
|
+
### Service Pattern for Detection
|
|
500
|
+
|
|
501
|
+
For environment detection to work, services should return the `ConfigParser` from `envParser.create()`:
|
|
502
|
+
|
|
503
|
+
```typescript
|
|
504
|
+
import type { Service } from '@geekmidas/services';
|
|
505
|
+
import type { EnvironmentParser } from '@geekmidas/envkit';
|
|
506
|
+
|
|
507
|
+
// ✅ Sync service - returns ConfigParser directly
|
|
508
|
+
const databaseService = {
|
|
509
|
+
serviceName: 'database' as const,
|
|
510
|
+
register(envParser: EnvironmentParser<{}>) {
|
|
511
|
+
// Return the ConfigParser - this tracks env vars
|
|
512
|
+
return envParser.create((get) => ({
|
|
513
|
+
url: get('DATABASE_URL').string(),
|
|
514
|
+
port: get('DATABASE_PORT').string().transform(Number).default('5432')
|
|
515
|
+
}));
|
|
516
|
+
}
|
|
517
|
+
} satisfies Service<'database', any>;
|
|
518
|
+
|
|
519
|
+
// ✅ Async service - check for empty env to support detection
|
|
520
|
+
const eventService = {
|
|
521
|
+
serviceName: 'events' as const,
|
|
522
|
+
register(envParser: EnvironmentParser<{}>) {
|
|
523
|
+
const configParser = envParser.create((get) => ({
|
|
524
|
+
connectionString: get('EVENT_CONNECTION_STRING').string()
|
|
525
|
+
}));
|
|
526
|
+
|
|
527
|
+
// Return ConfigParser for environment detection (build time)
|
|
528
|
+
// @ts-ignore - accessing internal property to detect sniffer
|
|
529
|
+
if (Object.keys(envParser.env || {}).length === 0) {
|
|
530
|
+
return configParser;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// Return Promise for runtime
|
|
534
|
+
return (async () => {
|
|
535
|
+
const config = configParser.parse();
|
|
536
|
+
// Initialize service with config
|
|
537
|
+
return await createService(config);
|
|
538
|
+
})();
|
|
539
|
+
}
|
|
540
|
+
} satisfies Service<'events', any>;
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### Build-Time Usage
|
|
544
|
+
|
|
545
|
+
The `@geekmidas/cli` automatically calls `getEnvironment()` during build to populate the manifest:
|
|
546
|
+
|
|
547
|
+
```json
|
|
548
|
+
{
|
|
549
|
+
"routes": [
|
|
550
|
+
{
|
|
551
|
+
"path": "/users",
|
|
552
|
+
"method": "GET",
|
|
553
|
+
"handler": ".gkm/getUsers.handler",
|
|
554
|
+
"environment": [
|
|
555
|
+
"DATABASE_URL",
|
|
556
|
+
"DATABASE_PORT"
|
|
557
|
+
]
|
|
558
|
+
}
|
|
559
|
+
]
|
|
560
|
+
}
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
This manifest can then be used by infrastructure-as-code tools (Terraform, CDK, SST, etc.) to automatically configure Lambda functions with the correct environment variables.
|
|
564
|
+
|
|
565
|
+
### Features
|
|
566
|
+
|
|
567
|
+
- **Automatic Detection**: No manual configuration needed
|
|
568
|
+
- **Async Service Support**: Works with both sync and async services
|
|
569
|
+
- **Deduplication**: Each variable listed once even if used by multiple services
|
|
570
|
+
- **Sorted Output**: Variables always returned in alphabetical order
|
|
571
|
+
- **Error Resilient**: Parse failures don't affect detection
|
|
572
|
+
- **Publisher Support**: Detects variables from `.publisher()` services
|
|
573
|
+
|
|
574
|
+
### Example with Multiple Services
|
|
575
|
+
|
|
576
|
+
```typescript
|
|
577
|
+
import { e } from '@geekmidas/constructs/endpoints';
|
|
578
|
+
import { databaseService } from './services/database';
|
|
579
|
+
import { cacheService } from './services/cache';
|
|
580
|
+
import { emailService } from './services/email';
|
|
581
|
+
|
|
582
|
+
const endpoint = e
|
|
583
|
+
.post('/users')
|
|
584
|
+
.services([databaseService, cacheService, emailService])
|
|
585
|
+
.handle(async ({ services }) => {
|
|
586
|
+
// Create user
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
// Automatically detects all variables from all services
|
|
590
|
+
const envVars = await endpoint.getEnvironment();
|
|
591
|
+
// Returns: [
|
|
592
|
+
// 'CACHE_URL',
|
|
593
|
+
// 'DATABASE_URL',
|
|
594
|
+
// 'DATABASE_PORT',
|
|
595
|
+
// 'SMTP_HOST',
|
|
596
|
+
// 'SMTP_PORT',
|
|
597
|
+
// 'SMTP_USER',
|
|
598
|
+
// 'SMTP_PASS'
|
|
599
|
+
// ]
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
## Related Packages
|
|
603
|
+
|
|
604
|
+
- [@geekmidas/services](../services) - Service discovery and dependency injection
|
|
605
|
+
- [@geekmidas/events](../events) - Event publishing and subscription
|
|
606
|
+
- [@geekmidas/logger](../logger) - Structured logging
|
|
607
|
+
- [@geekmidas/envkit](../envkit) - Environment configuration
|
|
608
|
+
- [@geekmidas/errors](../errors) - HTTP error classes
|
|
609
|
+
- [@geekmidas/client](../client) - Type-safe client for consuming endpoints
|
|
610
|
+
- [@geekmidas/cli](../cli) - CLI tools for building and deploying
|
|
611
|
+
|
|
612
|
+
## License
|
|
613
|
+
|
|
614
|
+
MIT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Function, FunctionHandler } from "./Function-BsBxc2wA.mjs";
|
|
2
|
+
import { FunctionExecutionWrapper } from "./FunctionExecutionWrapper-DvglBBjE.mjs";
|
|
3
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
4
|
+
import { Service } from "@geekmidas/services";
|
|
5
|
+
import { EventPublisher } from "@geekmidas/events";
|
|
6
|
+
import { Logger } from "@geekmidas/logger";
|
|
7
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
8
|
+
import { ComposableStandardSchema } from "@geekmidas/schema";
|
|
9
|
+
import { Handler } from "aws-lambda";
|
|
10
|
+
|
|
11
|
+
//#region src/functions/AWSLambdaFunction.d.ts
|
|
12
|
+
type AWSLambdaHandler<TEvent = any, TResult = any> = Handler<TEvent, TResult>;
|
|
13
|
+
declare class AWSLambdaFunction<TInput extends ComposableStandardSchema | undefined = undefined, TOutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string> extends FunctionExecutionWrapper<TInput, TOutSchema, TServices, TLogger, TEventPublisher, TEventPublisherServiceName> {
|
|
14
|
+
readonly fn: Function<TInput, TServices, TLogger, TOutSchema, FunctionHandler<TInput, TServices, TLogger, TOutSchema>, TEventPublisher, TEventPublisherServiceName>;
|
|
15
|
+
constructor(envParser: EnvironmentParser<{}>, fn: Function<TInput, TServices, TLogger, TOutSchema, FunctionHandler<TInput, TServices, TLogger, TOutSchema>, TEventPublisher, TEventPublisherServiceName>);
|
|
16
|
+
private error;
|
|
17
|
+
private baseInput;
|
|
18
|
+
private input;
|
|
19
|
+
private loggerMiddleware;
|
|
20
|
+
private services;
|
|
21
|
+
private events;
|
|
22
|
+
private _handler;
|
|
23
|
+
get handler(): AWSLambdaHandler;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AWSLambdaFunction, AWSLambdaHandler };
|
|
27
|
+
//# sourceMappingURL=AWSLambdaFunction-CpHFE2m6.d.mts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Function, FunctionHandler } from "./Function-BP58p9Mp.cjs";
|
|
2
|
+
import { FunctionExecutionWrapper } from "./FunctionExecutionWrapper-Bx-Dl-2a.cjs";
|
|
3
|
+
import { EventPublisher } from "@geekmidas/events";
|
|
4
|
+
import { Logger } from "@geekmidas/logger";
|
|
5
|
+
import { Service } from "@geekmidas/services";
|
|
6
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
7
|
+
import { ComposableStandardSchema } from "@geekmidas/schema";
|
|
8
|
+
import { EnvironmentParser } from "@geekmidas/envkit";
|
|
9
|
+
import { Handler } from "aws-lambda";
|
|
10
|
+
|
|
11
|
+
//#region src/functions/AWSLambdaFunction.d.ts
|
|
12
|
+
type AWSLambdaHandler<TEvent = any, TResult = any> = Handler<TEvent, TResult>;
|
|
13
|
+
declare class AWSLambdaFunction<TInput extends ComposableStandardSchema | undefined = undefined, TOutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TEventPublisher extends EventPublisher<any> | undefined = undefined, TEventPublisherServiceName extends string = string> extends FunctionExecutionWrapper<TInput, TOutSchema, TServices, TLogger, TEventPublisher, TEventPublisherServiceName> {
|
|
14
|
+
readonly fn: Function<TInput, TServices, TLogger, TOutSchema, FunctionHandler<TInput, TServices, TLogger, TOutSchema>, TEventPublisher, TEventPublisherServiceName>;
|
|
15
|
+
constructor(envParser: EnvironmentParser<{}>, fn: Function<TInput, TServices, TLogger, TOutSchema, FunctionHandler<TInput, TServices, TLogger, TOutSchema>, TEventPublisher, TEventPublisherServiceName>);
|
|
16
|
+
private error;
|
|
17
|
+
private baseInput;
|
|
18
|
+
private input;
|
|
19
|
+
private loggerMiddleware;
|
|
20
|
+
private services;
|
|
21
|
+
private events;
|
|
22
|
+
private _handler;
|
|
23
|
+
get handler(): AWSLambdaHandler;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AWSLambdaFunction, AWSLambdaHandler };
|
|
27
|
+
//# sourceMappingURL=AWSLambdaFunction-CwagvPG3.d.cts.map
|