@h4ad/serverless-adapter 3.0.0 → 3.2.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/README.md +2 -7
- package/lib/@types/binary-settings.d.ts +41 -0
- package/lib/@types/binary-settings.d.ts.map +1 -0
- package/lib/@types/binary-settings.js +1 -1
- package/lib/@types/binary-settings.js.map +1 -1
- package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts +37 -0
- package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts.map +1 -0
- package/lib/@types/digital-ocean/digital-ocean-http-event.js +1 -1
- package/lib/@types/digital-ocean/digital-ocean-http-event.js.map +1 -1
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts +22 -0
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts.map +1 -0
- package/lib/@types/digital-ocean/digital-ocean-http-response.js +1 -1
- package/lib/@types/digital-ocean/digital-ocean-http-response.js.map +1 -1
- package/lib/@types/digital-ocean/index.d.ts +2 -0
- package/lib/@types/digital-ocean/index.d.ts.map +1 -0
- package/lib/@types/digital-ocean/index.js +1 -1
- package/lib/@types/digital-ocean/index.js.map +1 -1
- package/lib/@types/headers.d.ts +37 -0
- package/lib/@types/headers.d.ts.map +1 -0
- package/lib/@types/headers.js +1 -1
- package/lib/@types/headers.js.map +1 -1
- package/lib/@types/helpers.d.ts +10 -0
- package/lib/@types/helpers.d.ts.map +1 -0
- package/lib/@types/helpers.js +1 -1
- package/lib/@types/helpers.js.map +1 -1
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts +81 -0
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts.map +1 -0
- package/lib/@types/huawei/huawei-api-gateway-event.js +1 -1
- package/lib/@types/huawei/huawei-api-gateway-event.js.map +1 -1
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts +27 -0
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts.map +1 -0
- package/lib/@types/huawei/huawei-api-gateway-response.js +1 -1
- package/lib/@types/huawei/huawei-api-gateway-response.js.map +1 -1
- package/lib/@types/huawei/huawei-context.d.ts +188 -0
- package/lib/@types/huawei/huawei-context.d.ts.map +1 -0
- package/lib/@types/huawei/huawei-context.js +1 -1
- package/lib/@types/huawei/huawei-context.js.map +1 -1
- package/lib/@types/huawei/index.d.ts +4 -0
- package/lib/@types/huawei/index.d.ts.map +1 -0
- package/lib/@types/huawei/index.js +1 -1
- package/lib/@types/huawei/index.js.map +1 -1
- package/lib/@types/index.d.ts +4 -0
- package/lib/@types/index.d.ts.map +1 -0
- package/lib/@types/index.js +1 -1
- package/lib/@types/index.js.map +1 -1
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts +56 -0
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts.map +1 -0
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js +1 -1
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js.map +1 -1
- package/lib/adapters/apollo-server/index.d.ts +2 -0
- package/lib/adapters/apollo-server/index.d.ts.map +1 -0
- package/lib/adapters/apollo-server/index.js +1 -1
- package/lib/adapters/apollo-server/index.js.map +1 -1
- package/lib/adapters/aws/alb.adapter.d.ts +71 -0
- package/lib/adapters/aws/alb.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/alb.adapter.js +1 -1
- package/lib/adapters/aws/alb.adapter.js.map +1 -1
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +76 -0
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/api-gateway-v1.adapter.js +1 -1
- package/lib/adapters/aws/api-gateway-v1.adapter.js.map +1 -1
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +75 -0
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/api-gateway-v2.adapter.js +1 -1
- package/lib/adapters/aws/api-gateway-v2.adapter.js.map +1 -1
- package/lib/adapters/aws/base/aws-simple-adapter.d.ts +83 -0
- package/lib/adapters/aws/base/aws-simple-adapter.d.ts.map +1 -0
- package/lib/adapters/aws/base/aws-simple-adapter.js +1 -1
- package/lib/adapters/aws/base/aws-simple-adapter.js.map +1 -1
- package/lib/adapters/aws/base/index.d.ts +2 -0
- package/lib/adapters/aws/base/index.d.ts.map +1 -0
- package/lib/adapters/aws/base/index.js +1 -1
- package/lib/adapters/aws/base/index.js.map +1 -1
- package/lib/adapters/aws/dynamodb.adapter.d.ts +56 -0
- package/lib/adapters/aws/dynamodb.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/dynamodb.adapter.js +1 -1
- package/lib/adapters/aws/dynamodb.adapter.js.map +1 -1
- package/lib/adapters/aws/event-bridge.adapter.d.ts +63 -0
- package/lib/adapters/aws/event-bridge.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/event-bridge.adapter.js +1 -1
- package/lib/adapters/aws/event-bridge.adapter.js.map +1 -1
- package/lib/adapters/aws/index.d.ts +12 -0
- package/lib/adapters/aws/index.d.ts.map +1 -0
- package/lib/adapters/aws/index.js +1 -1
- package/lib/adapters/aws/index.js.map +1 -1
- package/lib/adapters/aws/lambda-edge.adapter.d.ts +209 -0
- package/lib/adapters/aws/lambda-edge.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/lambda-edge.adapter.js +1 -1
- package/lib/adapters/aws/lambda-edge.adapter.js.map +1 -1
- package/lib/adapters/aws/request-lambda-edge.adapter.d.ts +131 -0
- package/lib/adapters/aws/request-lambda-edge.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/request-lambda-edge.adapter.js +2 -0
- package/lib/adapters/aws/request-lambda-edge.adapter.js.map +1 -0
- package/lib/adapters/aws/s3.adapter.d.ts +56 -0
- package/lib/adapters/aws/s3.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/s3.adapter.js +1 -1
- package/lib/adapters/aws/s3.adapter.js.map +1 -1
- package/lib/adapters/aws/sns.adapter.d.ts +56 -0
- package/lib/adapters/aws/sns.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/sns.adapter.js +1 -1
- package/lib/adapters/aws/sns.adapter.js.map +1 -1
- package/lib/adapters/aws/sqs.adapter.d.ts +56 -0
- package/lib/adapters/aws/sqs.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/sqs.adapter.js +1 -1
- package/lib/adapters/aws/sqs.adapter.js.map +1 -1
- package/lib/adapters/azure/http-trigger-v4.adapter.d.ts +81 -0
- package/lib/adapters/azure/http-trigger-v4.adapter.d.ts.map +1 -0
- package/lib/adapters/azure/http-trigger-v4.adapter.js +1 -1
- package/lib/adapters/azure/http-trigger-v4.adapter.js.map +1 -1
- package/lib/adapters/azure/index.d.ts +2 -0
- package/lib/adapters/azure/index.d.ts.map +1 -0
- package/lib/adapters/azure/index.js +1 -1
- package/lib/adapters/azure/index.js.map +1 -1
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts +65 -0
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts.map +1 -0
- package/lib/adapters/digital-ocean/http-function.adapter.js +1 -1
- package/lib/adapters/digital-ocean/http-function.adapter.js.map +1 -1
- package/lib/adapters/digital-ocean/index.d.ts +2 -0
- package/lib/adapters/digital-ocean/index.d.ts.map +1 -0
- package/lib/adapters/digital-ocean/index.js +1 -1
- package/lib/adapters/digital-ocean/index.js.map +1 -1
- package/lib/adapters/dummy/dummy.adapter.d.ts +31 -0
- package/lib/adapters/dummy/dummy.adapter.d.ts.map +1 -0
- package/lib/adapters/dummy/dummy.adapter.js +1 -1
- package/lib/adapters/dummy/dummy.adapter.js.map +1 -1
- package/lib/adapters/dummy/index.d.ts +2 -0
- package/lib/adapters/dummy/index.d.ts.map +1 -0
- package/lib/adapters/dummy/index.js +1 -1
- package/lib/adapters/dummy/index.js.map +1 -1
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +66 -0
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts.map +1 -0
- package/lib/adapters/huawei/huawei-api-gateway.adapter.js +1 -1
- package/lib/adapters/huawei/huawei-api-gateway.adapter.js.map +1 -1
- package/lib/adapters/huawei/index.d.ts +2 -0
- package/lib/adapters/huawei/index.d.ts.map +1 -0
- package/lib/adapters/huawei/index.js +1 -1
- package/lib/adapters/huawei/index.js.map +1 -1
- package/lib/contracts/adapter.contract.d.ts +152 -0
- package/lib/contracts/adapter.contract.d.ts.map +1 -0
- package/lib/contracts/adapter.contract.js +1 -1
- package/lib/contracts/adapter.contract.js.map +1 -1
- package/lib/contracts/framework.contract.d.ts +19 -0
- package/lib/contracts/framework.contract.d.ts.map +1 -0
- package/lib/contracts/framework.contract.js +1 -1
- package/lib/contracts/framework.contract.js.map +1 -1
- package/lib/contracts/handler.contract.d.ts +25 -0
- package/lib/contracts/handler.contract.d.ts.map +1 -0
- package/lib/contracts/handler.contract.js +1 -1
- package/lib/contracts/handler.contract.js.map +1 -1
- package/lib/contracts/index.d.ts +5 -0
- package/lib/contracts/index.d.ts.map +1 -0
- package/lib/contracts/index.js +1 -1
- package/lib/contracts/index.js.map +1 -1
- package/lib/contracts/resolver.contract.d.ts +83 -0
- package/lib/contracts/resolver.contract.d.ts.map +1 -0
- package/lib/contracts/resolver.contract.js +1 -1
- package/lib/contracts/resolver.contract.js.map +1 -1
- package/lib/core/base-handler.d.ts +32 -0
- package/lib/core/base-handler.d.ts.map +1 -0
- package/lib/core/base-handler.js +1 -1
- package/lib/core/base-handler.js.map +1 -1
- package/lib/core/constants.d.ts +31 -0
- package/lib/core/constants.d.ts.map +1 -0
- package/lib/core/constants.js +1 -1
- package/lib/core/constants.js.map +1 -1
- package/lib/core/current-invoke.d.ts +48 -0
- package/lib/core/current-invoke.d.ts.map +1 -0
- package/lib/core/current-invoke.js +1 -1
- package/lib/core/current-invoke.js.map +1 -1
- package/lib/core/event-body.d.ts +22 -0
- package/lib/core/event-body.d.ts.map +1 -0
- package/lib/core/event-body.js +1 -1
- package/lib/core/event-body.js.map +1 -1
- package/lib/core/headers.d.ts +73 -0
- package/lib/core/headers.d.ts.map +1 -0
- package/lib/core/headers.js +2 -2
- package/lib/core/headers.js.map +1 -1
- package/lib/core/index.d.ts +12 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/is-binary.d.ts +73 -0
- package/lib/core/is-binary.d.ts.map +1 -0
- package/lib/core/is-binary.js +1 -1
- package/lib/core/is-binary.js.map +1 -1
- package/lib/core/logger.d.ts +64 -0
- package/lib/core/logger.d.ts.map +1 -0
- package/lib/core/logger.js +1 -1
- package/lib/core/logger.js.map +1 -1
- package/lib/core/no-op.d.ts +8 -0
- package/lib/core/no-op.d.ts.map +1 -0
- package/lib/core/no-op.js +1 -1
- package/lib/core/no-op.js.map +1 -1
- package/lib/core/optional.d.ts +22 -0
- package/lib/core/optional.d.ts.map +1 -0
- package/lib/core/optional.js +1 -1
- package/lib/core/optional.js.map +1 -1
- package/lib/core/path.d.ts +53 -0
- package/lib/core/path.d.ts.map +1 -0
- package/lib/core/path.js +1 -1
- package/lib/core/path.js.map +1 -1
- package/lib/core/stream.d.ts +21 -0
- package/lib/core/stream.d.ts.map +1 -0
- package/lib/core/stream.js +1 -1
- package/lib/core/stream.js.map +1 -1
- package/lib/frameworks/apollo-server/apollo-server.framework.d.ts +69 -0
- package/lib/frameworks/apollo-server/apollo-server.framework.d.ts.map +1 -0
- package/lib/frameworks/apollo-server/apollo-server.framework.js +1 -1
- package/lib/frameworks/apollo-server/apollo-server.framework.js.map +1 -1
- package/lib/frameworks/apollo-server/index.d.ts +2 -0
- package/lib/frameworks/apollo-server/index.d.ts.map +1 -0
- package/lib/frameworks/apollo-server/index.js +1 -1
- package/lib/frameworks/apollo-server/index.js.map +1 -1
- package/lib/frameworks/body-parser/base-body-parser.framework.d.ts +69 -0
- package/lib/frameworks/body-parser/base-body-parser.framework.d.ts.map +1 -0
- package/lib/frameworks/body-parser/base-body-parser.framework.js +1 -1
- package/lib/frameworks/body-parser/base-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/index.d.ts +6 -0
- package/lib/frameworks/body-parser/index.d.ts.map +1 -0
- package/lib/frameworks/body-parser/index.js +1 -1
- package/lib/frameworks/body-parser/index.js.map +1 -1
- package/lib/frameworks/body-parser/json-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/json-body-parser.framework.d.ts.map +1 -0
- package/lib/frameworks/body-parser/json-body-parser.framework.js +1 -1
- package/lib/frameworks/body-parser/json-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts.map +1 -0
- package/lib/frameworks/body-parser/raw-body-parser.framework.js +1 -1
- package/lib/frameworks/body-parser/raw-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/text-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/text-body-parser.framework.d.ts.map +1 -0
- package/lib/frameworks/body-parser/text-body-parser.framework.js +1 -1
- package/lib/frameworks/body-parser/text-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts.map +1 -0
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js +1 -1
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js.map +1 -1
- package/lib/frameworks/cors/cors.framework.d.ts +78 -0
- package/lib/frameworks/cors/cors.framework.d.ts.map +1 -0
- package/lib/frameworks/cors/cors.framework.js +2 -2
- package/lib/frameworks/cors/cors.framework.js.map +1 -1
- package/lib/frameworks/cors/index.d.ts +2 -0
- package/lib/frameworks/cors/index.d.ts.map +1 -0
- package/lib/frameworks/cors/index.js +1 -1
- package/lib/frameworks/cors/index.js.map +1 -1
- package/lib/frameworks/deepkit/http-deepkit.framework.d.ts +18 -0
- package/lib/frameworks/deepkit/http-deepkit.framework.d.ts.map +1 -0
- package/lib/frameworks/deepkit/http-deepkit.framework.js +1 -1
- package/lib/frameworks/deepkit/http-deepkit.framework.js.map +1 -1
- package/lib/frameworks/deepkit/index.d.ts +2 -0
- package/lib/frameworks/deepkit/index.d.ts.map +1 -0
- package/lib/frameworks/deepkit/index.js +1 -1
- package/lib/frameworks/deepkit/index.js.map +1 -1
- package/lib/frameworks/express/express.framework.d.ts +17 -0
- package/lib/frameworks/express/express.framework.d.ts.map +1 -0
- package/lib/frameworks/express/express.framework.js +1 -1
- package/lib/frameworks/express/express.framework.js.map +1 -1
- package/lib/frameworks/express/index.d.ts +2 -0
- package/lib/frameworks/express/index.d.ts.map +1 -0
- package/lib/frameworks/express/index.js +1 -1
- package/lib/frameworks/express/index.js.map +1 -1
- package/lib/frameworks/fastify/fastify.framework.d.ts +17 -0
- package/lib/frameworks/fastify/fastify.framework.d.ts.map +1 -0
- package/lib/frameworks/fastify/fastify.framework.js +1 -1
- package/lib/frameworks/fastify/fastify.framework.js.map +1 -1
- package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts +14 -0
- package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts.map +1 -0
- package/lib/frameworks/fastify/helpers/no-op-content-parser.js +1 -1
- package/lib/frameworks/fastify/helpers/no-op-content-parser.js.map +1 -1
- package/lib/frameworks/fastify/index.d.ts +2 -0
- package/lib/frameworks/fastify/index.d.ts.map +1 -0
- package/lib/frameworks/fastify/index.js +1 -1
- package/lib/frameworks/fastify/index.js.map +1 -1
- package/lib/frameworks/hapi/hapi.framework.d.ts +17 -0
- package/lib/frameworks/hapi/hapi.framework.d.ts.map +1 -0
- package/lib/frameworks/hapi/hapi.framework.js +1 -1
- package/lib/frameworks/hapi/hapi.framework.js.map +1 -1
- package/lib/frameworks/hapi/index.d.ts +2 -0
- package/lib/frameworks/hapi/index.d.ts.map +1 -0
- package/lib/frameworks/hapi/index.js +1 -1
- package/lib/frameworks/hapi/index.js.map +1 -1
- package/lib/frameworks/koa/index.d.ts +2 -0
- package/lib/frameworks/koa/index.d.ts.map +1 -0
- package/lib/frameworks/koa/index.js +1 -1
- package/lib/frameworks/koa/index.js.map +1 -1
- package/lib/frameworks/koa/koa.framework.d.ts +17 -0
- package/lib/frameworks/koa/koa.framework.d.ts.map +1 -0
- package/lib/frameworks/koa/koa.framework.js +1 -1
- package/lib/frameworks/koa/koa.framework.js.map +1 -1
- package/lib/frameworks/lazy/index.d.ts +2 -0
- package/lib/frameworks/lazy/index.d.ts.map +1 -0
- package/lib/frameworks/lazy/index.js +1 -1
- package/lib/frameworks/lazy/index.js.map +1 -1
- package/lib/frameworks/lazy/lazy.framework.d.ts +56 -0
- package/lib/frameworks/lazy/lazy.framework.d.ts.map +1 -0
- package/lib/frameworks/lazy/lazy.framework.js +1 -1
- package/lib/frameworks/lazy/lazy.framework.js.map +1 -1
- package/lib/frameworks/trpc/index.d.ts +2 -0
- package/lib/frameworks/trpc/index.d.ts.map +1 -0
- package/lib/frameworks/trpc/index.js +1 -1
- package/lib/frameworks/trpc/index.js.map +1 -1
- package/lib/frameworks/trpc/trpc.framework.d.ts +153 -0
- package/lib/frameworks/trpc/trpc.framework.d.ts.map +1 -0
- package/lib/frameworks/trpc/trpc.framework.js +1 -1
- package/lib/frameworks/trpc/trpc.framework.js.map +1 -1
- package/lib/handlers/aws/aws-stream.handler.d.ts +89 -0
- package/lib/handlers/aws/aws-stream.handler.d.ts.map +1 -0
- package/lib/handlers/aws/aws-stream.handler.js +1 -1
- package/lib/handlers/aws/aws-stream.handler.js.map +1 -1
- package/lib/handlers/aws/index.d.ts +2 -0
- package/lib/handlers/aws/index.d.ts.map +1 -0
- package/lib/handlers/aws/index.js +1 -1
- package/lib/handlers/aws/index.js.map +1 -1
- package/lib/handlers/azure/azure.handler.d.ts +45 -0
- package/lib/handlers/azure/azure.handler.d.ts.map +1 -0
- package/lib/handlers/azure/azure.handler.js +1 -1
- package/lib/handlers/azure/azure.handler.js.map +1 -1
- package/lib/handlers/azure/index.d.ts +2 -0
- package/lib/handlers/azure/index.d.ts.map +1 -0
- package/lib/handlers/azure/index.js +1 -1
- package/lib/handlers/azure/index.js.map +1 -1
- package/lib/handlers/base/index.d.ts +2 -0
- package/lib/handlers/base/index.d.ts.map +1 -0
- package/lib/handlers/base/index.js +1 -1
- package/lib/handlers/base/index.js.map +1 -1
- package/lib/handlers/base/raw-request.d.ts +31 -0
- package/lib/handlers/base/raw-request.d.ts.map +1 -0
- package/lib/handlers/base/raw-request.js +1 -1
- package/lib/handlers/base/raw-request.js.map +1 -1
- package/lib/handlers/default/default.handler.d.ts +88 -0
- package/lib/handlers/default/default.handler.d.ts.map +1 -0
- package/lib/handlers/default/default.handler.js +1 -1
- package/lib/handlers/default/default.handler.js.map +1 -1
- package/lib/handlers/default/index.d.ts +2 -0
- package/lib/handlers/default/index.d.ts.map +1 -0
- package/lib/handlers/default/index.js +1 -1
- package/lib/handlers/default/index.js.map +1 -1
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts +17 -0
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts.map +1 -0
- package/lib/handlers/digital-ocean/digital-ocean.handler.js +1 -1
- package/lib/handlers/digital-ocean/digital-ocean.handler.js.map +1 -1
- package/lib/handlers/digital-ocean/index.d.ts +2 -0
- package/lib/handlers/digital-ocean/index.d.ts.map +1 -0
- package/lib/handlers/digital-ocean/index.js +1 -1
- package/lib/handlers/digital-ocean/index.js.map +1 -1
- package/lib/handlers/firebase/http-firebase-v2.handler.d.ts +27 -0
- package/lib/handlers/firebase/http-firebase-v2.handler.d.ts.map +1 -0
- package/lib/handlers/firebase/http-firebase-v2.handler.js +1 -1
- package/lib/handlers/firebase/http-firebase-v2.handler.js.map +1 -1
- package/lib/handlers/firebase/http-firebase.handler.d.ts +19 -0
- package/lib/handlers/firebase/http-firebase.handler.d.ts.map +1 -0
- package/lib/handlers/firebase/http-firebase.handler.js +1 -1
- package/lib/handlers/firebase/http-firebase.handler.js.map +1 -1
- package/lib/handlers/firebase/index.d.ts +3 -0
- package/lib/handlers/firebase/index.d.ts.map +1 -0
- package/lib/handlers/firebase/index.js +1 -1
- package/lib/handlers/firebase/index.js.map +1 -1
- package/lib/handlers/gcp/gcp.handler.d.ts +26 -0
- package/lib/handlers/gcp/gcp.handler.d.ts.map +1 -0
- package/lib/handlers/gcp/gcp.handler.js +1 -1
- package/lib/handlers/gcp/gcp.handler.js.map +1 -1
- package/lib/handlers/gcp/index.d.ts +2 -0
- package/lib/handlers/gcp/index.d.ts.map +1 -0
- package/lib/handlers/gcp/index.js +1 -1
- package/lib/handlers/gcp/index.js.map +1 -1
- package/lib/handlers/huawei/http-huawei.handler.d.ts +59 -0
- package/lib/handlers/huawei/http-huawei.handler.d.ts.map +1 -0
- package/lib/handlers/huawei/http-huawei.handler.js +1 -1
- package/lib/handlers/huawei/http-huawei.handler.js.map +1 -1
- package/lib/handlers/huawei/index.d.ts +2 -0
- package/lib/handlers/huawei/index.d.ts.map +1 -0
- package/lib/handlers/huawei/index.js +1 -1
- package/lib/handlers/huawei/index.js.map +1 -1
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.doc.js +1 -1
- package/lib/index.doc.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/network/index.d.ts +5 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +1 -1
- package/lib/network/index.js.map +1 -1
- package/lib/network/request.d.ts +44 -0
- package/lib/network/request.d.ts.map +1 -0
- package/lib/network/request.js +1 -1
- package/lib/network/request.js.map +1 -1
- package/lib/network/response-stream.d.ts +41 -0
- package/lib/network/response-stream.d.ts.map +1 -0
- package/lib/network/response-stream.js +4 -4
- package/lib/network/response-stream.js.map +1 -1
- package/lib/network/response.d.ts +48 -0
- package/lib/network/response.d.ts.map +1 -0
- package/lib/network/response.js +2 -2
- package/lib/network/response.js.map +1 -1
- package/lib/network/utils.d.ts +9 -0
- package/lib/network/utils.d.ts.map +1 -0
- package/lib/network/utils.js +1 -1
- package/lib/network/utils.js.map +1 -1
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts +19 -0
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts.map +1 -0
- package/lib/resolvers/aws-context/aws-context.resolver.js +1 -1
- package/lib/resolvers/aws-context/aws-context.resolver.js.map +1 -1
- package/lib/resolvers/aws-context/index.d.ts +2 -0
- package/lib/resolvers/aws-context/index.d.ts.map +1 -0
- package/lib/resolvers/aws-context/index.js +1 -1
- package/lib/resolvers/aws-context/index.js.map +1 -1
- package/lib/resolvers/callback/callback.resolver.d.ts +23 -0
- package/lib/resolvers/callback/callback.resolver.d.ts.map +1 -0
- package/lib/resolvers/callback/callback.resolver.js +1 -1
- package/lib/resolvers/callback/callback.resolver.js.map +1 -1
- package/lib/resolvers/callback/index.d.ts +2 -0
- package/lib/resolvers/callback/index.d.ts.map +1 -0
- package/lib/resolvers/callback/index.js +1 -1
- package/lib/resolvers/callback/index.js.map +1 -1
- package/lib/resolvers/dummy/dummy.resolver.d.ts +14 -0
- package/lib/resolvers/dummy/dummy.resolver.d.ts.map +1 -0
- package/lib/resolvers/dummy/dummy.resolver.js +1 -1
- package/lib/resolvers/dummy/dummy.resolver.js.map +1 -1
- package/lib/resolvers/dummy/index.d.ts +2 -0
- package/lib/resolvers/dummy/index.d.ts.map +1 -0
- package/lib/resolvers/dummy/index.js +1 -1
- package/lib/resolvers/dummy/index.js.map +1 -1
- package/lib/resolvers/promise/index.d.ts +2 -0
- package/lib/resolvers/promise/index.d.ts.map +1 -0
- package/lib/resolvers/promise/index.js +1 -1
- package/lib/resolvers/promise/index.js.map +1 -1
- package/lib/resolvers/promise/promise.resolver.d.ts +14 -0
- package/lib/resolvers/promise/promise.resolver.d.ts.map +1 -0
- package/lib/resolvers/promise/promise.resolver.js +1 -1
- package/lib/resolvers/promise/promise.resolver.js.map +1 -1
- package/lib/serverless-adapter.d.ts +119 -0
- package/lib/serverless-adapter.d.ts.map +1 -0
- package/lib/serverless-adapter.js +1 -1
- package/lib/serverless-adapter.js.map +1 -1
- package/package.json +47 -54
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { CloudFrontRequest, Context } from 'aws-lambda';
|
|
2
|
+
import type { CloudFrontHeaders, CloudFrontResultResponse } from 'aws-lambda/common/cloudfront';
|
|
3
|
+
import type { CloudFrontRequestEvent, CloudFrontRequestResult } from 'aws-lambda/trigger/cloudfront-request';
|
|
4
|
+
import { BothValueHeaders, SingleValueHeaders } from '../../@types';
|
|
5
|
+
import { AdapterContract, AdapterRequest, GetResponseAdapterProps, OnErrorProps } from '../../contracts';
|
|
6
|
+
import { StripBasePathFn } from '../../core';
|
|
7
|
+
/**
|
|
8
|
+
* The options to customize the {@link RequestLambdaEdgeAdapter}.
|
|
9
|
+
*
|
|
10
|
+
* @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface RequestLambdaEdgeAdapterOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Strip base path for custom paths, like `/api`.
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue ''
|
|
18
|
+
*/
|
|
19
|
+
stripBasePath?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The max response size in bytes of viewer request and viewer response.
|
|
22
|
+
*
|
|
23
|
+
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
|
|
24
|
+
*
|
|
25
|
+
* @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}
|
|
26
|
+
*/
|
|
27
|
+
viewerMaxResponseSizeInBytes?: number;
|
|
28
|
+
/**
|
|
29
|
+
* The max response size in bytes of origin request and origin response.
|
|
30
|
+
*
|
|
31
|
+
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
|
|
32
|
+
*
|
|
33
|
+
* @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}
|
|
34
|
+
*/
|
|
35
|
+
originMaxResponseSizeInBytes?: number;
|
|
36
|
+
/**
|
|
37
|
+
* The function called when the response size exceed the max limits of the Lambda\@edge
|
|
38
|
+
*
|
|
39
|
+
* @param response - The response from framework that exceed the limit of Lambda\@edge
|
|
40
|
+
* @defaultValue undefined
|
|
41
|
+
*/
|
|
42
|
+
onResponseSizeExceedLimit?: (response: CloudFrontRequestResult) => CloudFrontRequestResult;
|
|
43
|
+
/**
|
|
44
|
+
* The headers that will be stripped from the headers object because Lambda\@edge will fail if these headers are passed in the response.
|
|
45
|
+
*
|
|
46
|
+
* @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)
|
|
47
|
+
*
|
|
48
|
+
* @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.
|
|
49
|
+
*/
|
|
50
|
+
disallowedHeaders?: (string | RegExp)[];
|
|
51
|
+
/**
|
|
52
|
+
* If you want to change how we check against the header if it should be stripped, you can pass a function to this property.
|
|
53
|
+
*
|
|
54
|
+
* @param header - The header of the response
|
|
55
|
+
* @defaultValue The default method is implemented to test the header against the list {@link RequestLambdaEdgeAdapterOptions.disallowedHeaders}.
|
|
56
|
+
*/
|
|
57
|
+
shouldStripHeader?: (header: string) => boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The adapter to handle requests from AWS Lambda\@Edge of the type Viewer Request.
|
|
61
|
+
*
|
|
62
|
+
* The idea of this Adapter is to you be able to expose your framework to the Edge, like when you build for Cloudfront.
|
|
63
|
+
*
|
|
64
|
+
* {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}
|
|
65
|
+
* {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const stripBasePath = '/api'; // in case you have configure the cloudfront to forward the path /api to your lambda
|
|
70
|
+
* const adapter = new RequestLambdaEdgeAdapter({ stripBasePath });
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
export declare class RequestLambdaEdgeAdapter implements AdapterContract<CloudFrontRequestEvent, Context, CloudFrontResultResponse> {
|
|
77
|
+
protected readonly options?: RequestLambdaEdgeAdapterOptions | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Default constructor
|
|
80
|
+
*
|
|
81
|
+
* @param options - The options to customize the {@link RequestLambdaEdgeAdapter}
|
|
82
|
+
*/
|
|
83
|
+
constructor(options?: RequestLambdaEdgeAdapterOptions | undefined);
|
|
84
|
+
/**
|
|
85
|
+
* Strip base path function
|
|
86
|
+
*/
|
|
87
|
+
protected readonly stripPathFn: StripBasePathFn;
|
|
88
|
+
/**
|
|
89
|
+
* This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.
|
|
90
|
+
*/
|
|
91
|
+
protected readonly cachedDisallowedHeaders: RegExp[];
|
|
92
|
+
/**
|
|
93
|
+
* {@inheritDoc}
|
|
94
|
+
*/
|
|
95
|
+
getAdapterName(): string;
|
|
96
|
+
/**
|
|
97
|
+
* {@inheritDoc}
|
|
98
|
+
*/
|
|
99
|
+
canHandle(event: unknown): event is CloudFrontRequestEvent;
|
|
100
|
+
/**
|
|
101
|
+
* {@inheritDoc}
|
|
102
|
+
*/
|
|
103
|
+
getRequest(event: CloudFrontRequestEvent): AdapterRequest;
|
|
104
|
+
/**
|
|
105
|
+
* {@inheritDoc}
|
|
106
|
+
*/
|
|
107
|
+
getResponse({ body, headers: frameworkHeaders, isBase64Encoded, statusCode, log, event, }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontResultResponse;
|
|
108
|
+
/**
|
|
109
|
+
* {@inheritDoc}
|
|
110
|
+
*/
|
|
111
|
+
onErrorWhileForwarding({ error, delegatedResolver, respondWithErrors, log, event, }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void;
|
|
112
|
+
/**
|
|
113
|
+
* Returns the headers with the flattened (non-list) values of the cloudfront request headers
|
|
114
|
+
*
|
|
115
|
+
* @param cloudFrontRequest - The cloudfront request
|
|
116
|
+
*/
|
|
117
|
+
protected getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest: CloudFrontRequest): SingleValueHeaders;
|
|
118
|
+
/**
|
|
119
|
+
* Returns headers in Cloudfront Response format.
|
|
120
|
+
*
|
|
121
|
+
* @param originalHeaders - The original version of the request sent by the framework
|
|
122
|
+
*/
|
|
123
|
+
protected getHeadersForCloudfrontResponse(originalHeaders: BothValueHeaders): CloudFrontHeaders;
|
|
124
|
+
/**
|
|
125
|
+
* Returns the information if we should remove the response header
|
|
126
|
+
*
|
|
127
|
+
* @param headerKey - The header that will be tested
|
|
128
|
+
*/
|
|
129
|
+
protected shouldStripHeader(headerKey: string): boolean;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=request-lambda-edge.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-lambda-edge.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/request-lambda-edge.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EAKhB,MAAM,YAAY,CAAC;AAWpB;;;;;GAKG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;OAMG;IACH,4BAA4B,CAAC,EAAE,MAAM,CAAC;IAEtC;;;;;;OAMG;IACH,4BAA4B,CAAC,EAAE,MAAM,CAAC;IAEtC;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,CAC1B,QAAQ,EAAE,uBAAuB,KAC9B,uBAAuB,CAAC;IAE7B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAExC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,wBACX,YACE,eAAe,CAAC,sBAAsB,EAAE,OAAO,EAAE,wBAAwB,CAAC;IAShE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;IALvC;;;;OAIG;gBAC4B,OAAO,CAAC,6CAAiC;IAmBxE;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC;IAEhD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,EAAE,CAAC;IAMrD;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,sBAAsB;IAUjE;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,cAAc;IA0ChE;;OAEG;IACI,WAAW,CAAC,EACjB,IAAI,EACJ,OAAO,EAAE,gBAAgB,EACzB,eAAe,EACf,UAAU,EACV,GAAG,EACH,KAAK,GACN,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,GAAG,wBAAwB;IAqC7E;;OAEG;IACI,sBAAsB,CAAC,EAC5B,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,GAAG,EACH,KAAK,GACN,EAAE,YAAY,CAAC,sBAAsB,EAAE,uBAAuB,CAAC,GAAG,IAAI;IAkBvE;;;;OAIG;IACH,SAAS,CAAC,wCAAwC,CAChD,iBAAiB,EAAE,iBAAiB,GACnC,kBAAkB;IAWrB;;;;OAIG;IACH,SAAS,CAAC,+BAA+B,CACvC,eAAe,EAAE,gBAAgB,GAChC,iBAAiB;IA8BpB;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAgBxD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),request_lambda_edge_adapter_exports={};__export(request_lambda_edge_adapter_exports,{RequestLambdaEdgeAdapter:()=>RequestLambdaEdgeAdapter});module.exports=__toCommonJS(request_lambda_edge_adapter_exports);var import_core=require("../../core"),import_lambda_edge=require("./lambda-edge.adapter");class RequestLambdaEdgeAdapter{constructor(options){var _a,_b;this.options=options,this.stripPathFn=(0,import_core.buildStripBasePath)((_a=this.options)==null?void 0:_a.stripBasePath);const disallowedHeaders=(0,import_core.getDefaultIfUndefined)((_b=this.options)==null?void 0:_b.disallowedHeaders,import_lambda_edge.DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS);this.cachedDisallowedHeaders=disallowedHeaders.map(disallowedHeader=>disallowedHeader instanceof RegExp?disallowedHeader:new RegExp(`(${disallowedHeader})`,"gim"))}getAdapterName(){return RequestLambdaEdgeAdapter.name}canHandle(event){var _a,_b,_c;const lambdaEdgeEvent=event;if(!Array.isArray(lambdaEdgeEvent==null?void 0:lambdaEdgeEvent.Records))return!1;const eventType=(_c=(_b=(_a=lambdaEdgeEvent.Records[0])==null?void 0:_a.cf)==null?void 0:_b.config)==null?void 0:_c.eventType;return eventType==="viewer-request"||eventType==="origin-request"}getRequest(event){const cloudFrontRequest=event.Records[0].cf.request,method=cloudFrontRequest.method,path=this.stripPathFn((0,import_core.getPathWithQueryStringParams)(cloudFrontRequest.uri,cloudFrontRequest.querystring)),remoteAddress=cloudFrontRequest.clientIp,headers=this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);let body;if(cloudFrontRequest.body){const[buffer,contentLength]=(0,import_core.getEventBodyAsBuffer)(cloudFrontRequest.body.data,cloudFrontRequest.body.encoding==="base64");body=buffer,headers["content-length"]=contentLength.toString()}const{host}=headers;return{method,path,headers,body,remoteAddress,host,hostname:host}}getResponse({body,headers:frameworkHeaders,isBase64Encoded,statusCode,log,event}){var _a,_b,_c;const headers=this.getHeadersForCloudfrontResponse(frameworkHeaders),maxSizeInBytes=event.Records[0].cf.config.eventType==="origin-request"?(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.originMaxResponseSizeInBytes,import_lambda_edge.DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES):(0,import_core.getDefaultIfUndefined)((_b=this.options)==null?void 0:_b.viewerMaxResponseSizeInBytes,import_lambda_edge.DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES),response={body,status:statusCode.toString(),bodyEncoding:isBase64Encoded?"base64":"text",headers},bodyLength=body.length;return bodyLength<=maxSizeInBytes||((_c=this.options)!=null&&_c.onResponseSizeExceedLimit?this.options.onResponseSizeExceedLimit(response):log.error(`SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${bodyLength} of the max of ${maxSizeInBytes}.`)),response}onErrorWhileForwarding({error,delegatedResolver,respondWithErrors,log,event}){const body=respondWithErrors?error.stack:"",errorResponse=this.getResponse({event,statusCode:500,body:body||"",headers:{},isBase64Encoded:!1,log});delegatedResolver.succeed(errorResponse)}getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest){return Object.keys(cloudFrontRequest.headers).reduce((acc,headerKey)=>{const headerValue=cloudFrontRequest.headers[headerKey];return headerValue.length===1?acc[headerKey]=headerValue[0].value:acc[headerKey]=headerValue.map(header=>header.value).join(","),acc},{})}getHeadersForCloudfrontResponse(originalHeaders){return Object.keys(originalHeaders).reduce((acc,headerKey)=>{if(this.shouldStripHeader(headerKey))return acc;const lowercaseHeaderKey=headerKey.toLowerCase();acc[lowercaseHeaderKey]||(acc[lowercaseHeaderKey]=[]);const headerValue=originalHeaders[headerKey];if(!Array.isArray(headerValue))return acc[lowercaseHeaderKey].push({key:headerKey,value:headerValue||""}),acc;const headersArray=headerValue.map(value=>({key:headerKey,value}));return acc[lowercaseHeaderKey].push(...headersArray),acc},{})}shouldStripHeader(headerKey){var _a;if((_a=this.options)!=null&&_a.shouldStripHeader)return this.options.shouldStripHeader(headerKey);const headerKeyLowerCase=headerKey.toLowerCase();for(const stripHeaderIf of this.cachedDisallowedHeaders)if(stripHeaderIf.test(headerKeyLowerCase))return!0;return!1}}
|
|
2
|
+
//# sourceMappingURL=request-lambda-edge.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-lambda-edge.adapter.js","sources":["../../../src/adapters/aws/request-lambda-edge.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { CloudFrontRequest, Context } from 'aws-lambda';\nimport type {\n CloudFrontHeaders,\n CloudFrontResultResponse,\n} from 'aws-lambda/common/cloudfront';\nimport type {\n CloudFrontRequestEvent,\n CloudFrontRequestResult,\n} from 'aws-lambda/trigger/cloudfront-request';\nimport { BothValueHeaders, SingleValueHeaders } from '../../@types';\nimport {\n AdapterContract,\n AdapterRequest,\n GetResponseAdapterProps,\n OnErrorProps,\n} from '../../contracts';\nimport {\n StripBasePathFn,\n buildStripBasePath,\n getDefaultIfUndefined,\n getEventBodyAsBuffer,\n getPathWithQueryStringParams,\n} from '../../core';\nimport {\n DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,\n DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,\n DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,\n} from './lambda-edge.adapter';\n\n//#endregion\n\n//#endregion\n\n/**\n * The options to customize the {@link RequestLambdaEdgeAdapter}.\n *\n * @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter\n * @public\n */\nexport interface RequestLambdaEdgeAdapterOptions {\n /**\n * Strip base path for custom paths, like `/api`.\n *\n * @defaultValue ''\n */\n stripBasePath?: string;\n\n /**\n * The max response size in bytes of viewer request and viewer response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n viewerMaxResponseSizeInBytes?: number;\n\n /**\n * The max response size in bytes of origin request and origin response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n originMaxResponseSizeInBytes?: number;\n\n /**\n * The function called when the response size exceed the max limits of the Lambda\\@edge\n *\n * @param response - The response from framework that exceed the limit of Lambda\\@edge\n * @defaultValue undefined\n */\n onResponseSizeExceedLimit?: (\n response: CloudFrontRequestResult,\n ) => CloudFrontRequestResult;\n\n /**\n * The headers that will be stripped from the headers object because Lambda\\@edge will fail if these headers are passed in the response.\n *\n * @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)\n *\n * @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.\n */\n disallowedHeaders?: (string | RegExp)[];\n\n /**\n * If you want to change how we check against the header if it should be stripped, you can pass a function to this property.\n *\n * @param header - The header of the response\n * @defaultValue The default method is implemented to test the header against the list {@link RequestLambdaEdgeAdapterOptions.disallowedHeaders}.\n */\n shouldStripHeader?: (header: string) => boolean;\n}\n\n/**\n * The adapter to handle requests from AWS Lambda\\@Edge of the type Viewer Request.\n *\n * The idea of this Adapter is to you be able to expose your framework to the Edge, like when you build for Cloudfront.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}\n *\n * @example\n * ```typescript\n * const stripBasePath = '/api'; // in case you have configure the cloudfront to forward the path /api to your lambda\n * const adapter = new RequestLambdaEdgeAdapter({ stripBasePath });\n * ```\n *\n * @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter\n * @public\n */\nexport class RequestLambdaEdgeAdapter\n implements\n AdapterContract<CloudFrontRequestEvent, Context, CloudFrontResultResponse>\n{\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link RequestLambdaEdgeAdapter}\n */\n constructor(protected readonly options?: RequestLambdaEdgeAdapterOptions) {\n this.stripPathFn = buildStripBasePath(this.options?.stripBasePath);\n\n const disallowedHeaders = getDefaultIfUndefined(\n this.options?.disallowedHeaders,\n DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,\n );\n\n this.cachedDisallowedHeaders = disallowedHeaders.map(disallowedHeader => {\n if (disallowedHeader instanceof RegExp) return disallowedHeader;\n\n return new RegExp(`(${disallowedHeader})`, 'gim');\n });\n }\n\n //#endregion\n\n //#region Protected Properties\n\n /**\n * Strip base path function\n */\n protected readonly stripPathFn: StripBasePathFn;\n\n /**\n * This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.\n */\n protected readonly cachedDisallowedHeaders: RegExp[];\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return RequestLambdaEdgeAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is CloudFrontRequestEvent {\n const lambdaEdgeEvent = event as Partial<CloudFrontRequestEvent>;\n\n if (!Array.isArray(lambdaEdgeEvent?.Records)) return false;\n\n const eventType = lambdaEdgeEvent.Records[0]?.cf?.config?.eventType;\n\n return eventType === 'viewer-request' || eventType === 'origin-request';\n }\n\n /**\n * {@inheritDoc}\n */\n public getRequest(event: CloudFrontRequestEvent): AdapterRequest {\n const request = event.Records[0];\n const cloudFrontRequest = request.cf.request;\n\n const method = cloudFrontRequest.method;\n\n const path = this.stripPathFn(\n getPathWithQueryStringParams(\n cloudFrontRequest.uri,\n cloudFrontRequest.querystring,\n ),\n );\n const remoteAddress = cloudFrontRequest.clientIp;\n\n const headers =\n this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);\n\n let body: Buffer | undefined;\n\n if (cloudFrontRequest.body) {\n const [buffer, contentLength] = getEventBodyAsBuffer(\n cloudFrontRequest.body.data,\n cloudFrontRequest.body.encoding === 'base64',\n );\n\n body = buffer;\n headers['content-length'] = contentLength.toString();\n }\n\n const { host } = headers;\n\n return {\n method,\n path,\n headers,\n body,\n remoteAddress,\n host,\n hostname: host,\n };\n }\n\n /**\n * {@inheritDoc}\n */\n public getResponse({\n body,\n headers: frameworkHeaders,\n isBase64Encoded,\n statusCode,\n log,\n event,\n }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontResultResponse {\n const headers = this.getHeadersForCloudfrontResponse(frameworkHeaders);\n\n const maxSizeInBytes =\n event.Records[0].cf.config.eventType === 'origin-request'\n ? getDefaultIfUndefined(\n this.options?.originMaxResponseSizeInBytes,\n DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,\n )\n : getDefaultIfUndefined(\n this.options?.viewerMaxResponseSizeInBytes,\n DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,\n );\n\n const response: CloudFrontResultResponse = {\n body,\n status: statusCode.toString(),\n bodyEncoding: isBase64Encoded ? 'base64' : 'text',\n headers,\n };\n\n // probably is not correctly accurate, but it's a good approximation\n const bodyLength = body.length;\n\n if (bodyLength <= maxSizeInBytes) return response;\n\n if (this.options?.onResponseSizeExceedLimit)\n this.options.onResponseSizeExceedLimit(response);\n else {\n log.error(\n `SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${bodyLength} of the max of ${maxSizeInBytes}.`,\n );\n }\n\n return response;\n }\n\n /**\n * {@inheritDoc}\n */\n public onErrorWhileForwarding({\n error,\n delegatedResolver,\n respondWithErrors,\n log,\n event,\n }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void {\n const body = respondWithErrors ? error.stack : '';\n const errorResponse = this.getResponse({\n event,\n statusCode: 500,\n body: body || '',\n headers: {},\n isBase64Encoded: false,\n log,\n });\n\n delegatedResolver.succeed(errorResponse);\n }\n\n //#endregion\n\n //#region Protected Methods\n\n /**\n * Returns the headers with the flattened (non-list) values of the cloudfront request headers\n *\n * @param cloudFrontRequest - The cloudfront request\n */\n protected getFlattenedHeadersFromCloudfrontRequest(\n cloudFrontRequest: CloudFrontRequest,\n ): SingleValueHeaders {\n return Object.keys(cloudFrontRequest.headers).reduce((acc, headerKey) => {\n const headerValue = cloudFrontRequest.headers[headerKey];\n\n if (headerValue.length === 1) acc[headerKey] = headerValue[0].value;\n else acc[headerKey] = headerValue.map(header => header.value).join(',');\n\n return acc;\n }, {} as SingleValueHeaders);\n }\n\n /**\n * Returns headers in Cloudfront Response format.\n *\n * @param originalHeaders - The original version of the request sent by the framework\n */\n protected getHeadersForCloudfrontResponse(\n originalHeaders: BothValueHeaders,\n ): CloudFrontHeaders {\n return Object.keys(originalHeaders).reduce((acc, headerKey) => {\n if (this.shouldStripHeader(headerKey)) return acc;\n\n const lowercaseHeaderKey = headerKey.toLowerCase();\n\n if (!acc[lowercaseHeaderKey]) acc[lowercaseHeaderKey] = [];\n\n const headerValue = originalHeaders[headerKey];\n\n if (!Array.isArray(headerValue)) {\n acc[lowercaseHeaderKey].push({\n key: headerKey,\n value: headerValue || '',\n });\n\n return acc;\n }\n\n const headersArray = headerValue.map(value => ({\n key: headerKey,\n value: value,\n }));\n\n acc[lowercaseHeaderKey].push(...headersArray);\n\n return acc;\n }, {} as CloudFrontHeaders);\n }\n\n /**\n * Returns the information if we should remove the response header\n *\n * @param headerKey - The header that will be tested\n */\n protected shouldStripHeader(headerKey: string): boolean {\n if (this.options?.shouldStripHeader)\n return this.options.shouldStripHeader(headerKey);\n\n const headerKeyLowerCase = headerKey.toLowerCase();\n\n for (const stripHeaderIf of this.cachedDisallowedHeaders) {\n if (!stripHeaderIf.test(headerKeyLowerCase)) continue;\n\n return true;\n }\n\n return false;\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,oCAAA,CAAA,EAAA,SAAA,oCAAA,CAAA,yBAAA,IAAA,wBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,mCAAA,EAkBA,IAMO,YAAA,QAAA,YAAA,EAKA,mBAAA,QAAA,uBAAA,EAmFA,MAAM,wBAGb,CAQE,YAA+B,QAA2C,WAA3C,KAAA,QAAA,QAC7B,KAAK,eAAc,YAAA,qBAAmB,QAAK,UAAL,eAAc,aAAa,EAEjE,MAAM,qBAAoB,YAAA,wBACxB,QAAK,UAAL,eAAc,kBACd,mBAAA,sCAAA,EAGG,KAAA,wBAA0B,kBAAkB,IAAwB,kBACnE,4BAA4B,OAAe,iBAExC,IAAI,OAAO,IAAI,gBAAgB,IAAK,KAAK,CACjD,CACH,CAuBO,gBAAyB,CAC9B,OAAO,yBAAyB,IAClC,CAKO,UAAU,MAAiD,cAChE,MAAM,gBAAkB,MAExB,GAAI,CAAC,MAAM,QAAQ,6CAAiB,OAAO,EAAU,MAAA,GAErD,MAAM,WAAY,2BAAgB,QAAQ,CAAC,IAAzB,eAA4B,KAA5B,eAAgC,SAAhC,eAAwC,UAEnD,OAAA,YAAc,kBAAoB,YAAc,gBACzD,CAKO,WAAW,MAA+C,CAEzD,MAAA,kBADU,MAAM,QAAQ,CAAC,EACG,GAAG,QAE/B,OAAS,kBAAkB,OAE3B,KAAO,KAAK,eAChB,YAAA,8BACE,kBAAkB,IAClB,kBAAkB,WACpB,CAAA,EAEI,cAAgB,kBAAkB,SAElC,QACJ,KAAK,yCAAyC,iBAAiB,EAE7D,IAAA,KAEJ,GAAI,kBAAkB,KAAM,CACpB,KAAA,CAAC,OAAQ,aAAa,KAAI,YAAA,sBAC9B,kBAAkB,KAAK,KACvB,kBAAkB,KAAK,WAAa,QAAA,EAG/B,KAAA,OACC,QAAA,gBAAgB,EAAI,cAAc,SAAS,CACrD,CAEM,KAAA,CAAE,IAAS,EAAA,QAEV,MAAA,CACL,OACA,KACA,QACA,KACA,cACA,KACA,SAAU,IAAA,CAEd,CAKO,YAAY,CACjB,KACA,QAAS,iBACT,gBACA,WACA,IACA,KAAA,EAC4E,cACtE,MAAA,QAAU,KAAK,gCAAgC,gBAAgB,EAE/D,eACJ,MAAM,QAAQ,CAAC,EAAE,GAAG,OAAO,YAAc,oBACrC,YAAA,wBACE,QAAK,UAAL,eAAc,6BACd,mBAAA,yCAAA,KAEF,YAAA,wBACE,QAAK,UAAL,eAAc,6BACd,mBAAA,yCAAA,EAGF,SAAqC,CACzC,KACA,OAAQ,WAAW,SAAS,EAC5B,aAAc,gBAAkB,SAAW,OAC3C,OAAA,EAII,WAAa,KAAK,OAExB,OAAI,YAAc,kBAEd,QAAK,UAAL,SAAc,0BACX,KAAA,QAAQ,0BAA0B,QAAQ,EAE3C,IAAA,MACF,uEAAuE,UAAU,kBAAkB,cAAc,GAAA,GAI9G,QACT,CAKO,uBAAuB,CAC5B,MACA,kBACA,kBACA,IACA,KAAA,EACsE,CAChE,MAAA,KAAO,kBAAoB,MAAM,MAAQ,GACzC,cAAgB,KAAK,YAAY,CACrC,MACA,WAAY,IACZ,KAAM,MAAQ,GACd,QAAS,CAAC,EACV,gBAAiB,GACjB,GAAA,CACD,EAED,kBAAkB,QAAQ,aAAa,CACzC,CAWU,yCACR,kBACoB,CACb,OAAA,OAAO,KAAK,kBAAkB,OAAO,EAAE,OAAO,CAAC,IAAK,YAAc,CACjE,MAAA,YAAc,kBAAkB,QAAQ,SAAS,EAEvD,OAAI,YAAY,SAAW,EAAG,IAAI,SAAS,EAAI,YAAY,CAAC,EAAE,MACrD,IAAA,SAAS,EAAI,YAAY,YAAc,OAAO,KAAK,EAAE,KAAK,GAAG,EAE/D,GACT,EAAG,CAAwB,CAAA,CAC7B,CAOU,gCACR,gBACmB,CACnB,OAAO,OAAO,KAAK,eAAe,EAAE,OAAO,CAAC,IAAK,YAAc,CACzD,GAAA,KAAK,kBAAkB,SAAS,EAAU,OAAA,IAExC,MAAA,mBAAqB,UAAU,cAEhC,IAAI,kBAAkB,IAAO,IAAA,kBAAkB,EAAI,IAElD,MAAA,YAAc,gBAAgB,SAAS,EAE7C,GAAI,CAAC,MAAM,QAAQ,WAAW,EACxB,WAAA,kBAAkB,EAAE,KAAK,CAC3B,IAAK,UACL,MAAO,aAAe,EAAA,CACvB,EAEM,IAGH,MAAA,aAAe,YAAY,IAAc,QAAA,CAC7C,IAAK,UACL,KACA,EAAA,EAEF,WAAI,kBAAkB,EAAE,KAAK,GAAG,YAAY,EAErC,GACT,EAAG,CAAuB,CAAA,CAC5B,CAOU,kBAAkB,UAA4B,QACtD,IAAI,QAAK,UAAL,SAAc,kBACT,OAAA,KAAK,QAAQ,kBAAkB,SAAS,EAE3C,MAAA,mBAAqB,UAAU,cAE1B,UAAA,iBAAiB,KAAK,wBAC3B,GAAC,cAAc,KAAK,kBAAkB,EAEnC,MAAA,GAGF,MAAA,EACT,CAGF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { S3Event } from 'aws-lambda';
|
|
2
|
+
import { AwsSimpleAdapter } from './base/index';
|
|
3
|
+
/**
|
|
4
|
+
* The options to customize the {@link S3Adapter}
|
|
5
|
+
*
|
|
6
|
+
* @breadcrumb Adapters / AWS / S3Adapter
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface S3AdapterOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The path that will be used to create a request to be forwarded to the framework.
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue /s3
|
|
14
|
+
*/
|
|
15
|
+
s3ForwardPath?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The http method that will be used to create a request to be forwarded to the framework.
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue POST
|
|
20
|
+
*/
|
|
21
|
+
s3ForwardMethod?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The adapter to handle requests from AWS S3.
|
|
25
|
+
*
|
|
26
|
+
* The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.
|
|
27
|
+
*
|
|
28
|
+
* {@link https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html | Event Reference}
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const s3ForwardPath = '/your/route/s3'; // default /s3
|
|
33
|
+
* const s3ForwardMethod = 'POST'; // default POST
|
|
34
|
+
* const adapter = new S3Adapter({ s3ForwardPath, s3ForwardMethod });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @breadcrumb Adapters / AWS / S3Adapter
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare class S3Adapter extends AwsSimpleAdapter<S3Event> {
|
|
41
|
+
/**
|
|
42
|
+
* Default constructor
|
|
43
|
+
*
|
|
44
|
+
* @param options - The options to customize the {@link SNSAdapter}
|
|
45
|
+
*/
|
|
46
|
+
constructor(options?: S3AdapterOptions);
|
|
47
|
+
/**
|
|
48
|
+
* {@inheritDoc}
|
|
49
|
+
*/
|
|
50
|
+
getAdapterName(): string;
|
|
51
|
+
/**
|
|
52
|
+
* {@inheritDoc}
|
|
53
|
+
*/
|
|
54
|
+
canHandle(event: unknown): event is S3Event;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=s3.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/s3.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,SAAU,SAAQ,gBAAgB,CAAC,OAAO,CAAC;IAGtD;;;;OAIG;gBACS,OAAO,CAAC,EAAE,gBAAgB;IAatC;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO;CAWnD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),s3_adapter_exports={};__export(s3_adapter_exports,{S3Adapter:()=>S3Adapter});module.exports=__toCommonJS(s3_adapter_exports);var import_core=require("../../core"),import_base=require("./base/index");class S3Adapter extends import_base.AwsSimpleAdapter{constructor(options){super({forwardPath:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.s3ForwardPath,"/s3"),forwardMethod:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.s3ForwardMethod,"POST"),batch:!1,host:"s3.amazonaws.com"})}getAdapterName(){return S3Adapter.name}canHandle(event){var _a;const s3Event=event;return Array.isArray(s3Event==null?void 0:s3Event.Records)?((_a=s3Event.Records[0])==null?void 0:_a.eventSource)==="aws:s3":!1}}
|
|
2
2
|
//# sourceMappingURL=s3.adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3.adapter.js","sources":["../../../src/adapters/aws/s3.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { S3Event } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link S3Adapter}\n *\n * @breadcrumb Adapters / AWS / S3Adapter\n * @public\n */\nexport interface S3AdapterOptions {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /s3\n */\n s3ForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n s3ForwardMethod?: string;\n}\n\n/**\n * The adapter to handle requests from AWS S3.\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/
|
|
1
|
+
{"version":3,"file":"s3.adapter.js","sources":["../../../src/adapters/aws/s3.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { S3Event } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link S3Adapter}\n *\n * @breadcrumb Adapters / AWS / S3Adapter\n * @public\n */\nexport interface S3AdapterOptions {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /s3\n */\n s3ForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n s3ForwardMethod?: string;\n}\n\n/**\n * The adapter to handle requests from AWS S3.\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html | Event Reference}\n *\n * @example\n * ```typescript\n * const s3ForwardPath = '/your/route/s3'; // default /s3\n * const s3ForwardMethod = 'POST'; // default POST\n * const adapter = new S3Adapter({ s3ForwardPath, s3ForwardMethod });\n * ```\n *\n * @breadcrumb Adapters / AWS / S3Adapter\n * @public\n */\nexport class S3Adapter extends AwsSimpleAdapter<S3Event> {\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link SNSAdapter}\n */\n constructor(options?: S3AdapterOptions) {\n super({\n forwardPath: getDefaultIfUndefined(options?.s3ForwardPath, '/s3'),\n forwardMethod: getDefaultIfUndefined(options?.s3ForwardMethod, 'POST'),\n batch: false,\n host: 's3.amazonaws.com',\n });\n }\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return S3Adapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is S3Event {\n const s3Event = event as Partial<S3Event>;\n\n if (!Array.isArray(s3Event?.Records)) return false;\n\n const eventSource = s3Event.Records[0]?.eventSource;\n\n return eventSource === 'aws:s3';\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,mBAAA,CAAA,EAAA,SAAA,mBAAA,CAAA,UAAA,IAAA,SAAA,CAAA,EAAA,OAAA,QAAA,aAAA,kBAAA,EAGA,IAAsC,YAAA,QAAA,YAAA,EACL,YAAA,QAAA,cAAA,EA2C1B,MAAM,kBAAkB,YAA0B,gBAAA,CAQvD,YAAY,QAA4B,CAChC,MAAA,CACJ,eAAa,YAAA,uBAAsB,6BAAS,cAAe,KAAK,EAChE,iBAAe,YAAA,uBAAsB,6BAAS,gBAAiB,MAAM,EACrE,MAAO,GACP,KAAM,kBAAA,CACP,CACH,CASO,gBAAyB,CAC9B,OAAO,UAAU,IACnB,CAKO,UAAU,MAAkC,QACjD,MAAM,QAAU,MAEhB,OAAK,MAAM,QAAQ,6BAAS,OAAO,IAEf,WAAQ,QAAQ,CAAC,IAAjB,eAAoB,eAEjB,SAJsB,EAK/C,CAGF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { SNSEvent } from 'aws-lambda';
|
|
2
|
+
import { AwsSimpleAdapter } from './base/index';
|
|
3
|
+
/**
|
|
4
|
+
* The options to customize the {@link SNSAdapter}
|
|
5
|
+
*
|
|
6
|
+
* @breadcrumb Adapters / AWS / SNSAdapter
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface SNSAdapterOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The path that will be used to create a request to be forwarded to the framework.
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue /sns
|
|
14
|
+
*/
|
|
15
|
+
snsForwardPath?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The http method that will be used to create a request to be forwarded to the framework.
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue POST
|
|
20
|
+
*/
|
|
21
|
+
snsForwardMethod?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The adapter to handle requests from AWS SNS.
|
|
25
|
+
*
|
|
26
|
+
* The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.
|
|
27
|
+
*
|
|
28
|
+
* {@link https://docs.aws.amazon.com/lambda/latest/dg/with-sns.html | Event Reference}
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const snsForwardPath = '/your/route/sns'; // default /sns
|
|
33
|
+
* const snsForwardMethod = 'POST'; // default POST
|
|
34
|
+
* const adapter = new SNSAdapter({ snsForwardPath, snsForwardMethod });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @breadcrumb Adapters / AWS / SNSAdapter
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare class SNSAdapter extends AwsSimpleAdapter<SNSEvent> {
|
|
41
|
+
/**
|
|
42
|
+
* Default constructor
|
|
43
|
+
*
|
|
44
|
+
* @param options - The options to customize the {@link SNSAdapter}
|
|
45
|
+
*/
|
|
46
|
+
constructor(options?: SNSAdapterOptions);
|
|
47
|
+
/**
|
|
48
|
+
* {@inheritDoc}
|
|
49
|
+
*/
|
|
50
|
+
getAdapterName(): string;
|
|
51
|
+
/**
|
|
52
|
+
* {@inheritDoc}
|
|
53
|
+
*/
|
|
54
|
+
canHandle(event: unknown): event is SNSEvent;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=sns.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sns.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/sns.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,UAAW,SAAQ,gBAAgB,CAAC,QAAQ,CAAC;IAGxD;;;;OAIG;gBACS,OAAO,CAAC,EAAE,iBAAiB;IAavC;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ;CAWpD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),sns_adapter_exports={};__export(sns_adapter_exports,{SNSAdapter:()=>SNSAdapter});module.exports=__toCommonJS(sns_adapter_exports);var import_core=require("../../core"),import_base=require("./base/index");class SNSAdapter extends import_base.AwsSimpleAdapter{constructor(options){super({forwardPath:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.snsForwardPath,"/sns"),forwardMethod:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.snsForwardMethod,"POST"),batch:!1,host:"sns.amazonaws.com"})}getAdapterName(){return SNSAdapter.name}canHandle(event){var _a;const snsEvent=event;return Array.isArray(snsEvent==null?void 0:snsEvent.Records)?((_a=snsEvent.Records[0])==null?void 0:_a.EventSource)==="aws:sns":!1}}
|
|
2
2
|
//# sourceMappingURL=sns.adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sns.adapter.js","sources":["../../../src/adapters/aws/sns.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { SNSEvent } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link SNSAdapter}\n *\n * @breadcrumb Adapters / AWS / SNSAdapter\n * @public\n */\nexport interface SNSAdapterOptions {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /sns\n */\n snsForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n snsForwardMethod?: string;\n}\n\n/**\n * The adapter to handle requests from AWS SNS.\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/
|
|
1
|
+
{"version":3,"file":"sns.adapter.js","sources":["../../../src/adapters/aws/sns.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { SNSEvent } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link SNSAdapter}\n *\n * @breadcrumb Adapters / AWS / SNSAdapter\n * @public\n */\nexport interface SNSAdapterOptions {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /sns\n */\n snsForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n snsForwardMethod?: string;\n}\n\n/**\n * The adapter to handle requests from AWS SNS.\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/with-sns.html | Event Reference}\n *\n * @example\n * ```typescript\n * const snsForwardPath = '/your/route/sns'; // default /sns\n * const snsForwardMethod = 'POST'; // default POST\n * const adapter = new SNSAdapter({ snsForwardPath, snsForwardMethod });\n * ```\n *\n * @breadcrumb Adapters / AWS / SNSAdapter\n * @public\n */\nexport class SNSAdapter extends AwsSimpleAdapter<SNSEvent> {\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link SNSAdapter}\n */\n constructor(options?: SNSAdapterOptions) {\n super({\n forwardPath: getDefaultIfUndefined(options?.snsForwardPath, '/sns'),\n forwardMethod: getDefaultIfUndefined(options?.snsForwardMethod, 'POST'),\n batch: false,\n host: 'sns.amazonaws.com',\n });\n }\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return SNSAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is SNSEvent {\n const snsEvent = event as Partial<SNSEvent>;\n\n if (!Array.isArray(snsEvent?.Records)) return false;\n\n const eventSource = snsEvent.Records[0]?.EventSource;\n\n return eventSource === 'aws:sns';\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,oBAAA,CAAA,EAAA,SAAA,oBAAA,CAAA,WAAA,IAAA,UAAA,CAAA,EAAA,OAAA,QAAA,aAAA,mBAAA,EAGA,IAAsC,YAAA,QAAA,YAAA,EACL,YAAA,QAAA,cAAA,EA2C1B,MAAM,mBAAmB,YAA2B,gBAAA,CAQzD,YAAY,QAA6B,CACjC,MAAA,CACJ,eAAa,YAAA,uBAAsB,6BAAS,eAAgB,MAAM,EAClE,iBAAe,YAAA,uBAAsB,6BAAS,iBAAkB,MAAM,EACtE,MAAO,GACP,KAAM,mBAAA,CACP,CACH,CASO,gBAAyB,CAC9B,OAAO,WAAW,IACpB,CAKO,UAAU,MAAmC,QAClD,MAAM,SAAW,MAEjB,OAAK,MAAM,QAAQ,+BAAU,OAAO,IAEhB,YAAS,QAAQ,CAAC,IAAlB,eAAqB,eAElB,UAJuB,EAKhD,CAGF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { SQSEvent } from 'aws-lambda';
|
|
2
|
+
import { AWSSimpleAdapterOptions, AwsSimpleAdapter } from './base/index';
|
|
3
|
+
/**
|
|
4
|
+
* The options to customize the {@link SQSAdapter}
|
|
5
|
+
*
|
|
6
|
+
* @breadcrumb Adapters / AWS / SQSAdapter
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface SQSAdapterOptions extends Pick<AWSSimpleAdapterOptions, 'batch'> {
|
|
10
|
+
/**
|
|
11
|
+
* The path that will be used to create a request to be forwarded to the framework.
|
|
12
|
+
*
|
|
13
|
+
* @defaultValue /sqs
|
|
14
|
+
*/
|
|
15
|
+
sqsForwardPath?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The http method that will be used to create a request to be forwarded to the framework.
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue POST
|
|
20
|
+
*/
|
|
21
|
+
sqsForwardMethod?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The adapter to handle requests from AWS SQS.
|
|
25
|
+
*
|
|
26
|
+
* The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.
|
|
27
|
+
*
|
|
28
|
+
* {@link https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html | Event Reference}
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const sqsForwardPath = '/your/route/sqs'; // default /sqs
|
|
33
|
+
* const sqsForwardMethod = 'POST'; // default POST
|
|
34
|
+
* const adapter = new SQSAdapter({ sqsForwardPath, sqsForwardMethod });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @breadcrumb Adapters / AWS / SQSAdapter
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare class SQSAdapter extends AwsSimpleAdapter<SQSEvent> {
|
|
41
|
+
/**
|
|
42
|
+
* Default constructor
|
|
43
|
+
*
|
|
44
|
+
* @param options - The options to customize the {@link SNSAdapter}
|
|
45
|
+
*/
|
|
46
|
+
constructor(options?: SQSAdapterOptions);
|
|
47
|
+
/**
|
|
48
|
+
* {@inheritDoc}
|
|
49
|
+
*/
|
|
50
|
+
getAdapterName(): string;
|
|
51
|
+
/**
|
|
52
|
+
* {@inheritDoc}
|
|
53
|
+
*/
|
|
54
|
+
canHandle(event: unknown): event is SQSEvent;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=sqs.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqs.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/sqs.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIzE;;;;;GAKG;AACH,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,uBAAuB,EAAE,OAAO,CAAC;IAC9C;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,UAAW,SAAQ,gBAAgB,CAAC,QAAQ,CAAC;IAGxD;;;;OAIG;gBACS,OAAO,CAAC,EAAE,iBAAiB;IAavC;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ;CAWpD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),sqs_adapter_exports={};__export(sqs_adapter_exports,{SQSAdapter:()=>SQSAdapter});module.exports=__toCommonJS(sqs_adapter_exports);var import_core=require("../../core"),import_base=require("./base/index");class SQSAdapter extends import_base.AwsSimpleAdapter{constructor(options){super({forwardPath:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.sqsForwardPath,"/sqs"),forwardMethod:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.sqsForwardMethod,"POST"),batch:options==null?void 0:options.batch,host:"sqs.amazonaws.com"})}getAdapterName(){return SQSAdapter.name}canHandle(event){var _a;const sqsEvent=event;return Array.isArray(sqsEvent==null?void 0:sqsEvent.Records)?((_a=sqsEvent.Records[0])==null?void 0:_a.eventSource)==="aws:sqs":!1}}
|
|
2
2
|
//# sourceMappingURL=sqs.adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqs.adapter.js","sources":["../../../src/adapters/aws/sqs.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { SQSEvent } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AWSSimpleAdapterOptions, AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link SQSAdapter}\n *\n * @breadcrumb Adapters / AWS / SQSAdapter\n * @public\n */\nexport interface SQSAdapterOptions\n extends Pick<AWSSimpleAdapterOptions, 'batch'> {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /sqs\n */\n sqsForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n sqsForwardMethod?: string;\n}\n\n/**\n * The adapter to handle requests from AWS SQS.\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/
|
|
1
|
+
{"version":3,"file":"sqs.adapter.js","sources":["../../../src/adapters/aws/sqs.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { SQSEvent } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AWSSimpleAdapterOptions, AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link SQSAdapter}\n *\n * @breadcrumb Adapters / AWS / SQSAdapter\n * @public\n */\nexport interface SQSAdapterOptions\n extends Pick<AWSSimpleAdapterOptions, 'batch'> {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /sqs\n */\n sqsForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n sqsForwardMethod?: string;\n}\n\n/**\n * The adapter to handle requests from AWS SQS.\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html | Event Reference}\n *\n * @example\n * ```typescript\n * const sqsForwardPath = '/your/route/sqs'; // default /sqs\n * const sqsForwardMethod = 'POST'; // default POST\n * const adapter = new SQSAdapter({ sqsForwardPath, sqsForwardMethod });\n * ```\n *\n * @breadcrumb Adapters / AWS / SQSAdapter\n * @public\n */\nexport class SQSAdapter extends AwsSimpleAdapter<SQSEvent> {\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link SNSAdapter}\n */\n constructor(options?: SQSAdapterOptions) {\n super({\n forwardPath: getDefaultIfUndefined(options?.sqsForwardPath, '/sqs'),\n forwardMethod: getDefaultIfUndefined(options?.sqsForwardMethod, 'POST'),\n batch: options?.batch,\n host: 'sqs.amazonaws.com',\n });\n }\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return SQSAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is SQSEvent {\n const sqsEvent = event as Partial<SQSEvent>;\n\n if (!Array.isArray(sqsEvent?.Records)) return false;\n\n const eventSource = sqsEvent.Records[0]?.eventSource;\n\n return eventSource === 'aws:sqs';\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,oBAAA,CAAA,EAAA,SAAA,oBAAA,CAAA,WAAA,IAAA,UAAA,CAAA,EAAA,OAAA,QAAA,aAAA,mBAAA,EAGA,IAAsC,YAAA,QAAA,YAAA,EACoB,YAAA,QAAA,cAAA,EA4CnD,MAAM,mBAAmB,YAA2B,gBAAA,CAQzD,YAAY,QAA6B,CACjC,MAAA,CACJ,eAAa,YAAA,uBAAsB,6BAAS,eAAgB,MAAM,EAClE,iBAAe,YAAA,uBAAsB,6BAAS,iBAAkB,MAAM,EACtE,MAAO,6BAAS,MAChB,KAAM,mBAAA,CACP,CACH,CASO,gBAAyB,CAC9B,OAAO,WAAW,IACpB,CAKO,UAAU,MAAmC,QAClD,MAAM,SAAW,MAEjB,OAAK,MAAM,QAAQ,+BAAU,OAAO,IAEhB,YAAS,QAAQ,CAAC,IAAlB,eAAqB,eAElB,UAJuB,EAKhD,CAGF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Context, Cookie, HttpRequest, HttpResponseSimple } from '@azure/functions';
|
|
2
|
+
import { BothValueHeaders } from '../../@types';
|
|
3
|
+
import { AdapterContract, AdapterRequest, GetResponseAdapterProps, OnErrorProps } from '../../contracts';
|
|
4
|
+
/**
|
|
5
|
+
* The options to customize the {@link HttpTriggerV4Adapter}
|
|
6
|
+
*
|
|
7
|
+
* @breadcrumb Adapters / Azure / HttpTriggerV4Adapter
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface HttpTriggerV4AdapterOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Strip base path for custom domains
|
|
13
|
+
*
|
|
14
|
+
* @defaultValue ''
|
|
15
|
+
*/
|
|
16
|
+
stripBasePath?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The adapter to handle requests from Http Trigger on Azure Function V4.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const stripBasePath = '/any/custom/base/path'; // default ''
|
|
24
|
+
* const adapter = new HttpTriggerV4Adapter({ stripBasePath });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node | Reference}
|
|
28
|
+
*
|
|
29
|
+
* @breadcrumb Adapters / Azure / HttpTriggerV4Adapter
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare class HttpTriggerV4Adapter implements AdapterContract<HttpRequest, Context, HttpResponseSimple> {
|
|
33
|
+
protected readonly options?: HttpTriggerV4AdapterOptions | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Default constructor
|
|
36
|
+
*
|
|
37
|
+
* @param options - The options to customize the {@link HttpTriggerV4Adapter}
|
|
38
|
+
*/
|
|
39
|
+
constructor(options?: HttpTriggerV4AdapterOptions | undefined);
|
|
40
|
+
/**
|
|
41
|
+
* {@inheritDoc}
|
|
42
|
+
*/
|
|
43
|
+
getAdapterName(): string;
|
|
44
|
+
/**
|
|
45
|
+
* {@inheritDoc}
|
|
46
|
+
*/
|
|
47
|
+
canHandle(event: unknown, context: unknown): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* {@inheritDoc}
|
|
50
|
+
*/
|
|
51
|
+
getRequest(event: HttpRequest): AdapterRequest;
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritDoc}
|
|
54
|
+
*/
|
|
55
|
+
getResponse({ body, statusCode, headers: originalHeaders, }: GetResponseAdapterProps<HttpRequest>): HttpResponseSimple;
|
|
56
|
+
/**
|
|
57
|
+
* {@inheritDoc}
|
|
58
|
+
*/
|
|
59
|
+
onErrorWhileForwarding({ error, respondWithErrors, event, delegatedResolver, log, }: OnErrorProps<HttpRequest, HttpResponseSimple>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Get path from event with query strings
|
|
62
|
+
*
|
|
63
|
+
* @param event - The event sent by serverless
|
|
64
|
+
*/
|
|
65
|
+
protected getPathFromEvent(event: HttpRequest): string;
|
|
66
|
+
/**
|
|
67
|
+
* Get the Azure Cookie list parsed from set-cookie header.
|
|
68
|
+
*
|
|
69
|
+
* @param headers - The headers object
|
|
70
|
+
*/
|
|
71
|
+
protected getAzureCookiesFromHeaders(headers: BothValueHeaders): Cookie[];
|
|
72
|
+
/**
|
|
73
|
+
* Parse the string cookie to the Azure Cookie Object.
|
|
74
|
+
* This code was written by {@link https://github.com/zachabney | @zachabney}
|
|
75
|
+
* on {@link https://github.com/zachabney/azure-aws-serverless-express/blob/241d2d5c4d5906e4817662cad6426ec2cbbf9ca7/src/index.js#L4-L49 | this library}.
|
|
76
|
+
*
|
|
77
|
+
* @param cookie - The cookie
|
|
78
|
+
*/
|
|
79
|
+
protected parseCookie(cookie: string): Cookie;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=http-trigger-v4.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-trigger-v4.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/http-trigger-v4.adapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,WAAW,EACX,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,YAAY,EACb,MAAM,iBAAiB,CAAC;AAUzB;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,oBACX,YAAW,eAAe,CAAC,WAAW,EAAE,OAAO,EAAE,kBAAkB,CAAC;IASxD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;IALvC;;;;OAIG;gBAC4B,OAAO,CAAC,yCAA6B;IAMpE;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;IAmB3D;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc;IA6BrD;;OAEG;IACI,WAAW,CAAC,EACjB,IAAI,EACJ,UAAU,EACV,OAAO,EAAE,eAAe,GACzB,EAAE,uBAAuB,CAAC,WAAW,CAAC,GAAG,kBAAkB;IAoB5D;;OAEG;IACI,sBAAsB,CAAC,EAC5B,KAAK,EACL,iBAAiB,EACjB,KAAK,EACL,iBAAiB,EACjB,GAAG,GACJ,EAAE,YAAY,CAAC,WAAW,EAAE,kBAAkB,CAAC,GAAG,IAAI;IAkBvD;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM;IAiBtD;;;;OAIG;IACH,SAAS,CAAC,0BAA0B,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,EAAE;IAYzE;;;;;;OAMG;IACH,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CA8C9C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),http_trigger_v4_adapter_exports={};__export(http_trigger_v4_adapter_exports,{HttpTriggerV4Adapter:()=>HttpTriggerV4Adapter});module.exports=__toCommonJS(http_trigger_v4_adapter_exports);var import_url=require("url"),import_core=require("../../core");class HttpTriggerV4Adapter{constructor(options){this.options=options}getAdapterName(){return HttpTriggerV4Adapter.name}canHandle(event,context){const maybeEvent=event,maybeContext=context;return!!(maybeEvent&&maybeEvent.method&&maybeEvent.headers&&maybeEvent.url&&maybeEvent.query&&maybeContext&&maybeContext.traceContext&&maybeContext.bindingDefinitions&&maybeContext.log&&maybeContext.log.info&&maybeContext.bindingData)}getRequest(event){const path=this.getPathFromEvent(event),method=event.method,headers=(0,import_core.getFlattenedHeadersMap)(event.headers,",",!0);let body;if(event.body){const[bufferBody,contentLength]=(0,import_core.getEventBodyAsBuffer)(event.rawBody,!1);body=bufferBody,headers["content-length"]=String(contentLength)}const remoteAddress=headers["x-forwarded-for"];return{method,path,headers,remoteAddress,body}}getResponse({body,statusCode,headers:originalHeaders}){const headers=(0,import_core.getFlattenedHeadersMap)(originalHeaders,",",!0),cookies=this.getAzureCookiesFromHeaders(originalHeaders);return headers["set-cookie"]&&delete headers["set-cookie"],{body,statusCode,headers,enableContentNegotiation:!1,cookies}}onErrorWhileForwarding({error,respondWithErrors,event,delegatedResolver,log}){const body=respondWithErrors?error.stack:"",errorResponse=this.getResponse({event,statusCode:500,body:body||"",headers:{},isBase64Encoded:!1,log});delegatedResolver.succeed(errorResponse)}getPathFromEvent(event){var _a;const stripBasePath=(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.stripBasePath,""),originalPath=new import_url.URL(event.url).pathname,replaceRegex=new RegExp(`^${stripBasePath}`),path=originalPath.replace(replaceRegex,""),queryParams=event.query;return(0,import_core.getPathWithQueryStringParams)(path,queryParams)}getAzureCookiesFromHeaders(headers){const setCookie=headers["set-cookie"];return(Array.isArray(setCookie)?setCookie:setCookie?[setCookie]:[]).map(cookie=>this.parseCookie(cookie))}parseCookie(cookie){return cookie.split(";").reduce((azureCookieObject,cookieProperty,index)=>{const[key,value]=cookieProperty.split("="),sanitizedKey=key.toLowerCase().trim(),sanitizedValue=value&&value.trim();if(index===0)return azureCookieObject.name=key,azureCookieObject.value=sanitizedValue,azureCookieObject;switch(sanitizedKey){case"domain":azureCookieObject.domain=sanitizedValue;break;case"path":azureCookieObject.path=sanitizedValue;break;case"expires":azureCookieObject.expires=new Date(sanitizedValue);break;case"secure":azureCookieObject.secure=!0;break;case"httponly":azureCookieObject.httpOnly=!0;break;case"samesite":azureCookieObject.sameSite=sanitizedValue;break;case"max-age":azureCookieObject.maxAge=Number(sanitizedValue);break}return azureCookieObject},{name:"",value:""})}}
|
|
2
2
|
//# sourceMappingURL=http-trigger-v4.adapter.js.map
|