@geekmidas/constructs 0.3.2 → 0.5.0
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/dist/{AWSLambdaFunction-EPGY4s7i.cjs → AWSLambdaFunction-Ba1DcsW2.cjs} +6 -6
- package/dist/AWSLambdaFunction-Ba1DcsW2.cjs.map +1 -0
- package/dist/{AWSLambdaFunction-BdebRMUh.d.mts → AWSLambdaFunction-CKe73Qr0.d.cts} +6 -6
- package/dist/AWSLambdaFunction-CKe73Qr0.d.cts.map +1 -0
- package/dist/{AWSLambdaFunction-D0tEOTXQ.d.cts → AWSLambdaFunction-CuG3HNZx.d.mts} +6 -6
- package/dist/AWSLambdaFunction-CuG3HNZx.d.mts.map +1 -0
- package/dist/{AWSLambdaFunction-C54a1doJ.mjs → AWSLambdaFunction-DnMm4xvz.mjs} +6 -6
- package/dist/AWSLambdaFunction-DnMm4xvz.mjs.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-Dx-Ks1Jp.d.cts → AWSLambdaSubscriberAdaptor-B4HH-WuQ.d.mts} +4 -4
- package/dist/AWSLambdaSubscriberAdaptor-B4HH-WuQ.d.mts.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-BLfO612H.mjs → AWSLambdaSubscriberAdaptor-BD3FwGUb.mjs} +3 -3
- package/dist/AWSLambdaSubscriberAdaptor-BD3FwGUb.mjs.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-DrFAvHOp.d.mts → AWSLambdaSubscriberAdaptor-BEqQ96VJ.d.cts} +4 -4
- package/dist/AWSLambdaSubscriberAdaptor-BEqQ96VJ.d.cts.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-BNcYYZ-P.cjs → AWSLambdaSubscriberAdaptor-DQDnt1Xk.cjs} +3 -3
- package/dist/AWSLambdaSubscriberAdaptor-DQDnt1Xk.cjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-BT9JXihC.mjs → AmazonApiGatewayEndpointAdaptor-Bvy-Hgjf.mjs} +56 -14
- package/dist/AmazonApiGatewayEndpointAdaptor-Bvy-Hgjf.mjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-DNFvvdmW.cjs → AmazonApiGatewayEndpointAdaptor-Cpxluhfg.cjs} +55 -13
- package/dist/AmazonApiGatewayEndpointAdaptor-Cpxluhfg.cjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-qlKXuZxy.d.mts → AmazonApiGatewayEndpointAdaptor-DTgdZ8I1.d.mts} +52 -6
- package/dist/AmazonApiGatewayEndpointAdaptor-DTgdZ8I1.d.mts.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-DLqnYQ4E.d.cts → AmazonApiGatewayEndpointAdaptor-DsWnO6x9.d.cts} +51 -5
- package/dist/AmazonApiGatewayEndpointAdaptor-DsWnO6x9.d.cts.map +1 -0
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-DyUaJIhB.d.cts → AmazonApiGatewayV1EndpointAdaptor-7ELXUBFK.d.cts} +4 -4
- package/dist/AmazonApiGatewayV1EndpointAdaptor-7ELXUBFK.d.cts.map +1 -0
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-Ccl8B8kG.cjs → AmazonApiGatewayV1EndpointAdaptor-B8vIYYNh.cjs} +4 -4
- package/dist/AmazonApiGatewayV1EndpointAdaptor-B8vIYYNh.cjs.map +1 -0
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-CShQI8Gk.mjs → AmazonApiGatewayV1EndpointAdaptor-ByXGIju8.mjs} +4 -4
- package/dist/AmazonApiGatewayV1EndpointAdaptor-ByXGIju8.mjs.map +1 -0
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-MRUxs3Xi.d.mts → AmazonApiGatewayV1EndpointAdaptor-RWRmFPrN.d.mts} +5 -5
- package/dist/AmazonApiGatewayV1EndpointAdaptor-RWRmFPrN.d.mts.map +1 -0
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-D8-0Aab4.cjs → AmazonApiGatewayV2EndpointAdaptor-DIetspUm.cjs} +4 -4
- package/dist/AmazonApiGatewayV2EndpointAdaptor-DIetspUm.cjs.map +1 -0
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-lCRzGE4q.mjs → AmazonApiGatewayV2EndpointAdaptor-DWemCZvl.mjs} +4 -4
- package/dist/AmazonApiGatewayV2EndpointAdaptor-DWemCZvl.mjs.map +1 -0
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-M1-w0U5R.d.cts → AmazonApiGatewayV2EndpointAdaptor-D_uMTmuJ.d.cts} +4 -6
- package/dist/AmazonApiGatewayV2EndpointAdaptor-D_uMTmuJ.d.cts.map +1 -0
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-fuLM6M9k.d.mts → AmazonApiGatewayV2EndpointAdaptor-wnOMDv6o.d.mts} +5 -7
- package/dist/AmazonApiGatewayV2EndpointAdaptor-wnOMDv6o.d.mts.map +1 -0
- package/dist/{Authorizer-C0ge_tc8.cjs → Authorizer-BXxBee2P.cjs} +1 -1
- package/dist/Authorizer-BXxBee2P.cjs.map +1 -0
- package/dist/{Authorizer-r9U3y_ms.mjs → Authorizer-BgjU8-z6.mjs} +1 -1
- package/dist/Authorizer-BgjU8-z6.mjs.map +1 -0
- package/dist/{Authorizer-gWxYsGEp.d.mts → Authorizer-DCcYOx3h.d.mts} +1 -1
- package/dist/Authorizer-DCcYOx3h.d.mts.map +1 -0
- package/dist/{Authorizer-B-btowNd.d.cts → Authorizer-DWtwC8we.d.cts} +1 -1
- package/dist/Authorizer-DWtwC8we.d.cts.map +1 -0
- package/dist/{BaseFunctionBuilder-Czi1Jwza.mjs → BaseFunctionBuilder-0qlenb9z.mjs} +2 -2
- package/dist/BaseFunctionBuilder-0qlenb9z.mjs.map +1 -0
- package/dist/BaseFunctionBuilder-BAtutR6q.d.cts.map +1 -1
- package/dist/{BaseFunctionBuilder-DRY419e7.d.mts → BaseFunctionBuilder-CDfDWWAQ.d.mts} +2 -2
- package/dist/BaseFunctionBuilder-CDfDWWAQ.d.mts.map +1 -0
- package/dist/{BaseFunctionBuilder-MYG3C9ug.cjs → BaseFunctionBuilder-D7o93EGv.cjs} +2 -2
- package/dist/BaseFunctionBuilder-D7o93EGv.cjs.map +1 -0
- package/dist/{Construct-Ba5cMxib.cjs → Construct-BlnyYtJC.cjs} +31 -2
- package/dist/Construct-BlnyYtJC.cjs.map +1 -0
- package/dist/Construct-C4rPE67v.d.cts.map +1 -1
- package/dist/{Construct-DdyGHuag.mjs → Construct-D5dCvxZ3.mjs} +31 -2
- package/dist/Construct-D5dCvxZ3.mjs.map +1 -0
- package/dist/{Construct-XrijZFFh.d.mts → Construct-dZiwVo0q.d.mts} +1 -1
- package/dist/Construct-dZiwVo0q.d.mts.map +1 -0
- package/dist/Construct.cjs +1 -1
- package/dist/Construct.d.mts +1 -1
- package/dist/Construct.mjs +1 -1
- package/dist/{Cron-bDLcTvV5.d.cts → Cron-B6FnTu7k.d.cts} +2 -2
- package/dist/Cron-B6FnTu7k.d.cts.map +1 -0
- package/dist/{Cron-CGF4YAfM.cjs → Cron-BAPQetlC.cjs} +3 -3
- package/dist/Cron-BAPQetlC.cjs.map +1 -0
- package/dist/{Cron-BxhGs5up.mjs → Cron-CAk_ddH8.mjs} +3 -3
- package/dist/Cron-CAk_ddH8.mjs.map +1 -0
- package/dist/{Cron-cdjlSKNp.d.mts → Cron-D3bEljxQ.d.mts} +2 -2
- package/dist/Cron-D3bEljxQ.d.mts.map +1 -0
- package/dist/{CronBuilder-DKVXyE0Q.d.cts → CronBuilder-CA8euP0z.d.cts} +4 -4
- package/dist/CronBuilder-CA8euP0z.d.cts.map +1 -0
- package/dist/{CronBuilder-BC4m5-p1.d.mts → CronBuilder-DvdiKzhq.d.mts} +4 -4
- package/dist/CronBuilder-DvdiKzhq.d.mts.map +1 -0
- package/dist/{CronBuilder-CcxKRtVP.cjs → CronBuilder-DxXA5ymv.cjs} +4 -4
- package/dist/CronBuilder-DxXA5ymv.cjs.map +1 -0
- package/dist/{CronBuilder-d2jh-IB2.mjs → CronBuilder-e8TaHPYm.mjs} +4 -4
- package/dist/CronBuilder-e8TaHPYm.mjs.map +1 -0
- package/dist/{Endpoint-BPv9_-m_.d.cts → Endpoint-BOlbY5iq.d.cts} +3 -3
- package/dist/Endpoint-BOlbY5iq.d.cts.map +1 -0
- package/dist/{Endpoint-CuOEswxJ.mjs → Endpoint-BbdNmtlM.mjs} +6 -6
- package/dist/Endpoint-BbdNmtlM.mjs.map +1 -0
- package/dist/{Endpoint-BdwG75G_.d.mts → Endpoint-Dlv7nxgj.d.mts} +4 -4
- package/dist/Endpoint-Dlv7nxgj.d.mts.map +1 -0
- package/dist/{Endpoint-BVGZXFyV.cjs → Endpoint-DxvnlfXg.cjs} +6 -6
- package/dist/Endpoint-DxvnlfXg.cjs.map +1 -0
- package/dist/{EndpointBuilder-Cgj1P_ra.cjs → EndpointBuilder-40Iz5CjY.cjs} +6 -6
- package/dist/EndpointBuilder-40Iz5CjY.cjs.map +1 -0
- package/dist/{EndpointBuilder-DnCB1h1j.mjs → EndpointBuilder-BaVvhW9m.mjs} +6 -6
- package/dist/EndpointBuilder-BaVvhW9m.mjs.map +1 -0
- package/dist/{EndpointBuilder-DIy_m1bu.d.cts → EndpointBuilder-CFfWWjUa.d.cts} +3 -3
- package/dist/EndpointBuilder-CFfWWjUa.d.cts.map +1 -0
- package/dist/{EndpointBuilder-B3az942t.d.mts → EndpointBuilder-T_K2NLWw.d.mts} +5 -5
- package/dist/EndpointBuilder-T_K2NLWw.d.mts.map +1 -0
- package/dist/{EndpointFactory-CyPbm3AD.d.cts → EndpointFactory-ChzBVEM9.d.cts} +4 -4
- package/dist/EndpointFactory-ChzBVEM9.d.cts.map +1 -0
- package/dist/{EndpointFactory-CbdxPCIH.mjs → EndpointFactory-DfNjSgVG.mjs} +7 -7
- package/dist/EndpointFactory-DfNjSgVG.mjs.map +1 -0
- package/dist/{EndpointFactory-C-0nE6Jg.d.mts → EndpointFactory-GAL_tuPf.d.mts} +4 -4
- package/dist/EndpointFactory-GAL_tuPf.d.mts.map +1 -0
- package/dist/{EndpointFactory-CYj6BYok.cjs → EndpointFactory-r6jxPvQ8.cjs} +7 -7
- package/dist/EndpointFactory-r6jxPvQ8.cjs.map +1 -0
- package/dist/{Function-BVHqIDp9.mjs → Function-D8tBamM3.mjs} +3 -3
- package/dist/Function-D8tBamM3.mjs.map +1 -0
- package/dist/{Function-DN2G6OT5.d.mts → Function-DBmU3uGI.d.mts} +3 -3
- package/dist/Function-DBmU3uGI.d.mts.map +1 -0
- package/dist/{Function-Cf7f_kCz.d.cts → Function-PNW4HdNE.d.cts} +2 -2
- package/dist/Function-PNW4HdNE.d.cts.map +1 -0
- package/dist/{Function-DDZb1525.cjs → Function-iLKrUXuw.cjs} +3 -3
- package/dist/Function-iLKrUXuw.cjs.map +1 -0
- package/dist/{FunctionBuilder-DswJ-9sD.cjs → FunctionBuilder-BEpPgeho.cjs} +4 -4
- package/dist/FunctionBuilder-BEpPgeho.cjs.map +1 -0
- package/dist/{FunctionBuilder-Cxx8D2na.d.mts → FunctionBuilder-Bv4H2I1a.d.mts} +4 -4
- package/dist/FunctionBuilder-Bv4H2I1a.d.mts.map +1 -0
- package/dist/{FunctionBuilder-CrDYgfiI.mjs → FunctionBuilder-BwNF99AB.mjs} +4 -4
- package/dist/FunctionBuilder-BwNF99AB.mjs.map +1 -0
- package/dist/{FunctionBuilder-CJBzzXL3.d.cts → FunctionBuilder-DCqXIHaq.d.cts} +2 -2
- package/dist/FunctionBuilder-DCqXIHaq.d.cts.map +1 -0
- package/dist/{FunctionExecutionWrapper-CLDh7Z2_.mjs → FunctionExecutionWrapper-B__HE_B-.mjs} +3 -3
- package/dist/FunctionExecutionWrapper-B__HE_B-.mjs.map +1 -0
- package/dist/{FunctionExecutionWrapper-DF260Aaj.d.mts → FunctionExecutionWrapper-BclgIztn.d.cts} +5 -5
- package/dist/FunctionExecutionWrapper-BclgIztn.d.cts.map +1 -0
- package/dist/{FunctionExecutionWrapper-BYI2bGTL.cjs → FunctionExecutionWrapper-BjF6t9Hb.cjs} +3 -3
- package/dist/FunctionExecutionWrapper-BjF6t9Hb.cjs.map +1 -0
- package/dist/{FunctionExecutionWrapper-Qy8bmgFR.d.cts → FunctionExecutionWrapper-Dq21c6vt.d.mts} +5 -5
- package/dist/FunctionExecutionWrapper-Dq21c6vt.d.mts.map +1 -0
- package/dist/HonoEndpointAdaptor-C_ym_Sbr.mjs +251 -0
- package/dist/HonoEndpointAdaptor-C_ym_Sbr.mjs.map +1 -0
- package/dist/HonoEndpointAdaptor-DiQH0eTb.cjs +257 -0
- package/dist/HonoEndpointAdaptor-DiQH0eTb.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-YcRHYALH.d.cts → HonoEndpointAdaptor-Dkkemmbo.d.cts} +10 -5
- package/dist/HonoEndpointAdaptor-Dkkemmbo.d.cts.map +1 -0
- package/dist/{HonoEndpointAdaptor-BaPlUhz0.d.mts → HonoEndpointAdaptor-HukjdF6M.d.mts} +11 -6
- package/dist/HonoEndpointAdaptor-HukjdF6M.d.mts.map +1 -0
- package/dist/{Subscriber-COYMSevD.d.cts → Subscriber--zUjZDR6.d.cts} +1 -1
- package/dist/Subscriber--zUjZDR6.d.cts.map +1 -0
- package/dist/{Subscriber-ikctpU3I.d.mts → Subscriber-0Ac7cXID.d.mts} +2 -2
- package/dist/Subscriber-0Ac7cXID.d.mts.map +1 -0
- package/dist/{Subscriber-BmPf9GFb.mjs → Subscriber-BgZ8T-O2.mjs} +2 -2
- package/dist/Subscriber-BgZ8T-O2.mjs.map +1 -0
- package/dist/{Subscriber-BiHjVXtM.cjs → Subscriber-CoFmHMIM.cjs} +2 -2
- package/dist/Subscriber-CoFmHMIM.cjs.map +1 -0
- package/dist/{SubscriberBuilder-D_9zzllj.d.mts → SubscriberBuilder-D8cmUHee.d.mts} +2 -2
- package/dist/SubscriberBuilder-D8cmUHee.d.mts.map +1 -0
- package/dist/{SubscriberBuilder-DJPEeYDJ.mjs → SubscriberBuilder-DWXWZBPo.mjs} +2 -2
- package/dist/SubscriberBuilder-DWXWZBPo.mjs.map +1 -0
- package/dist/{SubscriberBuilder-ivHAGIVi.d.cts → SubscriberBuilder-DciTqb-7.d.cts} +2 -2
- package/dist/SubscriberBuilder-DciTqb-7.d.cts.map +1 -0
- package/dist/{SubscriberBuilder-Cp1C-xtT.cjs → SubscriberBuilder-JlxhyqGp.cjs} +2 -2
- package/dist/SubscriberBuilder-JlxhyqGp.cjs.map +1 -0
- package/dist/{TestEndpointAdaptor-DB7bREhS.d.mts → TestEndpointAdaptor-Boijwbmz.d.mts} +4 -4
- package/dist/TestEndpointAdaptor-Boijwbmz.d.mts.map +1 -0
- package/dist/{TestEndpointAdaptor-C10xBI--.d.cts → TestEndpointAdaptor-DdwpRyNh.d.cts} +3 -3
- package/dist/TestEndpointAdaptor-DdwpRyNh.d.cts.map +1 -0
- package/dist/TestEndpointAdaptor-Dk75ExxE.cjs +176 -0
- package/dist/TestEndpointAdaptor-Dk75ExxE.cjs.map +1 -0
- package/dist/TestEndpointAdaptor-OiA2JLDp.mjs +170 -0
- package/dist/TestEndpointAdaptor-OiA2JLDp.mjs.map +1 -0
- package/dist/adaptors/aws.cjs +12 -12
- package/dist/adaptors/aws.d.cts +13 -12
- package/dist/adaptors/aws.d.mts +16 -15
- package/dist/adaptors/aws.mjs +12 -12
- package/dist/adaptors/hono.cjs +10 -9
- package/dist/adaptors/hono.d.cts +6 -6
- package/dist/adaptors/hono.d.mts +9 -9
- package/dist/adaptors/hono.mjs +10 -9
- package/dist/adaptors/testing.cjs +8 -7
- package/dist/adaptors/testing.d.cts +6 -6
- package/dist/adaptors/testing.d.mts +9 -9
- package/dist/adaptors/testing.mjs +8 -7
- package/dist/crons/Cron.cjs +6 -6
- package/dist/crons/Cron.d.cts +4 -4
- package/dist/crons/Cron.d.mts +6 -6
- package/dist/crons/Cron.mjs +6 -6
- package/dist/crons/CronBuilder.cjs +7 -7
- package/dist/crons/CronBuilder.d.cts +5 -5
- package/dist/crons/CronBuilder.d.mts +7 -7
- package/dist/crons/CronBuilder.mjs +7 -7
- package/dist/crons/index.cjs +7 -7
- package/dist/crons/index.cjs.map +1 -1
- package/dist/crons/index.d.cts +9 -9
- package/dist/crons/index.d.mts +7 -7
- package/dist/crons/index.mjs +7 -7
- package/dist/crons/index.mjs.map +1 -1
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +7 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +8 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +11 -10
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +7 -7
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +8 -8
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +8 -7
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +11 -10
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.mjs +8 -8
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.cjs +8 -8
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +9 -8
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +12 -11
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +8 -8
- package/dist/endpoints/Authorizer.cjs +1 -1
- package/dist/endpoints/Authorizer.d.cts +1 -1
- package/dist/endpoints/Authorizer.d.mts +1 -1
- package/dist/endpoints/Authorizer.mjs +1 -1
- package/dist/endpoints/Endpoint.cjs +6 -6
- package/dist/endpoints/Endpoint.d.cts +5 -5
- package/dist/endpoints/Endpoint.d.mts +8 -8
- package/dist/endpoints/Endpoint.mjs +6 -6
- package/dist/endpoints/EndpointBuilder.cjs +9 -9
- package/dist/endpoints/EndpointBuilder.d.cts +6 -6
- package/dist/endpoints/EndpointBuilder.d.mts +9 -9
- package/dist/endpoints/EndpointBuilder.mjs +9 -9
- package/dist/endpoints/EndpointFactory.cjs +10 -10
- package/dist/endpoints/EndpointFactory.d.cts +7 -7
- package/dist/endpoints/EndpointFactory.d.mts +10 -10
- package/dist/endpoints/EndpointFactory.mjs +10 -10
- package/dist/endpoints/HonoEndpointAdaptor.cjs +10 -9
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +6 -6
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/HonoEndpointAdaptor.mjs +10 -9
- package/dist/endpoints/TestEndpointAdaptor.cjs +8 -7
- package/dist/endpoints/TestEndpointAdaptor.d.cts +6 -6
- package/dist/endpoints/TestEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/TestEndpointAdaptor.mjs +8 -7
- package/dist/endpoints/audit.d.cts +5 -5
- package/dist/endpoints/audit.d.mts +8 -8
- package/dist/endpoints/helpers.cjs +7 -7
- package/dist/endpoints/helpers.d.cts +5 -5
- package/dist/endpoints/helpers.d.cts.map +1 -1
- package/dist/endpoints/helpers.d.mts +8 -8
- package/dist/endpoints/helpers.d.mts.map +1 -1
- package/dist/endpoints/helpers.mjs +7 -7
- package/dist/endpoints/index.cjs +20 -10
- package/dist/endpoints/index.cjs.map +1 -1
- package/dist/endpoints/index.d.cts +12 -10
- package/dist/endpoints/index.d.cts.map +1 -1
- package/dist/endpoints/index.d.mts +15 -13
- package/dist/endpoints/index.d.mts.map +1 -1
- package/dist/endpoints/index.mjs +13 -11
- package/dist/endpoints/index.mjs.map +1 -1
- package/dist/endpoints/lazyAccessors.cjs +10 -0
- package/dist/endpoints/lazyAccessors.d.cts +10 -0
- package/dist/endpoints/lazyAccessors.d.mts +10 -0
- package/dist/endpoints/lazyAccessors.mjs +3 -0
- package/dist/endpoints/parseHonoQuery.cjs +1 -1
- package/dist/endpoints/parseHonoQuery.mjs +1 -1
- package/dist/endpoints/parseQueryParams.d.cts.map +1 -1
- package/dist/endpoints/parseQueryParams.d.mts.map +1 -1
- package/dist/endpoints/processAudits.d.cts +5 -5
- package/dist/endpoints/processAudits.d.cts.map +1 -1
- package/dist/endpoints/processAudits.d.mts +8 -8
- package/dist/endpoints/processAudits.d.mts.map +1 -1
- package/dist/endpoints/rls.cjs +1 -1
- package/dist/endpoints/rls.d.cts +5 -5
- package/dist/endpoints/rls.d.mts +8 -8
- package/dist/endpoints/rls.mjs +1 -1
- package/dist/functions/AWSLambdaFunction.cjs +6 -6
- package/dist/functions/AWSLambdaFunction.d.cts +3 -3
- package/dist/functions/AWSLambdaFunction.d.mts +4 -4
- package/dist/functions/AWSLambdaFunction.mjs +6 -6
- package/dist/functions/BaseFunctionBuilder.cjs +2 -2
- package/dist/functions/BaseFunctionBuilder.d.mts +2 -2
- package/dist/functions/BaseFunctionBuilder.mjs +2 -2
- package/dist/functions/Function.cjs +2 -2
- package/dist/functions/Function.d.cts +1 -1
- package/dist/functions/Function.d.mts +2 -2
- package/dist/functions/Function.mjs +2 -2
- package/dist/functions/FunctionBuilder.cjs +4 -4
- package/dist/functions/FunctionBuilder.d.cts +2 -2
- package/dist/functions/FunctionBuilder.d.mts +4 -4
- package/dist/functions/FunctionBuilder.mjs +4 -4
- package/dist/functions/FunctionExecutionWrapper.cjs +5 -5
- package/dist/functions/FunctionExecutionWrapper.d.cts +2 -2
- package/dist/functions/FunctionExecutionWrapper.d.mts +3 -3
- package/dist/functions/FunctionExecutionWrapper.mjs +5 -5
- package/dist/functions/TestFunctionAdaptor.cjs +7 -7
- package/dist/functions/TestFunctionAdaptor.cjs.map +1 -1
- package/dist/functions/TestFunctionAdaptor.d.cts +2 -2
- package/dist/functions/TestFunctionAdaptor.d.cts.map +1 -1
- package/dist/functions/TestFunctionAdaptor.d.mts +3 -3
- package/dist/functions/TestFunctionAdaptor.d.mts.map +1 -1
- package/dist/functions/TestFunctionAdaptor.mjs +7 -7
- package/dist/functions/TestFunctionAdaptor.mjs.map +1 -1
- package/dist/functions/index.cjs +5 -5
- package/dist/functions/index.d.cts +3 -3
- package/dist/functions/index.d.mts +5 -5
- package/dist/functions/index.mjs +5 -5
- package/dist/{functions-fTid0RMK.cjs → functions-BkKXVeHm.cjs} +2 -2
- package/dist/functions-BkKXVeHm.cjs.map +1 -0
- package/dist/functions-C3A1vMRW.mjs +8 -0
- package/dist/functions-C3A1vMRW.mjs.map +1 -0
- package/dist/{helpers-BcP1tXAi.cjs → helpers-BelEzV4U.cjs} +2 -2
- package/dist/helpers-BelEzV4U.cjs.map +1 -0
- package/dist/{helpers-ByRTDO_m.mjs → helpers-DgsMFMUV.mjs} +2 -2
- package/dist/helpers-DgsMFMUV.mjs.map +1 -0
- package/dist/{index-BWzGIj06.d.mts → index-CgAQHr3f.d.mts} +2 -2
- package/dist/index-CgAQHr3f.d.mts.map +1 -0
- package/dist/index-D0fp_IK1.d.cts +12 -0
- package/dist/index-D0fp_IK1.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +1 -1
- package/dist/lazyAccessors-B-Jgkg2o.mjs +175 -0
- package/dist/lazyAccessors-B-Jgkg2o.mjs.map +1 -0
- package/dist/lazyAccessors-B2ILzU-j.d.mts +49 -0
- package/dist/lazyAccessors-B2ILzU-j.d.mts.map +1 -0
- package/dist/lazyAccessors-B8Hhras9.cjs +223 -0
- package/dist/lazyAccessors-B8Hhras9.cjs.map +1 -0
- package/dist/lazyAccessors-Bcpi06ed.d.cts +49 -0
- package/dist/lazyAccessors-Bcpi06ed.d.cts.map +1 -0
- package/dist/{parseHonoQuery-CZC5_97v.cjs → parseHonoQuery-D4MhxTRc.cjs} +1 -1
- package/dist/parseHonoQuery-D4MhxTRc.cjs.map +1 -0
- package/dist/{parseHonoQuery-DDgIkTO4.mjs → parseHonoQuery-DpK3sGPc.mjs} +1 -1
- package/dist/parseHonoQuery-DpK3sGPc.mjs.map +1 -0
- package/dist/parseQueryParams-BSNkjmZ9.cjs.map +1 -1
- package/dist/parseQueryParams-UMTRnRrW.mjs.map +1 -1
- package/dist/processAudits-CzHkPokQ.cjs.map +1 -1
- package/dist/processAudits-Dj8UGqcW.mjs.map +1 -1
- package/dist/publisher-Bw4770Hi.mjs.map +1 -1
- package/dist/publisher-C4BhHB5I.d.cts +16 -0
- package/dist/publisher-C4BhHB5I.d.cts.map +1 -0
- package/dist/publisher-NE-GnXL8.d.mts +16 -0
- package/dist/publisher-NE-GnXL8.d.mts.map +1 -0
- package/dist/publisher-lFQleddL.cjs.map +1 -1
- package/dist/publisher.d.cts +3 -16
- package/dist/publisher.d.mts +3 -16
- package/dist/{rls-CmJ7bRsz.cjs → rls-BrywnrQb.cjs} +1 -1
- package/dist/{rls-CmJ7bRsz.cjs.map → rls-BrywnrQb.cjs.map} +1 -1
- package/dist/{rls-Bf3FRwto.mjs → rls-C0cWOnk4.mjs} +1 -1
- package/dist/{rls-Bf3FRwto.mjs.map → rls-C0cWOnk4.mjs.map} +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.cjs +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.cts +2 -2
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +3 -3
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.mjs +1 -1
- package/dist/subscribers/Subscriber.cjs +2 -2
- package/dist/subscribers/Subscriber.d.cts +1 -1
- package/dist/subscribers/Subscriber.d.mts +2 -2
- package/dist/subscribers/Subscriber.mjs +2 -2
- package/dist/subscribers/SubscriberBuilder.cjs +3 -3
- package/dist/subscribers/SubscriberBuilder.d.cts +2 -2
- package/dist/subscribers/SubscriberBuilder.d.mts +3 -3
- package/dist/subscribers/SubscriberBuilder.mjs +3 -3
- package/dist/subscribers/index.cjs +3 -3
- package/dist/subscribers/index.cjs.map +1 -1
- package/dist/subscribers/index.d.cts +4 -4
- package/dist/subscribers/index.d.cts.map +1 -1
- package/dist/subscribers/index.d.mts +3 -3
- package/dist/subscribers/index.d.mts.map +1 -1
- package/dist/subscribers/index.mjs +3 -3
- package/dist/subscribers/index.mjs.map +1 -1
- package/dist/telemetry-BTaiRqPo.d.cts +95 -0
- package/dist/telemetry-BTaiRqPo.d.cts.map +1 -0
- package/dist/telemetry-yAHf5yDs.d.mts +95 -0
- package/dist/telemetry-yAHf5yDs.d.mts.map +1 -0
- package/dist/telemetry.cjs +0 -0
- package/dist/telemetry.d.cts +2 -0
- package/dist/telemetry.d.mts +2 -0
- package/dist/telemetry.mjs +0 -0
- package/dist/types-B5H3piDg.d.cts.map +1 -1
- package/dist/{types-DdIlpxAd.d.mts → types-Dw-iLd3Y.d.mts} +1 -1
- package/dist/types-Dw-iLd3Y.d.mts.map +1 -0
- package/dist/types.d.mts +1 -1
- package/package.json +18 -18
- package/src/Construct.ts +117 -86
- package/src/__benchmarks__/build-time-optimization.bench.ts +274 -0
- package/src/__benchmarks__/endpoint.bench.ts +375 -375
- package/src/__benchmarks__/fixtures.ts +241 -0
- package/src/__benchmarks__/hono-adaptor.bench.ts +533 -0
- package/src/__benchmarks__/hono-server.bench.ts +206 -206
- package/src/__benchmarks__/response-builder.bench.ts +428 -0
- package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +319 -0
- package/src/__benchmarks__/strategies/strategy-c-middleware.ts +530 -0
- package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +567 -0
- package/src/__tests__/Construct.environment.spec.ts +349 -350
- package/src/__tests__/publisher.setting.spec.ts +496 -499
- package/src/__tests__/publisher.spec.ts +440 -442
- package/src/crons/Cron.ts +117 -117
- package/src/crons/CronBuilder.ts +237 -238
- package/src/crons/__tests__/Cron.spec.ts +448 -448
- package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +214 -214
- package/src/crons/index.ts +4 -4
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +571 -463
- package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +86 -86
- package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +85 -81
- package/src/endpoints/Authorizer.ts +100 -100
- package/src/endpoints/Endpoint.ts +921 -937
- package/src/endpoints/EndpointBuilder.ts +703 -703
- package/src/endpoints/EndpointFactory.ts +1054 -1056
- package/src/endpoints/HonoEndpointAdaptor.ts +621 -548
- package/src/endpoints/TestEndpointAdaptor.ts +372 -353
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +499 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +541 -542
- package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +1172 -1174
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +599 -599
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +710 -710
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +280 -280
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +924 -730
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +307 -0
- package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +408 -408
- package/src/endpoints/__tests__/Authorizer.spec.ts +286 -0
- package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +162 -162
- package/src/endpoints/__tests__/Endpoint.headers.spec.ts +182 -182
- package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +158 -159
- package/src/endpoints/__tests__/Endpoint.spec.ts +819 -822
- package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +427 -427
- package/src/endpoints/__tests__/EndpointBuilder.spec.ts +478 -478
- package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +426 -426
- package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +501 -501
- package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +177 -177
- package/src/endpoints/__tests__/EndpointFactory.spec.ts +471 -471
- package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +143 -143
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +663 -663
- package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +608 -608
- package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +561 -561
- package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +1036 -1036
- package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +278 -278
- package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +1093 -1093
- package/src/endpoints/__tests__/ResponseBuilder.spec.ts +230 -230
- package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +569 -569
- package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +841 -841
- package/src/endpoints/__tests__/endpoint-types.test.ts +68 -68
- package/src/endpoints/__tests__/helpers.spec.ts +37 -0
- package/src/endpoints/__tests__/lazyAccessors.spec.ts +330 -0
- package/src/endpoints/__tests__/processAudits.spec.ts +631 -0
- package/src/endpoints/audit.ts +51 -51
- package/src/endpoints/helpers.ts +34 -35
- package/src/endpoints/index.ts +33 -23
- package/src/endpoints/lazyAccessors.ts +241 -0
- package/src/endpoints/parseHonoQuery.ts +41 -41
- package/src/endpoints/parseQueryParams.ts +36 -36
- package/src/endpoints/processAudits.ts +269 -269
- package/src/endpoints/rls.ts +16 -16
- package/src/functions/AWSLambdaFunction.ts +294 -295
- package/src/functions/BaseFunctionBuilder.ts +185 -185
- package/src/functions/Function.ts +190 -190
- package/src/functions/FunctionBuilder.ts +353 -353
- package/src/functions/FunctionExecutionWrapper.ts +199 -200
- package/src/functions/TestFunctionAdaptor.ts +191 -191
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +424 -424
- package/src/functions/__tests__/Function.audits.spec.ts +364 -364
- package/src/functions/__tests__/Function.spec.ts +453 -454
- package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +179 -179
- package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +369 -369
- package/src/functions/index.ts +6 -4
- package/src/index.ts +13 -9
- package/src/publisher.ts +71 -72
- package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +244 -248
- package/src/subscribers/Subscriber.ts +82 -84
- package/src/subscribers/SubscriberBuilder.ts +129 -129
- package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +589 -589
- package/src/subscribers/__tests__/Subscriber.spec.ts +402 -404
- package/src/subscribers/index.ts +1 -0
- package/src/telemetry.ts +103 -0
- package/src/types.ts +7 -7
- package/test.ts +58 -59
- package/dist/AWSLambdaFunction-BdebRMUh.d.mts.map +0 -1
- package/dist/AWSLambdaFunction-C54a1doJ.mjs.map +0 -1
- package/dist/AWSLambdaFunction-D0tEOTXQ.d.cts.map +0 -1
- package/dist/AWSLambdaFunction-EPGY4s7i.cjs.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-BLfO612H.mjs.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-BNcYYZ-P.cjs.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-DrFAvHOp.d.mts.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-Dx-Ks1Jp.d.cts.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-BT9JXihC.mjs.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-DLqnYQ4E.d.cts.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-DNFvvdmW.cjs.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-qlKXuZxy.d.mts.map +0 -1
- package/dist/AmazonApiGatewayV1EndpointAdaptor-CShQI8Gk.mjs.map +0 -1
- package/dist/AmazonApiGatewayV1EndpointAdaptor-Ccl8B8kG.cjs.map +0 -1
- package/dist/AmazonApiGatewayV1EndpointAdaptor-DyUaJIhB.d.cts.map +0 -1
- package/dist/AmazonApiGatewayV1EndpointAdaptor-MRUxs3Xi.d.mts.map +0 -1
- package/dist/AmazonApiGatewayV2EndpointAdaptor-D8-0Aab4.cjs.map +0 -1
- package/dist/AmazonApiGatewayV2EndpointAdaptor-M1-w0U5R.d.cts.map +0 -1
- package/dist/AmazonApiGatewayV2EndpointAdaptor-fuLM6M9k.d.mts.map +0 -1
- package/dist/AmazonApiGatewayV2EndpointAdaptor-lCRzGE4q.mjs.map +0 -1
- package/dist/Authorizer-B-btowNd.d.cts.map +0 -1
- package/dist/Authorizer-C0ge_tc8.cjs.map +0 -1
- package/dist/Authorizer-gWxYsGEp.d.mts.map +0 -1
- package/dist/Authorizer-r9U3y_ms.mjs.map +0 -1
- package/dist/BaseFunctionBuilder-Czi1Jwza.mjs.map +0 -1
- package/dist/BaseFunctionBuilder-DRY419e7.d.mts.map +0 -1
- package/dist/BaseFunctionBuilder-MYG3C9ug.cjs.map +0 -1
- package/dist/Construct-Ba5cMxib.cjs.map +0 -1
- package/dist/Construct-DdyGHuag.mjs.map +0 -1
- package/dist/Construct-XrijZFFh.d.mts.map +0 -1
- package/dist/Cron-BxhGs5up.mjs.map +0 -1
- package/dist/Cron-CGF4YAfM.cjs.map +0 -1
- package/dist/Cron-bDLcTvV5.d.cts.map +0 -1
- package/dist/Cron-cdjlSKNp.d.mts.map +0 -1
- package/dist/CronBuilder-BC4m5-p1.d.mts.map +0 -1
- package/dist/CronBuilder-CcxKRtVP.cjs.map +0 -1
- package/dist/CronBuilder-DKVXyE0Q.d.cts.map +0 -1
- package/dist/CronBuilder-d2jh-IB2.mjs.map +0 -1
- package/dist/Endpoint-BPv9_-m_.d.cts.map +0 -1
- package/dist/Endpoint-BVGZXFyV.cjs.map +0 -1
- package/dist/Endpoint-BdwG75G_.d.mts.map +0 -1
- package/dist/Endpoint-CuOEswxJ.mjs.map +0 -1
- package/dist/EndpointBuilder-B3az942t.d.mts.map +0 -1
- package/dist/EndpointBuilder-Cgj1P_ra.cjs.map +0 -1
- package/dist/EndpointBuilder-DIy_m1bu.d.cts.map +0 -1
- package/dist/EndpointBuilder-DnCB1h1j.mjs.map +0 -1
- package/dist/EndpointFactory-C-0nE6Jg.d.mts.map +0 -1
- package/dist/EndpointFactory-CYj6BYok.cjs.map +0 -1
- package/dist/EndpointFactory-CbdxPCIH.mjs.map +0 -1
- package/dist/EndpointFactory-CyPbm3AD.d.cts.map +0 -1
- package/dist/Function-BVHqIDp9.mjs.map +0 -1
- package/dist/Function-Cf7f_kCz.d.cts.map +0 -1
- package/dist/Function-DDZb1525.cjs.map +0 -1
- package/dist/Function-DN2G6OT5.d.mts.map +0 -1
- package/dist/FunctionBuilder-CJBzzXL3.d.cts.map +0 -1
- package/dist/FunctionBuilder-CrDYgfiI.mjs.map +0 -1
- package/dist/FunctionBuilder-Cxx8D2na.d.mts.map +0 -1
- package/dist/FunctionBuilder-DswJ-9sD.cjs.map +0 -1
- package/dist/FunctionExecutionWrapper-BYI2bGTL.cjs.map +0 -1
- package/dist/FunctionExecutionWrapper-CLDh7Z2_.mjs.map +0 -1
- package/dist/FunctionExecutionWrapper-DF260Aaj.d.mts.map +0 -1
- package/dist/FunctionExecutionWrapper-Qy8bmgFR.d.cts.map +0 -1
- package/dist/HonoEndpointAdaptor-BaPlUhz0.d.mts.map +0 -1
- package/dist/HonoEndpointAdaptor-CQe2FqMR.cjs +0 -234
- package/dist/HonoEndpointAdaptor-CQe2FqMR.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-Ce-2HBxn.mjs +0 -228
- package/dist/HonoEndpointAdaptor-Ce-2HBxn.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-YcRHYALH.d.cts.map +0 -1
- package/dist/Subscriber-BiHjVXtM.cjs.map +0 -1
- package/dist/Subscriber-BmPf9GFb.mjs.map +0 -1
- package/dist/Subscriber-COYMSevD.d.cts.map +0 -1
- package/dist/Subscriber-ikctpU3I.d.mts.map +0 -1
- package/dist/SubscriberBuilder-Cp1C-xtT.cjs.map +0 -1
- package/dist/SubscriberBuilder-DJPEeYDJ.mjs.map +0 -1
- package/dist/SubscriberBuilder-D_9zzllj.d.mts.map +0 -1
- package/dist/SubscriberBuilder-ivHAGIVi.d.cts.map +0 -1
- package/dist/TestEndpointAdaptor-C10xBI--.d.cts.map +0 -1
- package/dist/TestEndpointAdaptor-DB7bREhS.d.mts.map +0 -1
- package/dist/TestEndpointAdaptor-DJgik2Wj.mjs +0 -160
- package/dist/TestEndpointAdaptor-DJgik2Wj.mjs.map +0 -1
- package/dist/TestEndpointAdaptor-ZbtQiuHE.cjs +0 -166
- package/dist/TestEndpointAdaptor-ZbtQiuHE.cjs.map +0 -1
- package/dist/functions-C6EK1xL6.mjs +0 -8
- package/dist/functions-C6EK1xL6.mjs.map +0 -1
- package/dist/functions-fTid0RMK.cjs.map +0 -1
- package/dist/helpers-BcP1tXAi.cjs.map +0 -1
- package/dist/helpers-ByRTDO_m.mjs.map +0 -1
- package/dist/index-BWzGIj06.d.mts.map +0 -1
- package/dist/index-DmFozqLd.d.cts +0 -12
- package/dist/index-DmFozqLd.d.cts.map +0 -1
- package/dist/parseHonoQuery-CZC5_97v.cjs.map +0 -1
- package/dist/parseHonoQuery-DDgIkTO4.mjs.map +0 -1
- package/dist/publisher.d.cts.map +0 -1
- package/dist/publisher.d.mts.map +0 -1
- package/dist/types-DdIlpxAd.d.mts.map +0 -1
|
@@ -1,1196 +1,1194 @@
|
|
|
1
1
|
import { EnvironmentParser } from '@geekmidas/envkit';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
BadRequestError,
|
|
4
|
+
ConflictError,
|
|
5
|
+
HttpError,
|
|
6
|
+
InternalServerError,
|
|
7
|
+
NotFoundError,
|
|
8
|
+
UnauthorizedError,
|
|
9
9
|
} from '@geekmidas/errors';
|
|
10
10
|
import type { Logger } from '@geekmidas/logger';
|
|
11
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
12
|
-
import { z } from 'zod';
|
|
13
|
-
import { Endpoint } from '../Endpoint';
|
|
14
|
-
|
|
15
11
|
import { createMockContext, createMockV1Event } from '@geekmidas/testkit/aws';
|
|
16
|
-
|
|
17
12
|
import { createMockLogger } from '@geekmidas/testkit/logger';
|
|
13
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
14
|
+
import { z } from 'zod';
|
|
18
15
|
import { AmazonApiGatewayV1Endpoint } from '../AmazonApiGatewayV1EndpointAdaptor';
|
|
16
|
+
import { Endpoint } from '../Endpoint';
|
|
19
17
|
/**
|
|
20
18
|
* Common test event types for AWS adapter testing
|
|
21
19
|
*/
|
|
22
20
|
export type TestEvent =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
| { type: 'user.created'; payload: { userId: string; email: string } }
|
|
22
|
+
| { type: 'user.updated'; payload: { userId: string; changes: string[] } }
|
|
23
|
+
| { type: 'notification.sent'; payload: { userId: string; type: string } };
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
26
|
* Mock service for testing
|
|
29
27
|
*/
|
|
30
28
|
export const TestService = {
|
|
31
|
-
|
|
29
|
+
serviceName: 'TestService' as const,
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
async register() {
|
|
32
|
+
return this;
|
|
33
|
+
},
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
async cleanup() {},
|
|
38
36
|
};
|
|
39
37
|
|
|
40
38
|
describe('AmazonApiGatewayV1Endpoint', () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
39
|
+
let mockLogger: Logger;
|
|
40
|
+
let envParser: EnvironmentParser<{}>;
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
vi.clearAllMocks();
|
|
44
|
+
mockLogger = createMockLogger();
|
|
45
|
+
envParser = new EnvironmentParser({});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('handler', () => {
|
|
49
|
+
it('should handle a simple GET request', async () => {
|
|
50
|
+
const endpoint = new Endpoint({
|
|
51
|
+
route: '/test',
|
|
52
|
+
method: 'GET',
|
|
53
|
+
fn: async () => ({ message: 'Hello, World!' }),
|
|
54
|
+
input: {},
|
|
55
|
+
output: z.object({ message: z.string() }),
|
|
56
|
+
services: [],
|
|
57
|
+
logger: mockLogger,
|
|
58
|
+
timeout: undefined,
|
|
59
|
+
memorySize: undefined,
|
|
60
|
+
status: undefined,
|
|
61
|
+
getSession: undefined,
|
|
62
|
+
authorize: undefined,
|
|
63
|
+
description: 'Test endpoint',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
67
|
+
const handler = adapter.handler;
|
|
68
|
+
|
|
69
|
+
const event = createMockV1Event();
|
|
70
|
+
const context = createMockContext();
|
|
71
|
+
const response = await handler(event, context);
|
|
72
|
+
|
|
73
|
+
expect(response.statusCode).toBe(200);
|
|
74
|
+
expect(response.body).toBe(JSON.stringify({ message: 'Hello, World!' }));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should handle POST request with body', async () => {
|
|
78
|
+
const inputSchema = z.object({ name: z.string() });
|
|
79
|
+
const outputSchema = z.object({ id: z.string(), name: z.string() });
|
|
80
|
+
|
|
81
|
+
const endpoint = new Endpoint({
|
|
82
|
+
route: '/users',
|
|
83
|
+
method: 'POST',
|
|
84
|
+
fn: async ({ body }) => ({ id: '123', name: body.name }),
|
|
85
|
+
input: { body: inputSchema },
|
|
86
|
+
output: outputSchema,
|
|
87
|
+
services: [],
|
|
88
|
+
logger: mockLogger,
|
|
89
|
+
timeout: undefined,
|
|
90
|
+
memorySize: undefined,
|
|
91
|
+
status: 201,
|
|
92
|
+
getSession: undefined,
|
|
93
|
+
authorize: undefined,
|
|
94
|
+
description: 'Create user endpoint',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
98
|
+
const handler = adapter.handler;
|
|
99
|
+
|
|
100
|
+
const event = createMockV1Event({
|
|
101
|
+
httpMethod: 'POST',
|
|
102
|
+
body: JSON.stringify({ name: 'John Doe' }),
|
|
103
|
+
});
|
|
104
|
+
const context = createMockContext();
|
|
105
|
+
const response = await handler(event, context);
|
|
106
|
+
|
|
107
|
+
expect(response.statusCode).toBe(201);
|
|
108
|
+
expect(response.body).toBe(
|
|
109
|
+
JSON.stringify({ id: '123', name: 'John Doe' }),
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should handle query parameters', async () => {
|
|
114
|
+
const querySchema = z.object({ page: z.string().transform(Number) });
|
|
115
|
+
const outputSchema = z.object({
|
|
116
|
+
page: z.number(),
|
|
117
|
+
items: z.array(z.string()),
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const endpoint = new Endpoint({
|
|
121
|
+
route: '/items',
|
|
122
|
+
method: 'GET',
|
|
123
|
+
fn: async ({ query }) => ({
|
|
124
|
+
page: query.page,
|
|
125
|
+
items: ['item1', 'item2'],
|
|
126
|
+
}),
|
|
127
|
+
input: { query: querySchema },
|
|
128
|
+
output: outputSchema,
|
|
129
|
+
services: [],
|
|
130
|
+
logger: mockLogger,
|
|
131
|
+
timeout: undefined,
|
|
132
|
+
memorySize: undefined,
|
|
133
|
+
status: undefined,
|
|
134
|
+
getSession: undefined,
|
|
135
|
+
authorize: undefined,
|
|
136
|
+
description: 'List items endpoint',
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
140
|
+
const handler = adapter.handler;
|
|
141
|
+
|
|
142
|
+
const event = createMockV1Event({
|
|
143
|
+
queryStringParameters: { page: '2' },
|
|
144
|
+
});
|
|
145
|
+
const context = createMockContext();
|
|
146
|
+
const response = await handler(event, context);
|
|
147
|
+
|
|
148
|
+
expect(response.statusCode).toBe(200);
|
|
149
|
+
expect(response.body).toBe(
|
|
150
|
+
JSON.stringify({ page: 2, items: ['item1', 'item2'] }),
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('should handle path parameters', async () => {
|
|
155
|
+
const paramsSchema = z.object({ id: z.string() });
|
|
156
|
+
const outputSchema = z.object({ id: z.string(), name: z.string() });
|
|
157
|
+
|
|
158
|
+
const endpoint = new Endpoint({
|
|
159
|
+
route: '/users/:id',
|
|
160
|
+
method: 'GET',
|
|
161
|
+
fn: async ({ params }) => ({ id: params.id, name: 'John Doe' }),
|
|
162
|
+
input: { params: paramsSchema },
|
|
163
|
+
output: outputSchema,
|
|
164
|
+
services: [],
|
|
165
|
+
logger: mockLogger,
|
|
166
|
+
timeout: undefined,
|
|
167
|
+
memorySize: undefined,
|
|
168
|
+
status: undefined,
|
|
169
|
+
getSession: undefined,
|
|
170
|
+
authorize: undefined,
|
|
171
|
+
description: 'Get user endpoint',
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
175
|
+
const handler = adapter.handler;
|
|
176
|
+
|
|
177
|
+
const event = createMockV1Event({
|
|
178
|
+
pathParameters: { id: '123' },
|
|
179
|
+
});
|
|
180
|
+
const context = createMockContext();
|
|
181
|
+
const response = await handler(event, context);
|
|
182
|
+
|
|
183
|
+
expect(response.statusCode).toBe(200);
|
|
184
|
+
expect(response.body).toBe(
|
|
185
|
+
JSON.stringify({ id: '123', name: 'John Doe' }),
|
|
186
|
+
);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should handle endpoint without output', async () => {
|
|
190
|
+
const endpoint = new Endpoint({
|
|
191
|
+
route: '/void',
|
|
192
|
+
method: 'POST',
|
|
193
|
+
fn: async () => {},
|
|
194
|
+
input: {},
|
|
195
|
+
output: undefined,
|
|
196
|
+
services: [],
|
|
197
|
+
logger: mockLogger,
|
|
198
|
+
timeout: undefined,
|
|
199
|
+
memorySize: undefined,
|
|
200
|
+
status: 204,
|
|
201
|
+
getSession: undefined,
|
|
202
|
+
authorize: undefined,
|
|
203
|
+
description: 'Void endpoint',
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
207
|
+
const handler = adapter.handler;
|
|
208
|
+
|
|
209
|
+
const event = createMockV1Event({ httpMethod: 'POST' });
|
|
210
|
+
const context = createMockContext();
|
|
211
|
+
const response = await handler(event, context);
|
|
212
|
+
|
|
213
|
+
expect(response.statusCode).toBe(204);
|
|
214
|
+
expect(response.body).toBeUndefined();
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
describe('middleware', () => {
|
|
219
|
+
it('should inject logger with context', async () => {
|
|
220
|
+
const endpoint = new Endpoint({
|
|
221
|
+
route: '/test',
|
|
222
|
+
method: 'GET',
|
|
223
|
+
fn: async ({ logger }) => {
|
|
224
|
+
logger.info('Test log');
|
|
225
|
+
return { success: true };
|
|
226
|
+
},
|
|
227
|
+
input: {},
|
|
228
|
+
output: z.object({ success: z.boolean() }),
|
|
229
|
+
services: [],
|
|
230
|
+
logger: mockLogger,
|
|
231
|
+
timeout: undefined,
|
|
232
|
+
memorySize: undefined,
|
|
233
|
+
status: undefined,
|
|
234
|
+
getSession: undefined,
|
|
235
|
+
authorize: undefined,
|
|
236
|
+
description: 'Logger test endpoint',
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
240
|
+
const handler = adapter.handler;
|
|
241
|
+
|
|
242
|
+
const event = createMockV1Event();
|
|
243
|
+
const context = createMockContext();
|
|
244
|
+
await handler(event, context);
|
|
245
|
+
|
|
246
|
+
expect(mockLogger.child).toHaveBeenCalledWith({
|
|
247
|
+
route: '/test',
|
|
248
|
+
host: 'test.example.com',
|
|
249
|
+
method: 'GET',
|
|
250
|
+
fn: {
|
|
251
|
+
name: 'test-function',
|
|
252
|
+
version: '1',
|
|
253
|
+
},
|
|
254
|
+
req: {
|
|
255
|
+
ip: expect.any(String),
|
|
256
|
+
awsRequestId: 'test-request-id',
|
|
257
|
+
id: 'request-id',
|
|
258
|
+
userAgent: 'test-agent',
|
|
259
|
+
path: '/test',
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('should handle errors and wrap them', async () => {
|
|
265
|
+
const endpoint = new Endpoint({
|
|
266
|
+
route: '/error',
|
|
267
|
+
method: 'GET',
|
|
268
|
+
fn: async () => {
|
|
269
|
+
throw new Error('Test error');
|
|
270
|
+
},
|
|
271
|
+
input: {},
|
|
272
|
+
output: z.object({ message: z.string() }),
|
|
273
|
+
services: [],
|
|
274
|
+
logger: mockLogger,
|
|
275
|
+
timeout: undefined,
|
|
276
|
+
memorySize: undefined,
|
|
277
|
+
status: undefined,
|
|
278
|
+
getSession: undefined,
|
|
279
|
+
authorize: undefined,
|
|
280
|
+
description: 'Error test endpoint',
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
284
|
+
const handler = adapter.handler;
|
|
285
|
+
|
|
286
|
+
const event = createMockV1Event();
|
|
287
|
+
const context = createMockContext();
|
|
288
|
+
|
|
289
|
+
const response = await handler(event, context);
|
|
290
|
+
|
|
291
|
+
expect(response.statusCode).toBe(500);
|
|
292
|
+
const body = JSON.parse(response.body!);
|
|
293
|
+
expect(body).toMatchObject({
|
|
294
|
+
message: 'An unknown error occurred',
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
expect(mockLogger.error).toHaveBeenCalled();
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it('should register services', async () => {
|
|
301
|
+
const endpoint = new Endpoint({
|
|
302
|
+
route: '/with-service',
|
|
303
|
+
method: 'GET',
|
|
304
|
+
fn: async ({ services }) => {
|
|
305
|
+
const testService = await services.TestService;
|
|
306
|
+
return { hasService: !!testService };
|
|
307
|
+
},
|
|
308
|
+
input: {},
|
|
309
|
+
output: z.object({ hasService: z.boolean() }),
|
|
310
|
+
services: [TestService],
|
|
311
|
+
logger: mockLogger,
|
|
312
|
+
timeout: undefined,
|
|
313
|
+
memorySize: undefined,
|
|
314
|
+
status: undefined,
|
|
315
|
+
getSession: undefined,
|
|
316
|
+
authorize: undefined,
|
|
317
|
+
description: 'Service test endpoint',
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
321
|
+
const handler = adapter.handler.bind(adapter);
|
|
322
|
+
|
|
323
|
+
const event = createMockV1Event();
|
|
324
|
+
const context = createMockContext();
|
|
325
|
+
const response = await handler(event, context);
|
|
326
|
+
|
|
327
|
+
expect(response.statusCode).toBe(200);
|
|
328
|
+
expect(response.body).toBe(JSON.stringify({ hasService: true }));
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('should handle session', async () => {
|
|
332
|
+
const mockSession = { userId: 'user-123', role: 'admin' };
|
|
333
|
+
|
|
334
|
+
const endpoint = new Endpoint({
|
|
335
|
+
route: '/with-session',
|
|
336
|
+
method: 'GET',
|
|
337
|
+
fn: async ({ session }) => ({ session }),
|
|
338
|
+
input: {},
|
|
339
|
+
output: z.object({ session: z.any() }),
|
|
340
|
+
services: [],
|
|
341
|
+
logger: mockLogger,
|
|
342
|
+
timeout: undefined,
|
|
343
|
+
memorySize: undefined,
|
|
344
|
+
status: undefined,
|
|
345
|
+
getSession: async () => mockSession,
|
|
346
|
+
authorize: undefined,
|
|
347
|
+
description: 'Session test endpoint',
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
351
|
+
const handler = adapter.handler;
|
|
352
|
+
|
|
353
|
+
const event = createMockV1Event();
|
|
354
|
+
const context = createMockContext();
|
|
355
|
+
const response = await handler(event, context);
|
|
356
|
+
|
|
357
|
+
expect(response.statusCode).toBe(200);
|
|
358
|
+
// Session is currently hardcoded as empty object in the implementation
|
|
359
|
+
expect(response.body).toBe(JSON.stringify({ session: mockSession }));
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
describe('error handling', () => {
|
|
364
|
+
it('should return correct status code for HttpError', async () => {
|
|
365
|
+
const endpoint = new Endpoint({
|
|
366
|
+
route: '/http-error',
|
|
367
|
+
method: 'GET',
|
|
368
|
+
fn: async () => {
|
|
369
|
+
throw new HttpError(403, 'Forbidden', { code: 'FORBIDDEN_ACCESS' });
|
|
370
|
+
},
|
|
371
|
+
input: {},
|
|
372
|
+
output: z.object({ message: z.string() }),
|
|
373
|
+
services: [],
|
|
374
|
+
logger: mockLogger,
|
|
375
|
+
timeout: undefined,
|
|
376
|
+
memorySize: undefined,
|
|
377
|
+
status: undefined,
|
|
378
|
+
getSession: undefined,
|
|
379
|
+
authorize: undefined,
|
|
380
|
+
description: 'HTTP error test endpoint',
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
384
|
+
const handler = adapter.handler;
|
|
385
|
+
|
|
386
|
+
const event = createMockV1Event();
|
|
387
|
+
const context = createMockContext();
|
|
388
|
+
|
|
389
|
+
const response = await handler(event, context);
|
|
390
|
+
|
|
391
|
+
expect(response.statusCode).toBe(403);
|
|
392
|
+
expect(response.body).toBe(
|
|
393
|
+
JSON.stringify({
|
|
394
|
+
message: 'Forbidden',
|
|
395
|
+
code: 'FORBIDDEN_ACCESS',
|
|
396
|
+
}),
|
|
397
|
+
);
|
|
398
|
+
expect(mockLogger.error).toHaveBeenCalled();
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it('should return 500 for non-HttpError errors', async () => {
|
|
402
|
+
const endpoint = new Endpoint({
|
|
403
|
+
route: '/generic-error',
|
|
404
|
+
method: 'GET',
|
|
405
|
+
fn: async () => {
|
|
406
|
+
throw new TypeError('Type mismatch');
|
|
407
|
+
},
|
|
408
|
+
input: {},
|
|
409
|
+
output: z.object({ message: z.string() }),
|
|
410
|
+
services: [],
|
|
411
|
+
logger: mockLogger,
|
|
412
|
+
timeout: undefined,
|
|
413
|
+
memorySize: undefined,
|
|
414
|
+
status: undefined,
|
|
415
|
+
getSession: undefined,
|
|
416
|
+
authorize: undefined,
|
|
417
|
+
description: 'Generic error test endpoint',
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
421
|
+
const handler = adapter.handler;
|
|
422
|
+
|
|
423
|
+
const event = createMockV1Event();
|
|
424
|
+
const context = createMockContext();
|
|
425
|
+
|
|
426
|
+
const response = await handler(event, context);
|
|
427
|
+
|
|
428
|
+
expect(response.statusCode).toBe(500);
|
|
429
|
+
const body = JSON.parse(response.body!);
|
|
430
|
+
expect(body).toMatchObject({
|
|
431
|
+
message: 'An unknown error occurred',
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
expect(mockLogger.error).toHaveBeenCalled();
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it('should preserve status codes for various HttpError subclasses', async () => {
|
|
438
|
+
const testCases = [
|
|
439
|
+
{
|
|
440
|
+
ErrorClass: UnauthorizedError,
|
|
441
|
+
statusCode: 401,
|
|
442
|
+
message: 'Unauthorized',
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
ErrorClass: BadRequestError,
|
|
446
|
+
statusCode: 400,
|
|
447
|
+
message: 'Bad Request',
|
|
448
|
+
},
|
|
449
|
+
{ ErrorClass: NotFoundError, statusCode: 404, message: 'Not Found' },
|
|
450
|
+
{ ErrorClass: ConflictError, statusCode: 409, message: 'Conflict' },
|
|
451
|
+
{
|
|
452
|
+
ErrorClass: InternalServerError,
|
|
453
|
+
statusCode: 500,
|
|
454
|
+
message: 'Internal Server Error',
|
|
455
|
+
},
|
|
456
|
+
];
|
|
457
|
+
|
|
458
|
+
for (const { ErrorClass, statusCode, message } of testCases) {
|
|
459
|
+
const endpoint = new Endpoint({
|
|
460
|
+
route: `/error-${statusCode}`,
|
|
461
|
+
method: 'GET',
|
|
462
|
+
fn: async () => {
|
|
463
|
+
throw new ErrorClass(message);
|
|
464
|
+
},
|
|
465
|
+
input: {},
|
|
466
|
+
output: z.object({ message: z.string() }),
|
|
467
|
+
services: [],
|
|
468
|
+
logger: mockLogger,
|
|
469
|
+
timeout: undefined,
|
|
470
|
+
memorySize: undefined,
|
|
471
|
+
status: undefined,
|
|
472
|
+
getSession: undefined,
|
|
473
|
+
authorize: undefined,
|
|
474
|
+
description: `${statusCode} error test endpoint`,
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
478
|
+
const handler = adapter.handler;
|
|
479
|
+
|
|
480
|
+
const event = createMockV1Event();
|
|
481
|
+
const context = createMockContext();
|
|
482
|
+
|
|
483
|
+
const response = await handler(event, context);
|
|
484
|
+
|
|
485
|
+
expect(response.statusCode).toBe(statusCode);
|
|
486
|
+
expect(response.body).toBe(
|
|
487
|
+
JSON.stringify({
|
|
488
|
+
message,
|
|
489
|
+
code: undefined,
|
|
490
|
+
}),
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
it('should return 422 for body validation errors', async () => {
|
|
496
|
+
const bodySchema = z.object({
|
|
497
|
+
name: z.string().min(3),
|
|
498
|
+
age: z.number().positive(),
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
const endpoint = new Endpoint({
|
|
502
|
+
route: '/validation',
|
|
503
|
+
method: 'POST',
|
|
504
|
+
fn: async () => ({ success: true }),
|
|
505
|
+
input: { body: bodySchema },
|
|
506
|
+
output: z.object({ success: z.boolean() }),
|
|
507
|
+
services: [],
|
|
508
|
+
logger: mockLogger,
|
|
509
|
+
timeout: undefined,
|
|
510
|
+
memorySize: undefined,
|
|
511
|
+
status: undefined,
|
|
512
|
+
getSession: undefined,
|
|
513
|
+
authorize: undefined,
|
|
514
|
+
description: 'Validation test endpoint',
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
518
|
+
const handler = adapter.handler;
|
|
519
|
+
|
|
520
|
+
const event = createMockV1Event({
|
|
521
|
+
httpMethod: 'POST',
|
|
522
|
+
body: JSON.stringify({ name: 'Jo', age: -5 }), // Invalid: name too short, age negative
|
|
523
|
+
});
|
|
524
|
+
const context = createMockContext();
|
|
525
|
+
|
|
526
|
+
const response = await handler(event, context);
|
|
527
|
+
|
|
528
|
+
expect(response.statusCode).toBe(422);
|
|
529
|
+
const body = JSON.parse(response.body!);
|
|
530
|
+
expect(body.message).toBe('Validation failed');
|
|
531
|
+
expect(body.code).toBeUndefined();
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
it('should return 422 for query validation errors', async () => {
|
|
535
|
+
const querySchema = z.object({
|
|
536
|
+
page: z.string().transform(Number).pipe(z.number().positive()),
|
|
537
|
+
limit: z.string().transform(Number).pipe(z.number().max(100)),
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
const endpoint = new Endpoint({
|
|
541
|
+
route: '/items',
|
|
542
|
+
method: 'GET',
|
|
543
|
+
fn: async () => ({ items: [] }),
|
|
544
|
+
input: { query: querySchema },
|
|
545
|
+
output: z.object({ items: z.array(z.any()) }),
|
|
546
|
+
services: [],
|
|
547
|
+
logger: mockLogger,
|
|
548
|
+
timeout: undefined,
|
|
549
|
+
memorySize: undefined,
|
|
550
|
+
status: undefined,
|
|
551
|
+
getSession: undefined,
|
|
552
|
+
authorize: undefined,
|
|
553
|
+
description: 'Query validation test endpoint',
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
557
|
+
const handler = adapter.handler;
|
|
558
|
+
|
|
559
|
+
const event = createMockV1Event({
|
|
560
|
+
queryStringParameters: { page: '0', limit: '200' }, // Invalid: page not positive, limit too high
|
|
561
|
+
});
|
|
562
|
+
const context = createMockContext();
|
|
563
|
+
|
|
564
|
+
const response = await handler(event, context);
|
|
565
|
+
|
|
566
|
+
expect(response.statusCode).toBe(422);
|
|
567
|
+
const body = JSON.parse(response.body!);
|
|
568
|
+
expect(body.message).toBe('Validation failed');
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
it('should return 422 for params validation errors', async () => {
|
|
572
|
+
const paramsSchema = z.object({
|
|
573
|
+
id: z.string().uuid(),
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
const endpoint = new Endpoint({
|
|
577
|
+
route: '/users/:id',
|
|
578
|
+
method: 'GET',
|
|
579
|
+
fn: async ({ params }) => ({ id: params.id }),
|
|
580
|
+
input: { params: paramsSchema },
|
|
581
|
+
output: z.object({ id: z.string() }),
|
|
582
|
+
services: [],
|
|
583
|
+
logger: mockLogger,
|
|
584
|
+
timeout: undefined,
|
|
585
|
+
memorySize: undefined,
|
|
586
|
+
status: undefined,
|
|
587
|
+
getSession: undefined,
|
|
588
|
+
authorize: undefined,
|
|
589
|
+
description: 'Params validation test endpoint',
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
593
|
+
const handler = adapter.handler;
|
|
594
|
+
|
|
595
|
+
const event = createMockV1Event({
|
|
596
|
+
pathParameters: { id: 'not-a-uuid' }, // Invalid: not a valid UUID
|
|
597
|
+
});
|
|
598
|
+
const context = createMockContext();
|
|
599
|
+
|
|
600
|
+
const response = await handler(event, context);
|
|
601
|
+
|
|
602
|
+
expect(response.statusCode).toBe(422);
|
|
603
|
+
const body = JSON.parse(response.body!);
|
|
604
|
+
expect(body.message).toBe('Validation failed');
|
|
605
|
+
});
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
describe('header handling', () => {
|
|
609
|
+
it('should provide header function to handler', async () => {
|
|
610
|
+
const endpoint = new Endpoint({
|
|
611
|
+
route: '/headers',
|
|
612
|
+
method: 'GET',
|
|
613
|
+
fn: async ({ header }) => ({
|
|
614
|
+
authorization: header('authorization'),
|
|
615
|
+
contentType: header('content-type'),
|
|
616
|
+
}),
|
|
617
|
+
input: {},
|
|
618
|
+
output: z.object({
|
|
619
|
+
authorization: z.string().optional(),
|
|
620
|
+
contentType: z.string().optional(),
|
|
621
|
+
}),
|
|
622
|
+
services: [],
|
|
623
|
+
logger: mockLogger,
|
|
624
|
+
timeout: undefined,
|
|
625
|
+
memorySize: undefined,
|
|
626
|
+
status: undefined,
|
|
627
|
+
getSession: undefined,
|
|
628
|
+
authorize: undefined,
|
|
629
|
+
description: 'Header test endpoint',
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
633
|
+
const handler = adapter.handler;
|
|
634
|
+
|
|
635
|
+
const event = createMockV1Event({
|
|
636
|
+
headers: {
|
|
637
|
+
'content-type': 'application/json',
|
|
638
|
+
authorization: 'Bearer token123',
|
|
639
|
+
},
|
|
640
|
+
});
|
|
641
|
+
const context = createMockContext();
|
|
642
|
+
const response = await handler(event, context);
|
|
643
|
+
|
|
644
|
+
expect(response.statusCode).toBe(200);
|
|
645
|
+
expect(response.body).toBe(
|
|
646
|
+
JSON.stringify({
|
|
647
|
+
authorization: 'Bearer token123',
|
|
648
|
+
contentType: 'application/json',
|
|
649
|
+
}),
|
|
650
|
+
);
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
describe('authorization', () => {
|
|
655
|
+
it('should allow requests when authorize returns true', async () => {
|
|
656
|
+
const endpoint = new Endpoint({
|
|
657
|
+
route: '/protected',
|
|
658
|
+
method: 'GET',
|
|
659
|
+
fn: async () => ({ success: true }),
|
|
660
|
+
input: {},
|
|
661
|
+
output: z.object({ success: z.boolean() }),
|
|
662
|
+
services: [],
|
|
663
|
+
logger: mockLogger,
|
|
664
|
+
timeout: undefined,
|
|
665
|
+
memorySize: undefined,
|
|
666
|
+
status: undefined,
|
|
667
|
+
getSession: undefined,
|
|
668
|
+
authorize: undefined,
|
|
669
|
+
description: 'Protected endpoint',
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
// Set authorize function that returns true
|
|
673
|
+
endpoint.authorize = async () => true;
|
|
674
|
+
|
|
675
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
676
|
+
const handler = adapter.handler;
|
|
677
|
+
|
|
678
|
+
const event = createMockV1Event();
|
|
679
|
+
const context = createMockContext();
|
|
680
|
+
const response = await handler(event, context);
|
|
681
|
+
|
|
682
|
+
expect(response.statusCode).toBe(200);
|
|
683
|
+
expect(response.body).toBe(JSON.stringify({ success: true }));
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
it('should reject requests when authorize returns false', async () => {
|
|
687
|
+
const endpoint = new Endpoint({
|
|
688
|
+
route: '/protected',
|
|
689
|
+
method: 'GET',
|
|
690
|
+
fn: async () => ({ success: true }),
|
|
691
|
+
input: {},
|
|
692
|
+
output: z.object({ success: z.boolean() }),
|
|
693
|
+
services: [],
|
|
694
|
+
logger: mockLogger,
|
|
695
|
+
timeout: undefined,
|
|
696
|
+
memorySize: undefined,
|
|
697
|
+
status: undefined,
|
|
698
|
+
getSession: undefined,
|
|
699
|
+
authorize: undefined,
|
|
700
|
+
description: 'Protected endpoint',
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
// Set authorize function that returns false
|
|
704
|
+
endpoint.authorize = async () => false;
|
|
705
|
+
|
|
706
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
707
|
+
const handler = adapter.handler;
|
|
708
|
+
|
|
709
|
+
const event = createMockV1Event();
|
|
710
|
+
const context = createMockContext();
|
|
711
|
+
|
|
712
|
+
const response = await handler(event, context);
|
|
713
|
+
|
|
714
|
+
expect(response.statusCode).toBe(401);
|
|
715
|
+
const body = JSON.parse(response.body!);
|
|
716
|
+
expect(body).toMatchObject({
|
|
717
|
+
message: 'Unauthorized access to the endpoint',
|
|
718
|
+
});
|
|
719
|
+
expect(mockLogger.warn).toHaveBeenCalledWith(
|
|
720
|
+
'Unauthorized access attempt',
|
|
721
|
+
);
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
it('should handle async authorize functions', async () => {
|
|
725
|
+
const endpoint = new Endpoint({
|
|
726
|
+
route: '/protected',
|
|
727
|
+
method: 'GET',
|
|
728
|
+
fn: async () => ({ success: true }),
|
|
729
|
+
input: {},
|
|
730
|
+
output: z.object({ success: z.boolean() }),
|
|
731
|
+
services: [],
|
|
732
|
+
logger: mockLogger,
|
|
733
|
+
timeout: undefined,
|
|
734
|
+
memorySize: undefined,
|
|
735
|
+
status: undefined,
|
|
736
|
+
getSession: undefined,
|
|
737
|
+
authorize: undefined,
|
|
738
|
+
description: 'Protected endpoint',
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
// Set async authorize function with delay
|
|
742
|
+
endpoint.authorize = async ({ header }) => {
|
|
743
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
744
|
+
return header('authorization') === 'Bearer valid-token';
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
748
|
+
const handler = adapter.handler;
|
|
749
|
+
|
|
750
|
+
// Test with valid token
|
|
751
|
+
const validEvent = createMockV1Event({
|
|
752
|
+
headers: {
|
|
753
|
+
authorization: 'Bearer valid-token',
|
|
754
|
+
},
|
|
755
|
+
});
|
|
756
|
+
const context = createMockContext();
|
|
757
|
+
const response = await handler(validEvent, context);
|
|
758
|
+
|
|
759
|
+
expect(response.statusCode).toBe(200);
|
|
760
|
+
expect(response.body).toBe(JSON.stringify({ success: true }));
|
|
761
|
+
|
|
762
|
+
// Test with invalid token
|
|
763
|
+
const invalidEvent = createMockV1Event({
|
|
764
|
+
headers: {
|
|
765
|
+
authorization: 'Bearer invalid-token',
|
|
766
|
+
},
|
|
767
|
+
});
|
|
768
|
+
const invalidResponse = await handler(invalidEvent, context);
|
|
769
|
+
const invalidResponseBody = JSON.parse(invalidResponse.body!);
|
|
770
|
+
expect(invalidResponse.statusCode).toBe(401);
|
|
771
|
+
expect(invalidResponseBody).toMatchObject({
|
|
772
|
+
message: 'Unauthorized access to the endpoint',
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
describe('combined inputs', () => {
|
|
778
|
+
it('should handle array query parameters', async () => {
|
|
779
|
+
const querySchema = z.object({
|
|
780
|
+
tags: z.array(z.string()),
|
|
781
|
+
page: z.coerce.number().default(1),
|
|
782
|
+
});
|
|
783
|
+
const outputSchema = z.object({
|
|
784
|
+
tags: z.array(z.string()),
|
|
785
|
+
page: z.number(),
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
const endpoint = new Endpoint({
|
|
789
|
+
route: '/items',
|
|
790
|
+
method: 'GET',
|
|
791
|
+
fn: async ({ query }) => ({
|
|
792
|
+
tags: query.tags,
|
|
793
|
+
page: query.page,
|
|
794
|
+
}),
|
|
795
|
+
input: { query: querySchema },
|
|
796
|
+
output: outputSchema,
|
|
797
|
+
services: [],
|
|
798
|
+
logger: mockLogger,
|
|
799
|
+
timeout: undefined,
|
|
800
|
+
memorySize: undefined,
|
|
801
|
+
authorize: undefined,
|
|
802
|
+
description: 'List items with tags',
|
|
803
|
+
getSession: () => ({}),
|
|
804
|
+
status: 200,
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
808
|
+
const handler = adapter.handler;
|
|
809
|
+
|
|
810
|
+
const event = createMockV1Event({
|
|
811
|
+
queryStringParameters: { tags: 'nodejs', page: '2' },
|
|
812
|
+
multiValueQueryStringParameters: {
|
|
813
|
+
tags: ['nodejs', 'typescript', 'javascript'],
|
|
814
|
+
page: ['2'],
|
|
815
|
+
},
|
|
816
|
+
});
|
|
817
|
+
const context = createMockContext();
|
|
818
|
+
const response = await handler(event, context);
|
|
819
|
+
|
|
820
|
+
expect(response.statusCode).toBe(200);
|
|
821
|
+
const body = JSON.parse(response.body!);
|
|
822
|
+
expect(body).toEqual({
|
|
823
|
+
tags: ['nodejs', 'typescript', 'javascript'],
|
|
824
|
+
page: 2,
|
|
825
|
+
});
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
it('should handle object query parameters with dot notation', async () => {
|
|
829
|
+
const querySchema = z.object({
|
|
830
|
+
filter: z.object({
|
|
831
|
+
name: z.string(),
|
|
832
|
+
status: z.string(),
|
|
833
|
+
priority: z.coerce.number(),
|
|
834
|
+
}),
|
|
835
|
+
sort: z.string().default('name'),
|
|
836
|
+
});
|
|
837
|
+
const outputSchema = z.object({
|
|
838
|
+
filter: z.object({
|
|
839
|
+
name: z.string(),
|
|
840
|
+
status: z.string(),
|
|
841
|
+
priority: z.number(),
|
|
842
|
+
}),
|
|
843
|
+
sort: z.string(),
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
const endpoint = new Endpoint({
|
|
847
|
+
route: '/search',
|
|
848
|
+
method: 'GET',
|
|
849
|
+
fn: async ({ query }) => ({
|
|
850
|
+
filter: query.filter,
|
|
851
|
+
sort: query.sort,
|
|
852
|
+
}),
|
|
853
|
+
input: { query: querySchema },
|
|
854
|
+
output: outputSchema,
|
|
855
|
+
services: [],
|
|
856
|
+
logger: mockLogger,
|
|
857
|
+
timeout: undefined,
|
|
858
|
+
memorySize: undefined,
|
|
859
|
+
authorize: undefined,
|
|
860
|
+
description: 'Search with filters',
|
|
861
|
+
getSession: () => ({}),
|
|
862
|
+
status: 200,
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
866
|
+
const handler = adapter.handler;
|
|
867
|
+
|
|
868
|
+
const event = createMockV1Event({
|
|
869
|
+
queryStringParameters: {
|
|
870
|
+
'filter.name': 'john',
|
|
871
|
+
'filter.status': 'active',
|
|
872
|
+
'filter.priority': '1',
|
|
873
|
+
sort: 'priority',
|
|
874
|
+
},
|
|
875
|
+
});
|
|
876
|
+
const context = createMockContext();
|
|
877
|
+
const response = await handler(event, context);
|
|
878
|
+
|
|
879
|
+
expect(response.statusCode).toBe(200);
|
|
880
|
+
const body = JSON.parse(response.body!);
|
|
881
|
+
expect(body).toEqual({
|
|
882
|
+
filter: {
|
|
883
|
+
name: 'john',
|
|
884
|
+
status: 'active',
|
|
885
|
+
priority: 1,
|
|
886
|
+
},
|
|
887
|
+
sort: 'priority',
|
|
888
|
+
});
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
it('should handle body, query, and params together', async () => {
|
|
892
|
+
const bodySchema = z.object({ name: z.string() });
|
|
893
|
+
const querySchema = z.object({ filter: z.string() });
|
|
894
|
+
const paramsSchema = z.object({ id: z.string() });
|
|
895
|
+
const outputSchema = z.object({
|
|
896
|
+
id: z.string(),
|
|
897
|
+
name: z.string(),
|
|
898
|
+
filter: z.string(),
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
const endpoint = new Endpoint({
|
|
902
|
+
route: '/complex/:id',
|
|
903
|
+
method: 'PUT',
|
|
904
|
+
fn: async ({ body, query, params }) => ({
|
|
905
|
+
id: params.id,
|
|
906
|
+
name: body.name,
|
|
907
|
+
filter: query.filter,
|
|
908
|
+
}),
|
|
909
|
+
input: {
|
|
910
|
+
body: bodySchema,
|
|
911
|
+
query: querySchema,
|
|
912
|
+
params: paramsSchema,
|
|
913
|
+
},
|
|
914
|
+
output: outputSchema,
|
|
915
|
+
services: [],
|
|
916
|
+
logger: mockLogger,
|
|
917
|
+
timeout: undefined,
|
|
918
|
+
memorySize: undefined,
|
|
919
|
+
status: undefined,
|
|
920
|
+
getSession: undefined,
|
|
921
|
+
authorize: undefined,
|
|
922
|
+
description: 'Complex input endpoint',
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
926
|
+
const handler = adapter.handler;
|
|
927
|
+
|
|
928
|
+
const event = createMockV1Event({
|
|
929
|
+
httpMethod: 'PUT',
|
|
930
|
+
body: JSON.stringify({ name: 'Updated Name' }),
|
|
931
|
+
queryStringParameters: { filter: 'active' },
|
|
932
|
+
pathParameters: { id: '456' },
|
|
933
|
+
});
|
|
934
|
+
const context = createMockContext();
|
|
935
|
+
const response = await handler(event, context);
|
|
936
|
+
|
|
937
|
+
expect(response.statusCode).toBe(200);
|
|
938
|
+
expect(response.body).toBe(
|
|
939
|
+
JSON.stringify({
|
|
940
|
+
id: '456',
|
|
941
|
+
name: 'Updated Name',
|
|
942
|
+
filter: 'active',
|
|
943
|
+
}),
|
|
944
|
+
);
|
|
945
|
+
});
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
describe('response metadata', () => {
|
|
949
|
+
it('should set response cookies', async () => {
|
|
950
|
+
const endpoint = new Endpoint({
|
|
951
|
+
route: '/test',
|
|
952
|
+
method: 'GET',
|
|
953
|
+
fn: async (_, response) => {
|
|
954
|
+
response.cookie('session', 'abc123', {
|
|
955
|
+
httpOnly: true,
|
|
956
|
+
secure: true,
|
|
957
|
+
});
|
|
958
|
+
return { success: true };
|
|
959
|
+
},
|
|
960
|
+
input: {},
|
|
961
|
+
output: z.object({ success: z.boolean() }),
|
|
962
|
+
services: [],
|
|
963
|
+
logger: mockLogger,
|
|
964
|
+
timeout: undefined,
|
|
965
|
+
memorySize: undefined,
|
|
966
|
+
status: undefined,
|
|
967
|
+
getSession: undefined,
|
|
968
|
+
authorize: undefined,
|
|
969
|
+
description: 'Test endpoint',
|
|
970
|
+
});
|
|
971
|
+
|
|
972
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
973
|
+
const handler = adapter.handler;
|
|
974
|
+
|
|
975
|
+
const event = createMockV1Event();
|
|
976
|
+
const context = createMockContext();
|
|
977
|
+
const response = await handler(event, context);
|
|
978
|
+
|
|
979
|
+
expect(response.multiValueHeaders?.['Set-Cookie']).toEqual([
|
|
980
|
+
'session=abc123; HttpOnly; Secure',
|
|
981
|
+
]);
|
|
982
|
+
expect(response.statusCode).toBe(200);
|
|
983
|
+
expect(response.body).toBe(JSON.stringify({ success: true }));
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
it('should set custom headers', async () => {
|
|
987
|
+
const endpoint = new Endpoint({
|
|
988
|
+
route: '/test',
|
|
989
|
+
method: 'GET',
|
|
990
|
+
fn: async (_, response) => {
|
|
991
|
+
response.header('X-Custom-Header', 'custom-value');
|
|
992
|
+
response.header('X-Request-Id', '12345');
|
|
993
|
+
return { success: true };
|
|
994
|
+
},
|
|
995
|
+
input: {},
|
|
996
|
+
output: z.object({ success: z.boolean() }),
|
|
997
|
+
services: [],
|
|
998
|
+
logger: mockLogger,
|
|
999
|
+
timeout: undefined,
|
|
1000
|
+
memorySize: undefined,
|
|
1001
|
+
status: undefined,
|
|
1002
|
+
getSession: undefined,
|
|
1003
|
+
authorize: undefined,
|
|
1004
|
+
description: 'Test endpoint',
|
|
1005
|
+
});
|
|
1006
|
+
|
|
1007
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
1008
|
+
const handler = adapter.handler;
|
|
1009
|
+
|
|
1010
|
+
const event = createMockV1Event();
|
|
1011
|
+
const context = createMockContext();
|
|
1012
|
+
const response = await handler(event, context);
|
|
1013
|
+
|
|
1014
|
+
expect(response.headers).toEqual({
|
|
1015
|
+
'X-Custom-Header': 'custom-value',
|
|
1016
|
+
'X-Request-Id': '12345',
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
it('should set custom status code', async () => {
|
|
1021
|
+
const endpoint = new Endpoint({
|
|
1022
|
+
route: '/test',
|
|
1023
|
+
method: 'POST',
|
|
1024
|
+
fn: async (_, response) => {
|
|
1025
|
+
response.status(201);
|
|
1026
|
+
return { id: '123' };
|
|
1027
|
+
},
|
|
1028
|
+
input: {},
|
|
1029
|
+
output: z.object({ id: z.string() }),
|
|
1030
|
+
services: [],
|
|
1031
|
+
logger: mockLogger,
|
|
1032
|
+
timeout: undefined,
|
|
1033
|
+
memorySize: undefined,
|
|
1034
|
+
status: undefined,
|
|
1035
|
+
getSession: undefined,
|
|
1036
|
+
authorize: undefined,
|
|
1037
|
+
description: 'Test endpoint',
|
|
1038
|
+
});
|
|
1039
|
+
|
|
1040
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
1041
|
+
const handler = adapter.handler;
|
|
1042
|
+
|
|
1043
|
+
const event = createMockV1Event({ httpMethod: 'POST' });
|
|
1044
|
+
const context = createMockContext();
|
|
1045
|
+
const response = await handler(event, context);
|
|
1046
|
+
|
|
1047
|
+
expect(response.statusCode).toBe(201);
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
it('should combine cookies, headers, and status', async () => {
|
|
1051
|
+
const endpoint = new Endpoint({
|
|
1052
|
+
route: '/test',
|
|
1053
|
+
method: 'POST',
|
|
1054
|
+
fn: async (_, response) => {
|
|
1055
|
+
response
|
|
1056
|
+
.status(201)
|
|
1057
|
+
.header('Location', '/test/123')
|
|
1058
|
+
.cookie('session', 'abc123', { httpOnly: true })
|
|
1059
|
+
.cookie('theme', 'dark');
|
|
1060
|
+
return { id: '123' };
|
|
1061
|
+
},
|
|
1062
|
+
input: {},
|
|
1063
|
+
output: z.object({ id: z.string() }),
|
|
1064
|
+
services: [],
|
|
1065
|
+
logger: mockLogger,
|
|
1066
|
+
timeout: undefined,
|
|
1067
|
+
memorySize: undefined,
|
|
1068
|
+
status: undefined,
|
|
1069
|
+
getSession: undefined,
|
|
1070
|
+
authorize: undefined,
|
|
1071
|
+
description: 'Test endpoint',
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
1075
|
+
const handler = adapter.handler;
|
|
1076
|
+
|
|
1077
|
+
const event = createMockV1Event({ httpMethod: 'POST' });
|
|
1078
|
+
const context = createMockContext();
|
|
1079
|
+
const response = await handler(event, context);
|
|
1080
|
+
|
|
1081
|
+
expect(response.statusCode).toBe(201);
|
|
1082
|
+
expect(response.headers).toEqual({ Location: '/test/123' });
|
|
1083
|
+
expect(response.multiValueHeaders?.['Set-Cookie']).toEqual([
|
|
1084
|
+
'session=abc123; HttpOnly',
|
|
1085
|
+
'theme=dark',
|
|
1086
|
+
]);
|
|
1087
|
+
});
|
|
1088
|
+
|
|
1089
|
+
it('should delete cookies', async () => {
|
|
1090
|
+
const endpoint = new Endpoint({
|
|
1091
|
+
route: '/test',
|
|
1092
|
+
method: 'GET',
|
|
1093
|
+
fn: async (_, response) => {
|
|
1094
|
+
response.deleteCookie('session', {
|
|
1095
|
+
path: '/',
|
|
1096
|
+
domain: '.example.com',
|
|
1097
|
+
});
|
|
1098
|
+
return { success: true };
|
|
1099
|
+
},
|
|
1100
|
+
input: {},
|
|
1101
|
+
output: z.object({ success: z.boolean() }),
|
|
1102
|
+
services: [],
|
|
1103
|
+
logger: mockLogger,
|
|
1104
|
+
timeout: undefined,
|
|
1105
|
+
memorySize: undefined,
|
|
1106
|
+
status: undefined,
|
|
1107
|
+
getSession: undefined,
|
|
1108
|
+
authorize: undefined,
|
|
1109
|
+
description: 'Test endpoint',
|
|
1110
|
+
});
|
|
1111
|
+
|
|
1112
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
1113
|
+
const handler = adapter.handler;
|
|
1114
|
+
|
|
1115
|
+
const event = createMockV1Event();
|
|
1116
|
+
const context = createMockContext();
|
|
1117
|
+
const response = await handler(event, context);
|
|
1118
|
+
|
|
1119
|
+
expect(response.multiValueHeaders?.['Set-Cookie']).toEqual([
|
|
1120
|
+
'session=; Domain=.example.com; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0',
|
|
1121
|
+
]);
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1124
|
+
it('should use send() method with metadata', async () => {
|
|
1125
|
+
const endpoint = new Endpoint({
|
|
1126
|
+
route: '/test',
|
|
1127
|
+
method: 'GET',
|
|
1128
|
+
fn: async (_, response) => {
|
|
1129
|
+
return response
|
|
1130
|
+
.status(201)
|
|
1131
|
+
.header('X-Custom', 'value')
|
|
1132
|
+
.cookie('session', 'abc123')
|
|
1133
|
+
.send({ id: '123' });
|
|
1134
|
+
},
|
|
1135
|
+
input: {},
|
|
1136
|
+
output: z.object({ id: z.string() }),
|
|
1137
|
+
services: [],
|
|
1138
|
+
logger: mockLogger,
|
|
1139
|
+
timeout: undefined,
|
|
1140
|
+
memorySize: undefined,
|
|
1141
|
+
status: undefined,
|
|
1142
|
+
getSession: undefined,
|
|
1143
|
+
authorize: undefined,
|
|
1144
|
+
description: 'Test endpoint',
|
|
1145
|
+
});
|
|
1146
|
+
|
|
1147
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
1148
|
+
const handler = adapter.handler;
|
|
1149
|
+
|
|
1150
|
+
const event = createMockV1Event();
|
|
1151
|
+
const context = createMockContext();
|
|
1152
|
+
const response = await handler(event, context);
|
|
1153
|
+
|
|
1154
|
+
expect(response.statusCode).toBe(201);
|
|
1155
|
+
expect(response.headers).toEqual({ 'X-Custom': 'value' });
|
|
1156
|
+
expect(response.multiValueHeaders?.['Set-Cookie']).toEqual([
|
|
1157
|
+
'session=abc123',
|
|
1158
|
+
]);
|
|
1159
|
+
expect(response.body).toBe(JSON.stringify({ id: '123' }));
|
|
1160
|
+
});
|
|
1161
|
+
|
|
1162
|
+
it('should return simple response without metadata when not using response builder', async () => {
|
|
1163
|
+
const endpoint = new Endpoint({
|
|
1164
|
+
route: '/test',
|
|
1165
|
+
method: 'GET',
|
|
1166
|
+
fn: async () => ({ success: true }),
|
|
1167
|
+
input: {},
|
|
1168
|
+
output: z.object({ success: z.boolean() }),
|
|
1169
|
+
services: [],
|
|
1170
|
+
logger: mockLogger,
|
|
1171
|
+
timeout: undefined,
|
|
1172
|
+
memorySize: undefined,
|
|
1173
|
+
status: undefined,
|
|
1174
|
+
getSession: undefined,
|
|
1175
|
+
authorize: undefined,
|
|
1176
|
+
description: 'Test endpoint',
|
|
1177
|
+
});
|
|
1178
|
+
|
|
1179
|
+
const adapter = new AmazonApiGatewayV1Endpoint(envParser, endpoint);
|
|
1180
|
+
const handler = adapter.handler;
|
|
1181
|
+
|
|
1182
|
+
const event = createMockV1Event();
|
|
1183
|
+
const context = createMockContext();
|
|
1184
|
+
const response = await handler(event, context);
|
|
1185
|
+
|
|
1186
|
+
expect(response).toEqual({
|
|
1187
|
+
statusCode: 200,
|
|
1188
|
+
body: JSON.stringify({ success: true }),
|
|
1189
|
+
});
|
|
1190
|
+
expect(response.headers).toBeUndefined();
|
|
1191
|
+
expect(response.multiValueHeaders).toBeUndefined();
|
|
1192
|
+
});
|
|
1193
|
+
});
|
|
1196
1194
|
});
|