@monorise/sst 1.0.0-dev.2 → 3.1.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/.sst/platform/src/components/aws/apigatewayv2.d.ts +1 -3
- package/dist/.sst/platform/src/components/aws/apigatewayv2.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/aurora.d.ts +4 -4
- package/dist/.sst/platform/src/components/aws/aurora.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/auth.d.ts +38 -3
- package/dist/.sst/platform/src/components/aws/auth.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/bucket.d.ts +102 -1
- package/dist/.sst/platform/src/components/aws/bucket.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/cluster.d.ts +1 -3
- package/dist/.sst/platform/src/components/aws/cluster.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/cognito-user-pool-client.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/cognito-user-pool.d.ts +4 -0
- package/dist/.sst/platform/src/components/aws/cognito-user-pool.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/dynamo.d.ts +0 -1
- package/dist/.sst/platform/src/components/aws/dynamo.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/email.d.ts +1 -1
- package/dist/.sst/platform/src/components/aws/fargate.d.ts +34 -0
- package/dist/.sst/platform/src/components/aws/fargate.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/function.d.ts +1 -3
- package/dist/.sst/platform/src/components/aws/function.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/helpers/arn.d.ts +5 -0
- package/dist/.sst/platform/src/components/aws/helpers/arn.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/open-search.d.ts +4 -4
- package/dist/.sst/platform/src/components/aws/open-search.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/opencontrol.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/permission.d.ts +13 -0
- package/dist/.sst/platform/src/components/aws/permission.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/postgres.d.ts +3 -3
- package/dist/.sst/platform/src/components/aws/postgres.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/realtime.d.ts +6 -0
- package/dist/.sst/platform/src/components/aws/realtime.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/redis.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/remix.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/router.d.ts +20 -14
- package/dist/.sst/platform/src/components/aws/router.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/service.d.ts +26 -0
- package/dist/.sst/platform/src/components/aws/service.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/solid-start.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/ssr-site.d.ts +197 -6
- package/dist/.sst/platform/src/components/aws/ssr-site.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/static-site.d.ts +5 -5
- package/dist/.sst/platform/src/components/aws/static-site.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/step-functions/state.d.ts +34 -0
- package/dist/.sst/platform/src/components/aws/step-functions/state.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/step-functions.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/svelte-kit.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/tan-stack-start.d.ts +1 -1
- package/dist/.sst/platform/src/components/aws/task.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/aws/vpc.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/base/base-ssr-site.d.ts +1 -99
- package/dist/.sst/platform/src/components/base/base-ssr-site.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/base/base-static-site.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/cloudflare/binding.d.ts +1 -1
- package/dist/.sst/platform/src/components/cloudflare/binding.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/cloudflare/bucket.d.ts +4 -2
- package/dist/.sst/platform/src/components/cloudflare/bucket.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/cloudflare/cron.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/cloudflare/d1.d.ts +1 -1
- package/dist/.sst/platform/src/components/cloudflare/experimental/astro.d.ts +186 -0
- package/dist/.sst/platform/src/components/cloudflare/experimental/astro.d.ts.map +1 -0
- package/dist/.sst/platform/src/components/cloudflare/experimental/index.d.ts +4 -0
- package/dist/.sst/platform/src/components/cloudflare/experimental/index.d.ts.map +1 -0
- package/dist/.sst/platform/src/components/cloudflare/experimental/solid-start.d.ts +171 -0
- package/dist/.sst/platform/src/components/cloudflare/experimental/solid-start.d.ts.map +1 -0
- package/dist/.sst/platform/src/components/cloudflare/experimental/static-site.d.ts +222 -0
- package/dist/.sst/platform/src/components/cloudflare/experimental/static-site.d.ts.map +1 -0
- package/dist/.sst/platform/src/components/cloudflare/helpers/fetch.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/cloudflare/helpers/worker-builder.d.ts +1 -1
- package/dist/.sst/platform/src/components/cloudflare/helpers/worker-builder.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/cloudflare/index.d.ts +4 -1
- package/dist/.sst/platform/src/components/cloudflare/index.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/cloudflare/kv.d.ts +8 -2
- package/dist/.sst/platform/src/components/cloudflare/kv.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/cloudflare/providers/kv-data.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/cloudflare/providers/worker-assets.d.ts +18 -0
- package/dist/.sst/platform/src/components/cloudflare/providers/worker-assets.d.ts.map +1 -0
- package/dist/.sst/platform/src/components/cloudflare/queue.d.ts +1 -1
- package/dist/.sst/platform/src/components/cloudflare/ssr-site.d.ts +34 -42
- package/dist/.sst/platform/src/components/cloudflare/ssr-site.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/cloudflare/worker.d.ts +28 -6
- package/dist/.sst/platform/src/components/cloudflare/worker.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/component.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/duration.d.ts +2 -1
- package/dist/.sst/platform/src/components/duration.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/rpc/rpc.d.ts +1 -0
- package/dist/.sst/platform/src/components/rpc/rpc.d.ts.map +1 -1
- package/dist/.sst/platform/src/components/secret.d.ts +1 -1
- package/dist/.sst/platform/src/config.d.ts +15 -0
- package/dist/.sst/platform/src/config.d.ts.map +1 -1
- package/dist/.sst/platform/src/util/fs.d.ts +5 -0
- package/dist/.sst/platform/src/util/fs.d.ts.map +1 -0
- package/dist/components/dashboard.d.ts +2 -0
- package/dist/components/dashboard.d.ts.map +1 -0
- package/dist/components/monorise-core.d.ts.map +1 -1
- package/dist/components/q-function.d.ts +1 -1
- package/dist/components/q-function.d.ts.map +1 -1
- package/dist/components/single-table.d.ts +2 -1
- package/dist/components/single-table.d.ts.map +1 -1
- package/dist/index.js +605 -7
- package/dist/index.js.map +1 -1
- package/dist/tsup.config.d.ts +3 -0
- package/dist/tsup.config.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/.sst/platform/src/components/aws/analog.js +0 -118
- package/dist/.sst/platform/src/components/aws/analog.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigateway-websocket-route.js +0 -110
- package/dist/.sst/platform/src/components/aws/apigateway-websocket-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigateway-websocket.js +0 -409
- package/dist/.sst/platform/src/components/aws/apigateway-websocket.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv1-api-key.js +0 -55
- package/dist/.sst/platform/src/components/aws/apigatewayv1-api-key.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv1-authorizer.js +0 -110
- package/dist/.sst/platform/src/components/aws/apigatewayv1-authorizer.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv1-base-route.js +0 -34
- package/dist/.sst/platform/src/components/aws/apigatewayv1-base-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv1-integration-route.js +0 -49
- package/dist/.sst/platform/src/components/aws/apigatewayv1-integration-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv1-lambda-route.js +0 -85
- package/dist/.sst/platform/src/components/aws/apigatewayv1-lambda-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv1-usage-plan.js +0 -66
- package/dist/.sst/platform/src/components/aws/apigatewayv1-usage-plan.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv1.js +0 -749
- package/dist/.sst/platform/src/components/aws/apigatewayv1.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv2-authorizer.js +0 -98
- package/dist/.sst/platform/src/components/aws/apigatewayv2-authorizer.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv2-base-route.js +0 -28
- package/dist/.sst/platform/src/components/aws/apigatewayv2-base-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv2-lambda-route.js +0 -84
- package/dist/.sst/platform/src/components/aws/apigatewayv2-lambda-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv2-private-route.js +0 -55
- package/dist/.sst/platform/src/components/aws/apigatewayv2-private-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv2-url-route.js +0 -53
- package/dist/.sst/platform/src/components/aws/apigatewayv2-url-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/apigatewayv2.js +0 -648
- package/dist/.sst/platform/src/components/aws/apigatewayv2.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/app-sync-data-source.js +0 -208
- package/dist/.sst/platform/src/components/aws/app-sync-data-source.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/app-sync-function.js +0 -52
- package/dist/.sst/platform/src/components/aws/app-sync-function.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/app-sync-resolver.js +0 -70
- package/dist/.sst/platform/src/components/aws/app-sync-resolver.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/app-sync.js +0 -330
- package/dist/.sst/platform/src/components/aws/app-sync.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/astro.js +0 -156
- package/dist/.sst/platform/src/components/aws/astro.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/aurora.js +0 -678
- package/dist/.sst/platform/src/components/aws/aurora.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/auth-v1.js +0 -36
- package/dist/.sst/platform/src/components/aws/auth-v1.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/auth.js +0 -209
- package/dist/.sst/platform/src/components/aws/auth.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/bucket-lambda-subscriber.js +0 -99
- package/dist/.sst/platform/src/components/aws/bucket-lambda-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/bucket-notification.js +0 -170
- package/dist/.sst/platform/src/components/aws/bucket-notification.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/bucket-queue-subscriber.js +0 -77
- package/dist/.sst/platform/src/components/aws/bucket-queue-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/bucket-topic-subscriber.js +0 -99
- package/dist/.sst/platform/src/components/aws/bucket-topic-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/bucket.js +0 -754
- package/dist/.sst/platform/src/components/aws/bucket.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/bus-base-subscriber.js +0 -19
- package/dist/.sst/platform/src/components/aws/bus-base-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/bus-lambda-subscriber.js +0 -81
- package/dist/.sst/platform/src/components/aws/bus-lambda-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/bus-queue-subscriber.js +0 -63
- package/dist/.sst/platform/src/components/aws/bus-queue-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/bus.js +0 -350
- package/dist/.sst/platform/src/components/aws/bus.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/cdn.js +0 -234
- package/dist/.sst/platform/src/components/aws/cdn.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/cluster-v1.js +0 -245
- package/dist/.sst/platform/src/components/aws/cluster-v1.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/cluster.js +0 -321
- package/dist/.sst/platform/src/components/aws/cluster.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/cognito-identity-pool.js +0 -263
- package/dist/.sst/platform/src/components/aws/cognito-identity-pool.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/cognito-identity-provider.js +0 -67
- package/dist/.sst/platform/src/components/aws/cognito-identity-provider.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/cognito-user-pool-client.js +0 -81
- package/dist/.sst/platform/src/components/aws/cognito-user-pool-client.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/cognito-user-pool.js +0 -368
- package/dist/.sst/platform/src/components/aws/cognito-user-pool.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/cron.js +0 -200
- package/dist/.sst/platform/src/components/aws/cron.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/dns-validated-certificate.js +0 -55
- package/dist/.sst/platform/src/components/aws/dns-validated-certificate.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/dns.js +0 -121
- package/dist/.sst/platform/src/components/aws/dns.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/dynamo-lambda-subscriber.js +0 -79
- package/dist/.sst/platform/src/components/aws/dynamo-lambda-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/dynamo.js +0 -291
- package/dist/.sst/platform/src/components/aws/dynamo.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/efs.js +0 -241
- package/dist/.sst/platform/src/components/aws/efs.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/email.js +0 -276
- package/dist/.sst/platform/src/components/aws/email.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/fargate.js +0 -434
- package/dist/.sst/platform/src/components/aws/fargate.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/function.js +0 -1041
- package/dist/.sst/platform/src/components/aws/function.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/helpers/apigateway-account.js +0 -31
- package/dist/.sst/platform/src/components/aws/helpers/apigateway-account.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/helpers/apigatewayv2-domain.js +0 -2
- package/dist/.sst/platform/src/components/aws/helpers/apigatewayv2-domain.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/helpers/arn.js +0 -86
- package/dist/.sst/platform/src/components/aws/helpers/arn.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/helpers/bootstrap.js +0 -7
- package/dist/.sst/platform/src/components/aws/helpers/bootstrap.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/helpers/container-builder.js +0 -27
- package/dist/.sst/platform/src/components/aws/helpers/container-builder.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/helpers/function-builder.js +0 -51
- package/dist/.sst/platform/src/components/aws/helpers/function-builder.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/helpers/provider.js +0 -34
- package/dist/.sst/platform/src/components/aws/helpers/provider.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/helpers/quota.js +0 -20
- package/dist/.sst/platform/src/components/aws/helpers/quota.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/helpers/site-builder.js +0 -36
- package/dist/.sst/platform/src/components/aws/helpers/site-builder.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/helpers/subscriber.js +0 -13
- package/dist/.sst/platform/src/components/aws/helpers/subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/https-redirect.js +0 -124
- package/dist/.sst/platform/src/components/aws/https-redirect.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/iam-edit.js +0 -40
- package/dist/.sst/platform/src/components/aws/iam-edit.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/index.js +0 -49
- package/dist/.sst/platform/src/components/aws/index.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/kinesis-stream-lambda-subscriber.js +0 -82
- package/dist/.sst/platform/src/components/aws/kinesis-stream-lambda-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/kinesis-stream.js +0 -134
- package/dist/.sst/platform/src/components/aws/kinesis-stream.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/linkable.js +0 -25
- package/dist/.sst/platform/src/components/aws/linkable.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/logging.js +0 -26
- package/dist/.sst/platform/src/components/aws/logging.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/mysql.js +0 -514
- package/dist/.sst/platform/src/components/aws/mysql.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/nextjs.js +0 -444
- package/dist/.sst/platform/src/components/aws/nextjs.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/nuxt.js +0 -113
- package/dist/.sst/platform/src/components/aws/nuxt.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/open-search.js +0 -365
- package/dist/.sst/platform/src/components/aws/open-search.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/opencontrol.js +0 -164
- package/dist/.sst/platform/src/components/aws/opencontrol.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/permission.js +0 -19
- package/dist/.sst/platform/src/components/aws/permission.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/postgres-v1.js +0 -304
- package/dist/.sst/platform/src/components/aws/postgres-v1.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/postgres.js +0 -532
- package/dist/.sst/platform/src/components/aws/postgres.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/providers/bucket-files.js +0 -8
- package/dist/.sst/platform/src/components/aws/providers/bucket-files.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/providers/distribution-deployment-waiter.js +0 -8
- package/dist/.sst/platform/src/components/aws/providers/distribution-deployment-waiter.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/providers/distribution-invalidation.js +0 -8
- package/dist/.sst/platform/src/components/aws/providers/distribution-invalidation.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/providers/function-environment-update.js +0 -18
- package/dist/.sst/platform/src/components/aws/providers/function-environment-update.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/providers/hosted-zone-lookup.js +0 -8
- package/dist/.sst/platform/src/components/aws/providers/hosted-zone-lookup.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/providers/kv-keys.js +0 -8
- package/dist/.sst/platform/src/components/aws/providers/kv-keys.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/providers/kv-routes-update.js +0 -8
- package/dist/.sst/platform/src/components/aws/providers/kv-routes-update.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/providers/origin-access-control.js +0 -8
- package/dist/.sst/platform/src/components/aws/providers/origin-access-control.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/providers/rds-role-lookup.js +0 -8
- package/dist/.sst/platform/src/components/aws/providers/rds-role-lookup.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/providers/vector-table.js +0 -8
- package/dist/.sst/platform/src/components/aws/providers/vector-table.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/queue-lambda-subscriber.js +0 -81
- package/dist/.sst/platform/src/components/aws/queue-lambda-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/queue.js +0 -322
- package/dist/.sst/platform/src/components/aws/queue.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/react.js +0 -157
- package/dist/.sst/platform/src/components/aws/react.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/realtime-lambda-subscriber.js +0 -78
- package/dist/.sst/platform/src/components/aws/realtime-lambda-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/realtime.js +0 -221
- package/dist/.sst/platform/src/components/aws/realtime.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/redis-v1.js +0 -335
- package/dist/.sst/platform/src/components/aws/redis-v1.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/redis.js +0 -382
- package/dist/.sst/platform/src/components/aws/redis.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/remix.js +0 -212
- package/dist/.sst/platform/src/components/aws/remix.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/router-base-route.js +0 -40
- package/dist/.sst/platform/src/components/aws/router-base-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/router-bucket-route.js +0 -40
- package/dist/.sst/platform/src/components/aws/router-bucket-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/router-url-route.js +0 -51
- package/dist/.sst/platform/src/components/aws/router-url-route.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/router.js +0 -1156
- package/dist/.sst/platform/src/components/aws/router.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/service-v1.js +0 -606
- package/dist/.sst/platform/src/components/aws/service-v1.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/service.js +0 -924
- package/dist/.sst/platform/src/components/aws/service.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/sns-topic-lambda-subscriber.js +0 -75
- package/dist/.sst/platform/src/components/aws/sns-topic-lambda-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/sns-topic-queue-subscriber.js +0 -59
- package/dist/.sst/platform/src/components/aws/sns-topic-queue-subscriber.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/sns-topic.js +0 -233
- package/dist/.sst/platform/src/components/aws/sns-topic.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/solid-start.js +0 -120
- package/dist/.sst/platform/src/components/aws/solid-start.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/ssr-site.js +0 -792
- package/dist/.sst/platform/src/components/aws/ssr-site.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/static-site.js +0 -583
- package/dist/.sst/platform/src/components/aws/static-site.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/step-functions/choice.js +0 -98
- package/dist/.sst/platform/src/components/aws/step-functions/choice.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/step-functions/fail.js +0 -25
- package/dist/.sst/platform/src/components/aws/step-functions/fail.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/step-functions/map.js +0 -108
- package/dist/.sst/platform/src/components/aws/step-functions/map.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/step-functions/parallel.js +0 -129
- package/dist/.sst/platform/src/components/aws/step-functions/parallel.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/step-functions/pass.js +0 -41
- package/dist/.sst/platform/src/components/aws/step-functions/pass.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/step-functions/state.js +0 -134
- package/dist/.sst/platform/src/components/aws/step-functions/state.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/step-functions/succeed.js +0 -25
- package/dist/.sst/platform/src/components/aws/step-functions/succeed.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/step-functions/task.js +0 -116
- package/dist/.sst/platform/src/components/aws/step-functions/task.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/step-functions/wait.js +0 -46
- package/dist/.sst/platform/src/components/aws/step-functions/wait.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/step-functions.js +0 -576
- package/dist/.sst/platform/src/components/aws/step-functions.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/svelte-kit.js +0 -144
- package/dist/.sst/platform/src/components/aws/svelte-kit.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/tan-stack-start.js +0 -143
- package/dist/.sst/platform/src/components/aws/tan-stack-start.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/task.js +0 -311
- package/dist/.sst/platform/src/components/aws/task.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/vector.js +0 -224
- package/dist/.sst/platform/src/components/aws/vector.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/vpc-v1.js +0 -355
- package/dist/.sst/platform/src/components/aws/vpc-v1.js.map +0 -1
- package/dist/.sst/platform/src/components/aws/vpc.js +0 -834
- package/dist/.sst/platform/src/components/aws/vpc.js.map +0 -1
- package/dist/.sst/platform/src/components/base/base-site.js +0 -47
- package/dist/.sst/platform/src/components/base/base-site.js.map +0 -1
- package/dist/.sst/platform/src/components/base/base-ssr-site.js +0 -72
- package/dist/.sst/platform/src/components/base/base-ssr-site.js.map +0 -1
- package/dist/.sst/platform/src/components/base/base-static-site.js +0 -87
- package/dist/.sst/platform/src/components/base/base-static-site.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/account-id.js +0 -2
- package/dist/.sst/platform/src/components/cloudflare/account-id.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/auth.js +0 -37
- package/dist/.sst/platform/src/components/cloudflare/auth.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/binding.js +0 -25
- package/dist/.sst/platform/src/components/cloudflare/binding.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/bucket.js +0 -98
- package/dist/.sst/platform/src/components/cloudflare/bucket.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/cron.js +0 -86
- package/dist/.sst/platform/src/components/cloudflare/cron.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/d1.js +0 -104
- package/dist/.sst/platform/src/components/cloudflare/d1.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/dns.js +0 -138
- package/dist/.sst/platform/src/components/cloudflare/dns.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/helpers/fetch.js +0 -39
- package/dist/.sst/platform/src/components/cloudflare/helpers/fetch.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/helpers/worker-builder.js +0 -25
- package/dist/.sst/platform/src/components/cloudflare/helpers/worker-builder.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/index.js +0 -13
- package/dist/.sst/platform/src/components/cloudflare/index.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/kv.js +0 -98
- package/dist/.sst/platform/src/components/cloudflare/kv.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/providers/dns-record.js +0 -11
- package/dist/.sst/platform/src/components/cloudflare/providers/dns-record.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/providers/kv-data.js +0 -63
- package/dist/.sst/platform/src/components/cloudflare/providers/kv-data.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/providers/worker-url.js +0 -83
- package/dist/.sst/platform/src/components/cloudflare/providers/worker-url.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/providers/zone-lookup.js +0 -54
- package/dist/.sst/platform/src/components/cloudflare/providers/zone-lookup.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/queue.js +0 -57
- package/dist/.sst/platform/src/components/cloudflare/queue.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/remix.d.ts +0 -223
- package/dist/.sst/platform/src/components/cloudflare/remix.d.ts.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/remix.js +0 -291
- package/dist/.sst/platform/src/components/cloudflare/remix.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/ssr-site.js +0 -177
- package/dist/.sst/platform/src/components/cloudflare/ssr-site.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/static-site.js +0 -315
- package/dist/.sst/platform/src/components/cloudflare/static-site.js.map +0 -1
- package/dist/.sst/platform/src/components/cloudflare/worker.js +0 -326
- package/dist/.sst/platform/src/components/cloudflare/worker.js.map +0 -1
- package/dist/.sst/platform/src/components/component.js +0 -395
- package/dist/.sst/platform/src/components/component.js.map +0 -1
- package/dist/.sst/platform/src/components/cpu.js +0 -9
- package/dist/.sst/platform/src/components/cpu.js.map +0 -1
- package/dist/.sst/platform/src/components/dns.js +0 -7
- package/dist/.sst/platform/src/components/dns.js.map +0 -1
- package/dist/.sst/platform/src/components/duration.js +0 -19
- package/dist/.sst/platform/src/components/duration.js.map +0 -1
- package/dist/.sst/platform/src/components/error.js +0 -6
- package/dist/.sst/platform/src/components/error.js.map +0 -1
- package/dist/.sst/platform/src/components/experimental/dev-command.js +0 -59
- package/dist/.sst/platform/src/components/experimental/dev-command.js.map +0 -1
- package/dist/.sst/platform/src/components/experimental/index.js +0 -2
- package/dist/.sst/platform/src/components/experimental/index.js.map +0 -1
- package/dist/.sst/platform/src/components/hint.d.ts +0 -7
- package/dist/.sst/platform/src/components/hint.d.ts.map +0 -1
- package/dist/.sst/platform/src/components/hint.js +0 -20
- package/dist/.sst/platform/src/components/hint.js.map +0 -1
- package/dist/.sst/platform/src/components/index.js +0 -16
- package/dist/.sst/platform/src/components/index.js.map +0 -1
- package/dist/.sst/platform/src/components/input.js +0 -2
- package/dist/.sst/platform/src/components/input.js.map +0 -1
- package/dist/.sst/platform/src/components/link.js +0 -138
- package/dist/.sst/platform/src/components/link.js.map +0 -1
- package/dist/.sst/platform/src/components/linkable.js +0 -244
- package/dist/.sst/platform/src/components/linkable.js.map +0 -1
- package/dist/.sst/platform/src/components/naming.js +0 -58
- package/dist/.sst/platform/src/components/naming.js.map +0 -1
- package/dist/.sst/platform/src/components/path.js +0 -5
- package/dist/.sst/platform/src/components/path.js.map +0 -1
- package/dist/.sst/platform/src/components/rpc/rpc.js +0 -120
- package/dist/.sst/platform/src/components/rpc/rpc.js.map +0 -1
- package/dist/.sst/platform/src/components/secret.js +0 -143
- package/dist/.sst/platform/src/components/secret.js.map +0 -1
- package/dist/.sst/platform/src/components/size.js +0 -29
- package/dist/.sst/platform/src/components/size.js.map +0 -1
- package/dist/.sst/platform/src/components/vercel/account-id.js +0 -2
- package/dist/.sst/platform/src/components/vercel/account-id.js.map +0 -1
- package/dist/.sst/platform/src/components/vercel/dns.js +0 -104
- package/dist/.sst/platform/src/components/vercel/dns.js.map +0 -1
- package/dist/.sst/platform/src/components/vercel/index.js +0 -3
- package/dist/.sst/platform/src/components/vercel/index.js.map +0 -1
- package/dist/.sst/platform/src/components/vercel/providers/dns-record.js +0 -8
- package/dist/.sst/platform/src/components/vercel/providers/dns-record.js.map +0 -1
- package/dist/.sst/platform/src/config.js +0 -5
- package/dist/.sst/platform/src/config.js.map +0 -1
- package/dist/.sst/platform/src/util/compare-semver.js +0 -24
- package/dist/.sst/platform/src/util/compare-semver.js.map +0 -1
- package/dist/.sst/platform/src/util/lazy.js +0 -12
- package/dist/.sst/platform/src/util/lazy.js.map +0 -1
- package/dist/.sst/platform/src/util/path-to-regex.d.ts +0 -128
- package/dist/.sst/platform/src/util/path-to-regex.d.ts.map +0 -1
- package/dist/.sst/platform/src/util/path-to-regex.js +0 -392
- package/dist/.sst/platform/src/util/path-to-regex.js.map +0 -1
- package/dist/.sst/platform/src/util/semaphore.js +0 -36
- package/dist/.sst/platform/src/util/semaphore.js.map +0 -1
- package/dist/.sst/platform/src/util/warn.js +0 -8
- package/dist/.sst/platform/src/util/warn.js.map +0 -1
- package/dist/components/monorise-core.js +0 -147
- package/dist/components/monorise-core.js.map +0 -1
- package/dist/components/q-function.js +0 -53
- package/dist/components/q-function.js.map +0 -1
- package/dist/components/single-table.js +0 -73
- package/dist/components/single-table.js.map +0 -1
- package/dist/constants/event.js +0 -74
- package/dist/constants/event.js.map +0 -1
- package/dist/constants/table.js +0 -3
- package/dist/constants/table.js.map +0 -1
- package/dist/sst.config.js +0 -24
- package/dist/sst.config.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,1156 +0,0 @@
|
|
|
1
|
-
import { all, interpolate, output, } from "@pulumi/pulumi";
|
|
2
|
-
import crypto from "crypto";
|
|
3
|
-
import { Component, transform } from "../component";
|
|
4
|
-
import { Cdn } from "./cdn";
|
|
5
|
-
import { cloudfront } from "@pulumi/aws";
|
|
6
|
-
import { hashStringToPrettyString, physicalName } from "../naming";
|
|
7
|
-
import { Bucket } from "./bucket";
|
|
8
|
-
import { OriginAccessControl } from "./providers/origin-access-control";
|
|
9
|
-
import { VisibleError } from "../error";
|
|
10
|
-
import { RouterUrlRoute } from "./router-url-route";
|
|
11
|
-
import { RouterBucketRoute } from "./router-bucket-route";
|
|
12
|
-
/**
|
|
13
|
-
* The `Router` component lets you use a CloudFront distribution to direct
|
|
14
|
-
* requests to various parts of your application like:
|
|
15
|
-
*
|
|
16
|
-
* - A URL
|
|
17
|
-
* - A function
|
|
18
|
-
* - A frontend
|
|
19
|
-
* - An S3 bucket
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
*
|
|
23
|
-
* #### Minimal example
|
|
24
|
-
*
|
|
25
|
-
* ```ts title="sst.config.ts"
|
|
26
|
-
* new sst.aws.Router("MyRouter");
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* #### Add a custom domain
|
|
30
|
-
*
|
|
31
|
-
* ```ts {2} title="sst.config.ts"
|
|
32
|
-
* new sst.aws.Router("MyRouter", {
|
|
33
|
-
* domain: "myapp.com"
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* #### Sharing the router across stages
|
|
38
|
-
*
|
|
39
|
-
* ```ts title="sst.config.ts"
|
|
40
|
-
* const router = $app.stage === "production"
|
|
41
|
-
* ? new sst.aws.Router("MyRouter", {
|
|
42
|
-
* domain: {
|
|
43
|
-
* name: "example.com",
|
|
44
|
-
* aliases: ["*.example.com"]
|
|
45
|
-
* }
|
|
46
|
-
* })
|
|
47
|
-
* : sst.aws.Router.get("MyRouter", "E1XWRGCYGTFB7Z");
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* #### Route to a URL
|
|
51
|
-
*
|
|
52
|
-
* ```ts title="sst.config.ts" {3}
|
|
53
|
-
* const router = new sst.aws.Router("MyRouter");
|
|
54
|
-
*
|
|
55
|
-
* router.route("/", "https://some-external-service.com");
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* #### Route to an S3 bucket
|
|
59
|
-
*
|
|
60
|
-
* ```ts title="sst.config.ts" {2,6}
|
|
61
|
-
* const myBucket = new sst.aws.Bucket("MyBucket", {
|
|
62
|
-
* access: "cloudfront"
|
|
63
|
-
* });
|
|
64
|
-
*
|
|
65
|
-
* const router = new sst.aws.Router("MyRouter");
|
|
66
|
-
* router.routeBucket("/files", myBucket);
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* You need to allow CloudFront to access the bucket by setting the `access` prop
|
|
70
|
-
* on the bucket.
|
|
71
|
-
*
|
|
72
|
-
* #### Route to a function
|
|
73
|
-
*
|
|
74
|
-
* ```ts title="sst.config.ts" {8-11}
|
|
75
|
-
* const router = new sst.aws.Router("MyRouter", {
|
|
76
|
-
* domain: "example.com"
|
|
77
|
-
* });
|
|
78
|
-
*
|
|
79
|
-
* const myFunction = new sst.aws.Function("MyFunction", {
|
|
80
|
-
* handler: "src/api.handler",
|
|
81
|
-
* url: {
|
|
82
|
-
* router: {
|
|
83
|
-
* instance: router,
|
|
84
|
-
* path: "/api"
|
|
85
|
-
* }
|
|
86
|
-
* }
|
|
87
|
-
* });
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* Setting the route through the function, instead of `router.route()` makes
|
|
91
|
-
* it so that `myFunction.url` gives you the URL based on the Router domain.
|
|
92
|
-
*
|
|
93
|
-
* #### Route to a frontend
|
|
94
|
-
*
|
|
95
|
-
* ```ts title="sst.config.ts" {4-6}
|
|
96
|
-
* const router = new sst.aws.Router("MyRouter");
|
|
97
|
-
*
|
|
98
|
-
* const mySite = new sst.aws.Nextjs("MyWeb", {
|
|
99
|
-
* router: {
|
|
100
|
-
* instance: router
|
|
101
|
-
* }
|
|
102
|
-
* });
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* Setting the route through the site, instead of `router.route()` makes
|
|
106
|
-
* it so that `mySite.url` gives you the URL based on the Router domain.
|
|
107
|
-
*
|
|
108
|
-
* #### Route to a frontend on a path
|
|
109
|
-
*
|
|
110
|
-
* ```ts title="sst.config.ts" {4-7}
|
|
111
|
-
* const router = new sst.aws.Router("MyRouter");
|
|
112
|
-
*
|
|
113
|
-
* new sst.aws.Nextjs("MyWeb", {
|
|
114
|
-
* router: {
|
|
115
|
-
* instance: router,
|
|
116
|
-
* path: "/docs"
|
|
117
|
-
* }
|
|
118
|
-
* });
|
|
119
|
-
* ```
|
|
120
|
-
*
|
|
121
|
-
* If you are routing to a path, you'll need to configure the base path in your
|
|
122
|
-
* frontend app as well. [Learn more](/docs/component/aws/nextjs/#router).
|
|
123
|
-
*
|
|
124
|
-
* #### Route to a frontend on a subdomain
|
|
125
|
-
*
|
|
126
|
-
* ```ts title="sst.config.ts" {4,9-12}
|
|
127
|
-
* const router = new sst.aws.Router("MyRouter", {
|
|
128
|
-
* domain: {
|
|
129
|
-
* name: "example.com",
|
|
130
|
-
* aliases: ["*.example.com"]
|
|
131
|
-
* }
|
|
132
|
-
* });
|
|
133
|
-
*
|
|
134
|
-
* new sst.aws.Nextjs("MyWeb", {
|
|
135
|
-
* router: {
|
|
136
|
-
* instance: router,
|
|
137
|
-
* domain: "docs.example.com"
|
|
138
|
-
* }
|
|
139
|
-
* });
|
|
140
|
-
* ```
|
|
141
|
-
*
|
|
142
|
-
* We configure `*.example.com` as an alias so that we can route to a subdomain.
|
|
143
|
-
*
|
|
144
|
-
* #### How it works
|
|
145
|
-
*
|
|
146
|
-
* This uses a CloudFront KeyValueStore to store the routing data and a CloudFront
|
|
147
|
-
* function to route the request. As routes are added, the store is updated.
|
|
148
|
-
*
|
|
149
|
-
* So when a request comes in, it does a lookup in the store and dynamically sets
|
|
150
|
-
* the origin based on the routing data. For frontends, that have their server
|
|
151
|
-
* functions deployed to multiple `regions`, it routes to the closest region based
|
|
152
|
-
* on the user's location.
|
|
153
|
-
*
|
|
154
|
-
* You might notice a _placeholder.sst.dev_ behavior in CloudFront. This is not
|
|
155
|
-
* used and is only there because CloudFront requires a default behavior.
|
|
156
|
-
*
|
|
157
|
-
* #### Limits
|
|
158
|
-
*
|
|
159
|
-
* There are some limits on this setup but it's managed by SST.
|
|
160
|
-
*
|
|
161
|
-
* - The CloudFront function can be a maximum of 10KB in size. But because all
|
|
162
|
-
* the route data is stored in the KeyValueStore, the function can be kept small.
|
|
163
|
-
* - Each value in the KeyValueStore needs to be less than 1KB. This component
|
|
164
|
-
* splits the routes into multiple values to keep it under the limit.
|
|
165
|
-
* - The KeyValueStore can be a maximum of 5MB. This is fairly large. But to
|
|
166
|
-
* handle sites that have a lot of files, only top-level assets get individual
|
|
167
|
-
* entries.
|
|
168
|
-
*/
|
|
169
|
-
export class Router extends Component {
|
|
170
|
-
constructor(name, args = {}, opts = {}) {
|
|
171
|
-
super(__pulumiType, name, args, opts);
|
|
172
|
-
const _refVersion = 2;
|
|
173
|
-
const self = this;
|
|
174
|
-
this.constructorName = name;
|
|
175
|
-
this.constructorOpts = opts;
|
|
176
|
-
if (args && "ref" in args) {
|
|
177
|
-
const ref = reference();
|
|
178
|
-
this.cdn = output(ref.cdn);
|
|
179
|
-
this.kvStoreArn = ref.kvStoreArn;
|
|
180
|
-
this.kvNamespace = ref.kvNamespace;
|
|
181
|
-
this.hasInlineRoutes = ref.hasInlineRoutes;
|
|
182
|
-
registerOutputs();
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
const hasInlineRoutes = args.routes !== undefined;
|
|
186
|
-
let cdn, kvStoreArn, kvNamespace;
|
|
187
|
-
if (hasInlineRoutes) {
|
|
188
|
-
cdn = handleInlineRoutes();
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
const r = handleLazyRoutes();
|
|
192
|
-
cdn = output(r.distribution);
|
|
193
|
-
kvStoreArn = r.kvStoreArn;
|
|
194
|
-
kvNamespace = output(r.kvNamespace);
|
|
195
|
-
}
|
|
196
|
-
this.cdn = cdn;
|
|
197
|
-
this.kvStoreArn = kvStoreArn;
|
|
198
|
-
this.kvNamespace = kvNamespace;
|
|
199
|
-
this.hasInlineRoutes = output(hasInlineRoutes);
|
|
200
|
-
registerOutputs();
|
|
201
|
-
function reference() {
|
|
202
|
-
const ref = args;
|
|
203
|
-
const cdn = Cdn.get(`${name}Cdn`, ref.distributionID, { parent: self });
|
|
204
|
-
const tags = cdn.nodes.distribution.tags.apply((tags) => {
|
|
205
|
-
if ((tags === null || tags === void 0 ? void 0 : tags["sst:ref:version"]) !== _refVersion.toString()) {
|
|
206
|
-
throw new VisibleError([
|
|
207
|
-
`There have been some minor changes to the "Router" component that's being referenced by "${name}".\n`,
|
|
208
|
-
`To update, you'll need to redeploy the stage where the Router was created. And then redeploy this stage.`,
|
|
209
|
-
].join("\n"));
|
|
210
|
-
}
|
|
211
|
-
return {
|
|
212
|
-
kvStoreArn: tags === null || tags === void 0 ? void 0 : tags["sst:ref:kv"],
|
|
213
|
-
kvNamespace: tags === null || tags === void 0 ? void 0 : tags["sst:ref:kv-namespace"],
|
|
214
|
-
hasInlineRoutes: (tags === null || tags === void 0 ? void 0 : tags["sst:ref:kv"]) === undefined,
|
|
215
|
-
};
|
|
216
|
-
});
|
|
217
|
-
return {
|
|
218
|
-
cdn,
|
|
219
|
-
kvStoreArn: tags.kvStoreArn,
|
|
220
|
-
kvNamespace: tags.kvNamespace,
|
|
221
|
-
hasInlineRoutes: tags.hasInlineRoutes,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
function registerOutputs() {
|
|
225
|
-
self.registerOutputs({
|
|
226
|
-
_hint: args._skipHint ? undefined : self.url,
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
function handleInlineRoutes() {
|
|
230
|
-
let defaultCachePolicy;
|
|
231
|
-
let defaultCfFunction;
|
|
232
|
-
let defaultOac;
|
|
233
|
-
const routes = normalizeRoutes();
|
|
234
|
-
const cdn = createCdn();
|
|
235
|
-
return cdn;
|
|
236
|
-
function normalizeRoutes() {
|
|
237
|
-
return output(args.routes).apply((routes) => {
|
|
238
|
-
var _a;
|
|
239
|
-
const normalizedRoutes = Object.fromEntries(Object.entries(routes).map(([path, route]) => {
|
|
240
|
-
// Route path must start with "/"
|
|
241
|
-
if (!path.startsWith("/"))
|
|
242
|
-
throw new Error(`In "${name}" Router, the route path "${path}" must start with a "/"`);
|
|
243
|
-
route = typeof route === "string" ? { url: route } : route;
|
|
244
|
-
const hasUrl = "url" in route ? 1 : 0;
|
|
245
|
-
const hasBucket = "bucket" in route ? 1 : 0;
|
|
246
|
-
if (hasUrl + hasBucket !== 1)
|
|
247
|
-
throw new Error(`In "${name}" Router, the route path "${path}" can only have one of url or bucket`);
|
|
248
|
-
return [path, route];
|
|
249
|
-
}));
|
|
250
|
-
normalizedRoutes["/*"] = (_a = normalizedRoutes["/*"]) !== null && _a !== void 0 ? _a : {
|
|
251
|
-
url: "https://do-not-exist.sst.dev",
|
|
252
|
-
};
|
|
253
|
-
return normalizedRoutes;
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
function createCfRequestDefaultFunction() {
|
|
257
|
-
defaultCfFunction =
|
|
258
|
-
defaultCfFunction !== null && defaultCfFunction !== void 0 ? defaultCfFunction : new cloudfront.Function(`${name}CloudfrontFunction`, {
|
|
259
|
-
runtime: "cloudfront-js-2.0",
|
|
260
|
-
code: [
|
|
261
|
-
`async function handler(event) {`,
|
|
262
|
-
` event.request.headers["x-forwarded-host"] = event.request.headers.host;`,
|
|
263
|
-
` return event.request;`,
|
|
264
|
-
`}`,
|
|
265
|
-
].join("\n"),
|
|
266
|
-
}, { parent: self });
|
|
267
|
-
return defaultCfFunction;
|
|
268
|
-
}
|
|
269
|
-
function createCfRequestFunction(path, config, rewrite, injectHostHeader) {
|
|
270
|
-
var _a, _b;
|
|
271
|
-
return new cloudfront.Function(`${name}CloudfrontFunction${hashStringToPrettyString(path, 8)}`, {
|
|
272
|
-
runtime: "cloudfront-js-2.0",
|
|
273
|
-
keyValueStoreAssociations: (config === null || config === void 0 ? void 0 : config.kvStore)
|
|
274
|
-
? [config.kvStore]
|
|
275
|
-
: (_a = config === null || config === void 0 ? void 0 : config.kvStores) !== null && _a !== void 0 ? _a : [],
|
|
276
|
-
code: `
|
|
277
|
-
async function handler(event) {
|
|
278
|
-
${injectHostHeader
|
|
279
|
-
? `event.request.headers["x-forwarded-host"] = event.request.headers.host;`
|
|
280
|
-
: ""}
|
|
281
|
-
${rewrite
|
|
282
|
-
? `
|
|
283
|
-
const re = new RegExp("${rewrite.regex}");
|
|
284
|
-
event.request.uri = event.request.uri.replace(re, "${rewrite.to}");`
|
|
285
|
-
: ""}
|
|
286
|
-
${(_b = config === null || config === void 0 ? void 0 : config.injection) !== null && _b !== void 0 ? _b : ""}
|
|
287
|
-
return event.request;
|
|
288
|
-
}`,
|
|
289
|
-
}, { parent: self });
|
|
290
|
-
}
|
|
291
|
-
function createCfResponseFunction(path, config) {
|
|
292
|
-
var _a, _b;
|
|
293
|
-
return new cloudfront.Function(`${name}CloudfrontFunctionResponse${hashStringToPrettyString(path, 8)}`, {
|
|
294
|
-
runtime: "cloudfront-js-2.0",
|
|
295
|
-
keyValueStoreAssociations: config.kvStore
|
|
296
|
-
? [config.kvStore]
|
|
297
|
-
: (_a = config.kvStores) !== null && _a !== void 0 ? _a : [],
|
|
298
|
-
code: `
|
|
299
|
-
async function handler(event) {
|
|
300
|
-
${(_b = config.injection) !== null && _b !== void 0 ? _b : ""}
|
|
301
|
-
return event.response;
|
|
302
|
-
}`,
|
|
303
|
-
}, { parent: self });
|
|
304
|
-
}
|
|
305
|
-
function createOriginAccessControl() {
|
|
306
|
-
defaultOac =
|
|
307
|
-
defaultOac !== null && defaultOac !== void 0 ? defaultOac : new OriginAccessControl(`${name}S3AccessControl`, { name: physicalName(64, name) }, { parent: self, ignoreChanges: ["name"] });
|
|
308
|
-
return defaultOac;
|
|
309
|
-
}
|
|
310
|
-
function createCachePolicy() {
|
|
311
|
-
var _a;
|
|
312
|
-
defaultCachePolicy =
|
|
313
|
-
defaultCachePolicy !== null && defaultCachePolicy !== void 0 ? defaultCachePolicy : new cloudfront.CachePolicy(...transform((_a = args.transform) === null || _a === void 0 ? void 0 : _a.cachePolicy, `${name}CachePolicy`, {
|
|
314
|
-
comment: `${name} router cache policy`,
|
|
315
|
-
defaultTtl: 0,
|
|
316
|
-
maxTtl: 31536000, // 1 year
|
|
317
|
-
minTtl: 0,
|
|
318
|
-
parametersInCacheKeyAndForwardedToOrigin: {
|
|
319
|
-
cookiesConfig: {
|
|
320
|
-
cookieBehavior: "none",
|
|
321
|
-
},
|
|
322
|
-
headersConfig: {
|
|
323
|
-
headerBehavior: "none",
|
|
324
|
-
},
|
|
325
|
-
queryStringsConfig: {
|
|
326
|
-
queryStringBehavior: "all",
|
|
327
|
-
},
|
|
328
|
-
enableAcceptEncodingBrotli: true,
|
|
329
|
-
enableAcceptEncodingGzip: true,
|
|
330
|
-
},
|
|
331
|
-
}, { parent: self }));
|
|
332
|
-
return defaultCachePolicy;
|
|
333
|
-
}
|
|
334
|
-
function createCdn() {
|
|
335
|
-
return routes.apply((routes) => {
|
|
336
|
-
var _a;
|
|
337
|
-
const distributionData = Object.entries(routes).map(([path, route]) => {
|
|
338
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
339
|
-
if ("url" in route) {
|
|
340
|
-
return {
|
|
341
|
-
origin: {
|
|
342
|
-
originId: path,
|
|
343
|
-
domainName: new URL(route.url).host,
|
|
344
|
-
customOriginConfig: {
|
|
345
|
-
httpPort: 80,
|
|
346
|
-
httpsPort: 443,
|
|
347
|
-
originProtocolPolicy: "https-only",
|
|
348
|
-
originReadTimeout: 20,
|
|
349
|
-
originSslProtocols: ["TLSv1.2"],
|
|
350
|
-
},
|
|
351
|
-
},
|
|
352
|
-
behavior: {
|
|
353
|
-
pathPattern: path,
|
|
354
|
-
targetOriginId: path,
|
|
355
|
-
functionAssociations: [
|
|
356
|
-
{
|
|
357
|
-
eventType: "viewer-request",
|
|
358
|
-
functionArn: ((_a = route.edge) === null || _a === void 0 ? void 0 : _a.viewerRequest) || route.rewrite
|
|
359
|
-
? createCfRequestFunction(path, (_b = route.edge) === null || _b === void 0 ? void 0 : _b.viewerRequest, route.rewrite, true).arn
|
|
360
|
-
: createCfRequestDefaultFunction().arn,
|
|
361
|
-
},
|
|
362
|
-
...(((_c = route.edge) === null || _c === void 0 ? void 0 : _c.viewerResponse)
|
|
363
|
-
? [
|
|
364
|
-
{
|
|
365
|
-
eventType: "viewer-response",
|
|
366
|
-
functionArn: createCfResponseFunction(path, route.edge.viewerResponse).arn,
|
|
367
|
-
},
|
|
368
|
-
]
|
|
369
|
-
: []),
|
|
370
|
-
],
|
|
371
|
-
viewerProtocolPolicy: "redirect-to-https",
|
|
372
|
-
allowedMethods: [
|
|
373
|
-
"DELETE",
|
|
374
|
-
"GET",
|
|
375
|
-
"HEAD",
|
|
376
|
-
"OPTIONS",
|
|
377
|
-
"PATCH",
|
|
378
|
-
"POST",
|
|
379
|
-
"PUT",
|
|
380
|
-
],
|
|
381
|
-
cachedMethods: ["GET", "HEAD"],
|
|
382
|
-
defaultTtl: 0,
|
|
383
|
-
compress: true,
|
|
384
|
-
cachePolicyId: (_d = route.cachePolicy) !== null && _d !== void 0 ? _d : createCachePolicy().id,
|
|
385
|
-
// CloudFront's Managed-AllViewerExceptHostHeader policy
|
|
386
|
-
originRequestPolicyId: "b689b0a8-53d0-40ab-baf2-68738e2966ac",
|
|
387
|
-
},
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
else if ("bucket" in route) {
|
|
391
|
-
return {
|
|
392
|
-
origin: {
|
|
393
|
-
originId: path,
|
|
394
|
-
domainName: route.bucket instanceof Bucket
|
|
395
|
-
? route.bucket.nodes.bucket.bucketRegionalDomainName
|
|
396
|
-
: route.bucket,
|
|
397
|
-
originPath: "",
|
|
398
|
-
originAccessControlId: createOriginAccessControl().id,
|
|
399
|
-
},
|
|
400
|
-
behavior: {
|
|
401
|
-
pathPattern: path,
|
|
402
|
-
targetOriginId: path,
|
|
403
|
-
functionAssociations: [
|
|
404
|
-
...(((_e = route.edge) === null || _e === void 0 ? void 0 : _e.viewerRequest) || route.rewrite
|
|
405
|
-
? [
|
|
406
|
-
{
|
|
407
|
-
eventType: "viewer-request",
|
|
408
|
-
functionArn: ((_f = route.edge) === null || _f === void 0 ? void 0 : _f.viewerRequest) || route.rewrite
|
|
409
|
-
? createCfRequestFunction(path, (_g = route.edge) === null || _g === void 0 ? void 0 : _g.viewerRequest, route.rewrite, false).arn
|
|
410
|
-
: createCfRequestDefaultFunction().arn,
|
|
411
|
-
},
|
|
412
|
-
]
|
|
413
|
-
: []),
|
|
414
|
-
...(((_h = route.edge) === null || _h === void 0 ? void 0 : _h.viewerResponse)
|
|
415
|
-
? [
|
|
416
|
-
{
|
|
417
|
-
eventType: "viewer-response",
|
|
418
|
-
functionArn: createCfResponseFunction(path, route.edge.viewerResponse).arn,
|
|
419
|
-
},
|
|
420
|
-
]
|
|
421
|
-
: []),
|
|
422
|
-
],
|
|
423
|
-
viewerProtocolPolicy: "redirect-to-https",
|
|
424
|
-
allowedMethods: ["GET", "HEAD", "OPTIONS"],
|
|
425
|
-
cachedMethods: ["GET", "HEAD"],
|
|
426
|
-
compress: true,
|
|
427
|
-
// CloudFront's managed CachingOptimized policy
|
|
428
|
-
cachePolicyId: (_j = route.cachePolicy) !== null && _j !== void 0 ? _j : "658327ea-f89d-4fab-a63d-7e88639e58f6",
|
|
429
|
-
},
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
throw new Error("Invalid route type");
|
|
433
|
-
});
|
|
434
|
-
return new Cdn(...transform((_a = args.transform) === null || _a === void 0 ? void 0 : _a.cdn, `${name}Cdn`, {
|
|
435
|
-
comment: `${name} router`,
|
|
436
|
-
origins: distributionData.map((d) => d.origin),
|
|
437
|
-
defaultCacheBehavior: Object.assign(Object.assign({}, distributionData.find((d) => d.behavior.pathPattern === "/*").behavior), {
|
|
438
|
-
// @ts-expect-error
|
|
439
|
-
pathPattern: undefined }),
|
|
440
|
-
orderedCacheBehaviors: distributionData
|
|
441
|
-
.filter((d) => d.behavior.pathPattern !== "/*")
|
|
442
|
-
.map((d) => d.behavior),
|
|
443
|
-
domain: args.domain,
|
|
444
|
-
wait: true,
|
|
445
|
-
}, { parent: self }));
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
function handleLazyRoutes() {
|
|
450
|
-
const kvNamespace = buildRequestKvNamespace();
|
|
451
|
-
const kvStoreArn = createRequestKvStore();
|
|
452
|
-
const requestFunction = createRequestFunction();
|
|
453
|
-
const responseFunction = createResponseFunction();
|
|
454
|
-
const cachePolicyId = createCachePolicy().id;
|
|
455
|
-
const distribution = createDistribution();
|
|
456
|
-
return { kvNamespace, kvStoreArn, distribution };
|
|
457
|
-
function buildRequestKvNamespace() {
|
|
458
|
-
// In the case multiple routers use the same kv store, we need to namespace the keys
|
|
459
|
-
return crypto
|
|
460
|
-
.createHash("md5")
|
|
461
|
-
.update(`${$app.name}-${$app.stage}-${name}`)
|
|
462
|
-
.digest("hex")
|
|
463
|
-
.substring(0, 4);
|
|
464
|
-
}
|
|
465
|
-
function createRequestKvStore() {
|
|
466
|
-
return output(args.edge).apply((edge) => {
|
|
467
|
-
const viewerRequest = edge === null || edge === void 0 ? void 0 : edge.viewerRequest;
|
|
468
|
-
const userKvStore = viewerRequest === null || viewerRequest === void 0 ? void 0 : viewerRequest.kvStore;
|
|
469
|
-
if (userKvStore)
|
|
470
|
-
return output(userKvStore);
|
|
471
|
-
return new cloudfront.KeyValueStore(`${name}KvStore`, {}, { parent: self }).arn;
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
function createCachePolicy() {
|
|
475
|
-
var _a;
|
|
476
|
-
return new cloudfront.CachePolicy(...transform((_a = args.transform) === null || _a === void 0 ? void 0 : _a.cachePolicy, `${name}ServerCachePolicy`, {
|
|
477
|
-
comment: "SST server response cache policy",
|
|
478
|
-
defaultTtl: 0,
|
|
479
|
-
maxTtl: 31536000, // 1 year
|
|
480
|
-
minTtl: 0,
|
|
481
|
-
parametersInCacheKeyAndForwardedToOrigin: {
|
|
482
|
-
cookiesConfig: {
|
|
483
|
-
cookieBehavior: "none",
|
|
484
|
-
},
|
|
485
|
-
headersConfig: {
|
|
486
|
-
headerBehavior: "whitelist",
|
|
487
|
-
headers: {
|
|
488
|
-
items: ["x-open-next-cache-key"],
|
|
489
|
-
},
|
|
490
|
-
},
|
|
491
|
-
queryStringsConfig: {
|
|
492
|
-
queryStringBehavior: "all",
|
|
493
|
-
},
|
|
494
|
-
enableAcceptEncodingBrotli: true,
|
|
495
|
-
enableAcceptEncodingGzip: true,
|
|
496
|
-
},
|
|
497
|
-
}, { parent: self }));
|
|
498
|
-
}
|
|
499
|
-
function createRequestFunction() {
|
|
500
|
-
return output(args.edge).apply((edge) => {
|
|
501
|
-
var _a, _b;
|
|
502
|
-
const userInjection = (_b = (_a = edge === null || edge === void 0 ? void 0 : edge.viewerRequest) === null || _a === void 0 ? void 0 : _a.injection) !== null && _b !== void 0 ? _b : "";
|
|
503
|
-
const blockCloudfrontUrlInjection = args.domain
|
|
504
|
-
? CF_BLOCK_CLOUDFRONT_URL_INJECTION
|
|
505
|
-
: "";
|
|
506
|
-
return new cloudfront.Function(`${name}CloudfrontFunctionRequest`, {
|
|
507
|
-
runtime: "cloudfront-js-2.0",
|
|
508
|
-
keyValueStoreAssociations: kvStoreArn ? [kvStoreArn] : [],
|
|
509
|
-
code: interpolate `
|
|
510
|
-
import cf from "cloudfront";
|
|
511
|
-
async function handler(event) {
|
|
512
|
-
${userInjection}
|
|
513
|
-
${blockCloudfrontUrlInjection}
|
|
514
|
-
${CF_ROUTER_INJECTION}
|
|
515
|
-
|
|
516
|
-
const routerNS = "${kvNamespace}";
|
|
517
|
-
|
|
518
|
-
async function getRoutes() {
|
|
519
|
-
let routes = [];
|
|
520
|
-
try {
|
|
521
|
-
const v = await cf.kvs().get(routerNS + ":routes");
|
|
522
|
-
routes = JSON.parse(v);
|
|
523
|
-
|
|
524
|
-
// handle chunked routes
|
|
525
|
-
if (routes.parts) {
|
|
526
|
-
const chunkPromises = [];
|
|
527
|
-
for (let i = 0; i < routes.parts; i++) {
|
|
528
|
-
chunkPromises.push(cf.kvs().get(routerNS + ":routes:" + i));
|
|
529
|
-
}
|
|
530
|
-
const chunks = await Promise.all(chunkPromises);
|
|
531
|
-
routes = JSON.parse(chunks.join(""));
|
|
532
|
-
}
|
|
533
|
-
} catch (e) {}
|
|
534
|
-
return routes;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
async function matchRoute(routes) {
|
|
538
|
-
const requestHost = event.request.headers.host.value;
|
|
539
|
-
const match = routes
|
|
540
|
-
${
|
|
541
|
-
/*
|
|
542
|
-
Route format: [type, routeNamespace, hostRegex, pathPrefix]
|
|
543
|
-
- First sort by host pattern (longest first)
|
|
544
|
-
- Then sort by path prefix (longest first)
|
|
545
|
-
*/ ""}
|
|
546
|
-
.map(r => {
|
|
547
|
-
var parts = r.split(",");
|
|
548
|
-
return {
|
|
549
|
-
type: parts[0],
|
|
550
|
-
routeNs: parts[1],
|
|
551
|
-
host: parts[2],
|
|
552
|
-
path: parts[3]
|
|
553
|
-
};
|
|
554
|
-
})
|
|
555
|
-
.sort((a, b) => {
|
|
556
|
-
return (a.host.length !== b.host.length)
|
|
557
|
-
? b.host.length - a.host.length
|
|
558
|
-
: b.path.length - a.path.length;
|
|
559
|
-
})
|
|
560
|
-
.find(r => {
|
|
561
|
-
return (
|
|
562
|
-
// matching hosts
|
|
563
|
-
(
|
|
564
|
-
r.host === "" || (
|
|
565
|
-
r.host.includes("*")
|
|
566
|
-
? new RegExp(r.host).test("^" + requestHost + "$")
|
|
567
|
-
: r.host.replaceAll("\\\\.", ".") === requestHost
|
|
568
|
-
)
|
|
569
|
-
)
|
|
570
|
-
&&
|
|
571
|
-
// matching paths
|
|
572
|
-
event.request.uri.startsWith(r.path)
|
|
573
|
-
);
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
// Load metadata
|
|
577
|
-
if (match) {
|
|
578
|
-
try {
|
|
579
|
-
const v = await cf.kvs().get(match.routeNs + ":metadata");
|
|
580
|
-
return { type: match.type, routeNs: match.routeNs, metadata: JSON.parse(v) };
|
|
581
|
-
} catch (e) {}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
// Look up the route
|
|
586
|
-
const routes = await getRoutes();
|
|
587
|
-
const route = await matchRoute(routes);
|
|
588
|
-
if (!route) return event.request;
|
|
589
|
-
if (route.metadata.rewrite) {
|
|
590
|
-
const rw = route.metadata.rewrite;
|
|
591
|
-
event.request.uri = event.request.uri.replace(new RegExp(rw.regex), rw.to);
|
|
592
|
-
}
|
|
593
|
-
if (route.type === "url") setUrlOrigin(route.metadata.host, route.metadata.origin);
|
|
594
|
-
if (route.type === "bucket") setS3Origin(route.metadata.domain, route.metadata.origin);
|
|
595
|
-
if (route.type === "site") await routeSite(route.routeNs, route.metadata);
|
|
596
|
-
return event.request;
|
|
597
|
-
}`,
|
|
598
|
-
}, { parent: self });
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
function createResponseFunction() {
|
|
602
|
-
return output(args.edge).apply((edge) => {
|
|
603
|
-
const userConfig = edge === null || edge === void 0 ? void 0 : edge.viewerResponse;
|
|
604
|
-
const userInjection = userConfig === null || userConfig === void 0 ? void 0 : userConfig.injection;
|
|
605
|
-
const kvStoreArn = userConfig === null || userConfig === void 0 ? void 0 : userConfig.kvStore;
|
|
606
|
-
if (!userInjection)
|
|
607
|
-
return;
|
|
608
|
-
return new cloudfront.Function(`${name}CloudfrontFunctionResponse`, {
|
|
609
|
-
runtime: "cloudfront-js-2.0",
|
|
610
|
-
keyValueStoreAssociations: kvStoreArn ? [kvStoreArn] : [],
|
|
611
|
-
code: `
|
|
612
|
-
import cf from "cloudfront";
|
|
613
|
-
async function handler(event) {
|
|
614
|
-
${userInjection}
|
|
615
|
-
return event.response;
|
|
616
|
-
}`,
|
|
617
|
-
}, { parent: self });
|
|
618
|
-
});
|
|
619
|
-
}
|
|
620
|
-
function createDistribution() {
|
|
621
|
-
var _a;
|
|
622
|
-
return new Cdn(...transform((_a = args.transform) === null || _a === void 0 ? void 0 : _a.cdn, `${name}Cdn`, {
|
|
623
|
-
comment: `${name} app`,
|
|
624
|
-
domain: args.domain,
|
|
625
|
-
origins: [
|
|
626
|
-
{
|
|
627
|
-
originId: "default",
|
|
628
|
-
domainName: "placeholder.sst.dev",
|
|
629
|
-
customOriginConfig: {
|
|
630
|
-
httpPort: 80,
|
|
631
|
-
httpsPort: 443,
|
|
632
|
-
originProtocolPolicy: "http-only",
|
|
633
|
-
originReadTimeout: 20,
|
|
634
|
-
originSslProtocols: ["TLSv1.2"],
|
|
635
|
-
},
|
|
636
|
-
},
|
|
637
|
-
],
|
|
638
|
-
defaultCacheBehavior: {
|
|
639
|
-
targetOriginId: "default",
|
|
640
|
-
viewerProtocolPolicy: "redirect-to-https",
|
|
641
|
-
allowedMethods: [
|
|
642
|
-
"DELETE",
|
|
643
|
-
"GET",
|
|
644
|
-
"HEAD",
|
|
645
|
-
"OPTIONS",
|
|
646
|
-
"PATCH",
|
|
647
|
-
"POST",
|
|
648
|
-
"PUT",
|
|
649
|
-
],
|
|
650
|
-
cachedMethods: ["GET", "HEAD"],
|
|
651
|
-
compress: true,
|
|
652
|
-
cachePolicyId,
|
|
653
|
-
// CloudFront's Managed-AllViewerExceptHostHeader policy
|
|
654
|
-
originRequestPolicyId: "b689b0a8-53d0-40ab-baf2-68738e2966ac",
|
|
655
|
-
functionAssociations: all([
|
|
656
|
-
requestFunction,
|
|
657
|
-
responseFunction,
|
|
658
|
-
]).apply(([reqFn, resFn]) => [
|
|
659
|
-
{ eventType: "viewer-request", functionArn: reqFn.arn },
|
|
660
|
-
...(resFn
|
|
661
|
-
? [{ eventType: "viewer-response", functionArn: resFn.arn }]
|
|
662
|
-
: []),
|
|
663
|
-
]),
|
|
664
|
-
},
|
|
665
|
-
tags: {
|
|
666
|
-
"sst:ref:kv": kvStoreArn,
|
|
667
|
-
"sst:ref:kv-namespace": kvNamespace,
|
|
668
|
-
"sst:ref:version": _refVersion.toString(),
|
|
669
|
-
},
|
|
670
|
-
}, { parent: self }));
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* The ID of the Router distribution.
|
|
676
|
-
*/
|
|
677
|
-
get distributionID() {
|
|
678
|
-
return this.cdn.nodes.distribution.id;
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* The URL of the Router.
|
|
682
|
-
*
|
|
683
|
-
* If the `domain` is set, this is the URL with the custom domain.
|
|
684
|
-
* Otherwise, it's the auto-generated CloudFront URL.
|
|
685
|
-
*/
|
|
686
|
-
get url() {
|
|
687
|
-
return all([this.cdn.domainUrl, this.cdn.url]).apply(([domainUrl, url]) => domainUrl !== null && domainUrl !== void 0 ? domainUrl : url);
|
|
688
|
-
}
|
|
689
|
-
/** @internal */
|
|
690
|
-
get _kvStoreArn() {
|
|
691
|
-
return this.kvStoreArn;
|
|
692
|
-
}
|
|
693
|
-
/** @internal */
|
|
694
|
-
get _kvNamespace() {
|
|
695
|
-
return this.kvNamespace;
|
|
696
|
-
}
|
|
697
|
-
/** @internal */
|
|
698
|
-
get _hasInlineRoutes() {
|
|
699
|
-
return this.hasInlineRoutes;
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* The underlying [resources](/docs/components/#nodes) this component creates.
|
|
703
|
-
*/
|
|
704
|
-
get nodes() {
|
|
705
|
-
return {
|
|
706
|
-
/**
|
|
707
|
-
* The Amazon CloudFront CDN resource.
|
|
708
|
-
*/
|
|
709
|
-
cdn: this.cdn,
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Add a route to a destination URL.
|
|
714
|
-
*
|
|
715
|
-
* @param pattern The path pattern to match for this route.
|
|
716
|
-
* @param url The destination URL to route matching requests to.
|
|
717
|
-
* @param args Configure the route.
|
|
718
|
-
*
|
|
719
|
-
* @example
|
|
720
|
-
*
|
|
721
|
-
* You can match a route based on:
|
|
722
|
-
*
|
|
723
|
-
* - A path like `/api`
|
|
724
|
-
* - A domain pattern like `api.example.com`
|
|
725
|
-
* - A combined pattern like `dev.example.com/api`
|
|
726
|
-
*
|
|
727
|
-
* For example, to match a path.
|
|
728
|
-
*
|
|
729
|
-
* ```ts title="sst.config.ts"
|
|
730
|
-
* router.route("/api", "https://api.example.com");
|
|
731
|
-
* ```
|
|
732
|
-
*
|
|
733
|
-
* Or match a domain.
|
|
734
|
-
*
|
|
735
|
-
* ```ts title="sst.config.ts"
|
|
736
|
-
* router.route("api.myapp.com/", "https://api.example.com");
|
|
737
|
-
* ```
|
|
738
|
-
*
|
|
739
|
-
* Or a combined pattern.
|
|
740
|
-
*
|
|
741
|
-
* ```ts title="sst.config.ts"
|
|
742
|
-
* router.route("dev.myapp.com/api", "https://api.example.com");
|
|
743
|
-
* ```
|
|
744
|
-
*
|
|
745
|
-
* You can also rewrite the request path.
|
|
746
|
-
*
|
|
747
|
-
* ```ts title="sst.config.ts"
|
|
748
|
-
* router.route("/api", "https://api.example.com", {
|
|
749
|
-
* rewrite: {
|
|
750
|
-
* regex: "^/api/(.*)$",
|
|
751
|
-
* to: "/$1"
|
|
752
|
-
* }
|
|
753
|
-
* });
|
|
754
|
-
* ```
|
|
755
|
-
*
|
|
756
|
-
* Here something like `/api/users/profile` will be routed to
|
|
757
|
-
* `https://api.example.com/users/profile`.
|
|
758
|
-
*/
|
|
759
|
-
route(pattern, url, args) {
|
|
760
|
-
all([pattern, args, this.hasInlineRoutes]).apply(([pattern, args, hasInlineRoutes]) => {
|
|
761
|
-
if (hasInlineRoutes)
|
|
762
|
-
throw new VisibleError("Cannot use both `routes` and `.route()` function to add routes.");
|
|
763
|
-
new RouterUrlRoute(`${this.constructorName}Route${pattern}`, {
|
|
764
|
-
store: this.kvStoreArn,
|
|
765
|
-
routerNamespace: this.kvNamespace,
|
|
766
|
-
pattern,
|
|
767
|
-
url,
|
|
768
|
-
routeArgs: args,
|
|
769
|
-
}, { provider: this.constructorOpts.provider });
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Add a route to an S3 bucket.
|
|
774
|
-
*
|
|
775
|
-
* @param pattern The path pattern to match for this route.
|
|
776
|
-
* @param bucket The S3 bucket to route matching requests to.
|
|
777
|
-
* @param args Configure the route.
|
|
778
|
-
*
|
|
779
|
-
* @example
|
|
780
|
-
*
|
|
781
|
-
* Let's say you have an S3 bucket that gives CloudFront `access`.
|
|
782
|
-
*
|
|
783
|
-
* ```ts title="sst.config.ts" {2}
|
|
784
|
-
* const bucket = new sst.aws.Bucket("MyBucket", {
|
|
785
|
-
* access: "cloudfront"
|
|
786
|
-
* });
|
|
787
|
-
* ```
|
|
788
|
-
*
|
|
789
|
-
* You can match a pattern and route to it based on:
|
|
790
|
-
*
|
|
791
|
-
* - A path like `/api`
|
|
792
|
-
* - A domain pattern like `api.example.com`
|
|
793
|
-
* - A combined pattern like `dev.example.com/api`
|
|
794
|
-
*
|
|
795
|
-
* For example, to match a path.
|
|
796
|
-
*
|
|
797
|
-
* ```ts title="sst.config.ts"
|
|
798
|
-
* router.routeBucket("/files", bucket);
|
|
799
|
-
* ```
|
|
800
|
-
*
|
|
801
|
-
* Or match a domain.
|
|
802
|
-
*
|
|
803
|
-
* ```ts title="sst.config.ts"
|
|
804
|
-
* router.routeBucket("files.example.com", bucket);
|
|
805
|
-
* ```
|
|
806
|
-
*
|
|
807
|
-
* Or a combined pattern.
|
|
808
|
-
*
|
|
809
|
-
* ```ts title="sst.config.ts"
|
|
810
|
-
* router.routeBucket("dev.example.com/files", bucket);
|
|
811
|
-
* ```
|
|
812
|
-
*
|
|
813
|
-
* You can also rewrite the request path.
|
|
814
|
-
*
|
|
815
|
-
* ```ts title="sst.config.ts"
|
|
816
|
-
* router.routeBucket("/files", bucket, {
|
|
817
|
-
* rewrite: {
|
|
818
|
-
* regex: "^/files/(.*)$",
|
|
819
|
-
* to: "/$1"
|
|
820
|
-
* }
|
|
821
|
-
* });
|
|
822
|
-
* ```
|
|
823
|
-
*
|
|
824
|
-
* Here something like `/files/logo.png` will be routed to
|
|
825
|
-
* `/logo.png`.
|
|
826
|
-
*/
|
|
827
|
-
routeBucket(pattern, bucket, args) {
|
|
828
|
-
all([pattern, args, this.hasInlineRoutes]).apply(([pattern, args, hasInlineRoutes]) => {
|
|
829
|
-
if (hasInlineRoutes)
|
|
830
|
-
throw new VisibleError("Cannot use both `routes` and `.routeBucket()` function to add routes.");
|
|
831
|
-
new RouterBucketRoute(`${this.constructorName}Route${pattern}`, {
|
|
832
|
-
store: this.kvStoreArn,
|
|
833
|
-
routerNamespace: this.kvNamespace,
|
|
834
|
-
pattern,
|
|
835
|
-
bucket,
|
|
836
|
-
routeArgs: args,
|
|
837
|
-
}, { provider: this.constructorOpts.provider });
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Add a route to a frontend or static site.
|
|
842
|
-
*
|
|
843
|
-
* @param pattern The path pattern to match for this route.
|
|
844
|
-
* @param site The frontend or static site to route matching requests to.
|
|
845
|
-
*
|
|
846
|
-
* @deprecated The `routeSite` function has been deprecated. Set the `route` on the
|
|
847
|
-
* site components to route the site through this Router.
|
|
848
|
-
*/
|
|
849
|
-
routeSite(pattern, site) {
|
|
850
|
-
throw new VisibleError(`The "routeSite" function has been deprecated. Configure the new "route" prop on the site component to route the site through this Router.`);
|
|
851
|
-
}
|
|
852
|
-
/** @internal */
|
|
853
|
-
getSSTLink() {
|
|
854
|
-
return {
|
|
855
|
-
properties: {
|
|
856
|
-
url: this.url,
|
|
857
|
-
},
|
|
858
|
-
};
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* Reference an existing Router with the given Router distribution ID.
|
|
862
|
-
*
|
|
863
|
-
* @param name The name of the component.
|
|
864
|
-
* @param distributionID The ID of the existing Router distribution.
|
|
865
|
-
* @param opts? Resource options.
|
|
866
|
-
*
|
|
867
|
-
* This is useful when you create a Router in one stage and want to share it in
|
|
868
|
-
* another. It avoids having to create a new Router in the other stage.
|
|
869
|
-
*
|
|
870
|
-
* :::tip
|
|
871
|
-
* You can use the `static get` method to share a Router across stages.
|
|
872
|
-
* :::
|
|
873
|
-
*
|
|
874
|
-
* @example
|
|
875
|
-
* Let's say you create a Router in the `dev` stage. And in your personal stage
|
|
876
|
-
* `frank`, you want to share the same Router.
|
|
877
|
-
*
|
|
878
|
-
* ```ts title="sst.config.ts"
|
|
879
|
-
* const router = $app.stage === "frank"
|
|
880
|
-
* ? sst.aws.Router.get("MyRouter", "E2IDLMESRN6V62")
|
|
881
|
-
* : new sst.aws.Router("MyRouter");
|
|
882
|
-
* ```
|
|
883
|
-
*
|
|
884
|
-
* Here `E2IDLMESRN6V62` is the ID of the Router distribution created in the
|
|
885
|
-
* `dev` stage. You can find this by outputting the distribution ID in the `dev`
|
|
886
|
-
* stage.
|
|
887
|
-
*
|
|
888
|
-
* ```ts title="sst.config.ts"
|
|
889
|
-
* return {
|
|
890
|
-
* router: router.distributionID
|
|
891
|
-
* };
|
|
892
|
-
* ```
|
|
893
|
-
*
|
|
894
|
-
* Learn more about [how to configure a router for your app](/docs/configure-a-router).
|
|
895
|
-
*/
|
|
896
|
-
static get(name, distributionID, opts) {
|
|
897
|
-
return new Router(name, {
|
|
898
|
-
ref: true,
|
|
899
|
-
distributionID: distributionID,
|
|
900
|
-
}, opts);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
const __pulumiType = "sst:aws:Router";
|
|
904
|
-
// @ts-expect-error
|
|
905
|
-
Router.__pulumiType = __pulumiType;
|
|
906
|
-
export const CF_BLOCK_CLOUDFRONT_URL_INJECTION = `
|
|
907
|
-
if (event.request.headers.host.value.includes('cloudfront.net')) {
|
|
908
|
-
return {
|
|
909
|
-
statusCode: 403,
|
|
910
|
-
statusDescription: 'Forbidden',
|
|
911
|
-
body: {
|
|
912
|
-
encoding: "text",
|
|
913
|
-
data: '<html><head><title>403 Forbidden</title></head><body><center><h1>403 Forbidden</h1></center></body></html>'
|
|
914
|
-
}
|
|
915
|
-
};
|
|
916
|
-
}`;
|
|
917
|
-
export const CF_ROUTER_INJECTION = `
|
|
918
|
-
async function routeSite(kvNamespace, metadata) {
|
|
919
|
-
const baselessUri = metadata.base
|
|
920
|
-
? event.request.uri.replace(metadata.base, "")
|
|
921
|
-
: event.request.uri;
|
|
922
|
-
|
|
923
|
-
// Route to S3 files
|
|
924
|
-
try {
|
|
925
|
-
// check using baselessUri b/c files are stored in the root
|
|
926
|
-
const u = decodeURIComponent(baselessUri);
|
|
927
|
-
const postfixes = u.endsWith("/")
|
|
928
|
-
? ["index.html"]
|
|
929
|
-
: ["", ".html", "/index.html"];
|
|
930
|
-
const v = await Promise.any(postfixes.map(p => cf.kvs().get(kvNamespace + ":" + u + p).then(v => p)));
|
|
931
|
-
// files are stored in a subdirectory, add it to the request uri
|
|
932
|
-
event.request.uri = metadata.s3.dir + event.request.uri + v;
|
|
933
|
-
setS3Origin(metadata.s3.domain);
|
|
934
|
-
return;
|
|
935
|
-
} catch (e) {}
|
|
936
|
-
|
|
937
|
-
// Route to S3 routes
|
|
938
|
-
if (metadata.s3 && metadata.s3.routes) {
|
|
939
|
-
for (var i=0, l=metadata.s3.routes.length; i<l; i++) {
|
|
940
|
-
const route = metadata.s3.routes[i];
|
|
941
|
-
if (baselessUri.startsWith(route)) {
|
|
942
|
-
event.request.uri = metadata.s3.dir + event.request.uri;
|
|
943
|
-
// uri ends with /, ie. /usage/ -> /usage/index.html
|
|
944
|
-
if (event.request.uri.endsWith("/")) {
|
|
945
|
-
event.request.uri += "index.html";
|
|
946
|
-
}
|
|
947
|
-
// uri ends with non-file, ie. /usage -> /usage/index.html
|
|
948
|
-
else if (!event.request.uri.split("/").pop().includes(".")) {
|
|
949
|
-
event.request.uri += "/index.html";
|
|
950
|
-
}
|
|
951
|
-
setS3Origin(metadata.s3.domain);
|
|
952
|
-
return;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
// Route to S3 custom 404 (no servers)
|
|
958
|
-
if (metadata.custom404) {
|
|
959
|
-
event.request.uri = metadata.s3.dir + (metadata.base ? metadata.base : "") + metadata.custom404;
|
|
960
|
-
setS3Origin(metadata.s3.domain);
|
|
961
|
-
return;
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
// Route to image optimizer
|
|
965
|
-
if (metadata.image && baselessUri.startsWith(metadata.image.route)) {
|
|
966
|
-
setUrlOrigin(metadata.image.host);
|
|
967
|
-
return;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
// Route to servers
|
|
971
|
-
if (metadata.servers){
|
|
972
|
-
event.request.headers["x-forwarded-host"] = event.request.headers.host;
|
|
973
|
-
${
|
|
974
|
-
// Note: In SvelteKit, form action requests contain "/" in request query string
|
|
975
|
-
// ie. POST request with query string "?/action"
|
|
976
|
-
// CloudFront does not allow query string with "/". It needs to be encoded.
|
|
977
|
-
""}
|
|
978
|
-
for (var key in event.request.querystring) {
|
|
979
|
-
if (key.includes("/")) {
|
|
980
|
-
event.request.querystring[encodeURIComponent(key)] = event.request.querystring[key];
|
|
981
|
-
delete event.request.querystring[key];
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
setNextjsGeoHeaders();
|
|
985
|
-
setNextjsCacheKey();
|
|
986
|
-
setUrlOrigin(findNearestServer(metadata.servers), metadata.origin);
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
function setNextjsGeoHeaders() {
|
|
990
|
-
${
|
|
991
|
-
// Inject the CloudFront viewer country, region, latitude, and longitude headers into
|
|
992
|
-
// the request headers for OpenNext to use them for OpenNext to use them
|
|
993
|
-
""}
|
|
994
|
-
if(event.request.headers["cloudfront-viewer-city"]) {
|
|
995
|
-
event.request.headers["x-open-next-city"] = event.request.headers["cloudfront-viewer-city"];
|
|
996
|
-
}
|
|
997
|
-
if(event.request.headers["cloudfront-viewer-country"]) {
|
|
998
|
-
event.request.headers["x-open-next-country"] = event.request.headers["cloudfront-viewer-country"];
|
|
999
|
-
}
|
|
1000
|
-
if(event.request.headers["cloudfront-viewer-region"]) {
|
|
1001
|
-
event.request.headers["x-open-next-region"] = event.request.headers["cloudfront-viewer-region"];
|
|
1002
|
-
}
|
|
1003
|
-
if(event.request.headers["cloudfront-viewer-latitude"]) {
|
|
1004
|
-
event.request.headers["x-open-next-latitude"] = event.request.headers["cloudfront-viewer-latitude"];
|
|
1005
|
-
}
|
|
1006
|
-
if(event.request.headers["cloudfront-viewer-longitude"]) {
|
|
1007
|
-
event.request.headers["x-open-next-longitude"] = event.request.headers["cloudfront-viewer-longitude"];
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
function setNextjsCacheKey() {
|
|
1012
|
-
${
|
|
1013
|
-
// This function is used to improve cache hit ratio by setting the cache key
|
|
1014
|
-
// based on the request headers and the path. `next/image` only needs the
|
|
1015
|
-
// accept header, and this header is not useful for the rest of the query
|
|
1016
|
-
""}
|
|
1017
|
-
var cacheKey = "";
|
|
1018
|
-
if (event.request.uri.startsWith("/_next/image")) {
|
|
1019
|
-
cacheKey = getHeader("accept");
|
|
1020
|
-
} else {
|
|
1021
|
-
cacheKey =
|
|
1022
|
-
getHeader("rsc") +
|
|
1023
|
-
getHeader("next-router-prefetch") +
|
|
1024
|
-
getHeader("next-router-state-tree") +
|
|
1025
|
-
getHeader("next-url") +
|
|
1026
|
-
getHeader("x-prerender-revalidate");
|
|
1027
|
-
}
|
|
1028
|
-
if (event.request.cookies["__prerender_bypass"]) {
|
|
1029
|
-
cacheKey += event.request.cookies["__prerender_bypass"]
|
|
1030
|
-
? event.request.cookies["__prerender_bypass"].value
|
|
1031
|
-
: "";
|
|
1032
|
-
}
|
|
1033
|
-
var crypto = require("crypto");
|
|
1034
|
-
var hashedKey = crypto.createHash("md5").update(cacheKey).digest("hex");
|
|
1035
|
-
event.request.headers["x-open-next-cache-key"] = { value: hashedKey };
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
function getHeader(key) {
|
|
1039
|
-
var header = event.request.headers[key];
|
|
1040
|
-
if (header) {
|
|
1041
|
-
if (header.multiValue) {
|
|
1042
|
-
return header.multiValue.map((header) => header.value).join(",");
|
|
1043
|
-
}
|
|
1044
|
-
if (header.value) {
|
|
1045
|
-
return header.value;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
return "";
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
function findNearestServer(servers) {
|
|
1052
|
-
if (servers.length === 1) return servers[0][0];
|
|
1053
|
-
|
|
1054
|
-
const h = event.request.headers;
|
|
1055
|
-
const lat = h["cloudfront-viewer-latitude"] && h["cloudfront-viewer-latitude"].value;
|
|
1056
|
-
const lon = h["cloudfront-viewer-longitude"] && h["cloudfront-viewer-longitude"].value;
|
|
1057
|
-
if (!lat || !lon) return servers[0][0];
|
|
1058
|
-
|
|
1059
|
-
return servers
|
|
1060
|
-
.map((s) => ({
|
|
1061
|
-
distance: haversineDistance(lat, lon, s[1], s[2]),
|
|
1062
|
-
host: s[0],
|
|
1063
|
-
}))
|
|
1064
|
-
.sort((a, b) => a.distance - b.distance)[0]
|
|
1065
|
-
.host;
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
function haversineDistance(lat1, lon1, lat2, lon2) {
|
|
1069
|
-
const toRad = angle => angle * Math.PI / 180;
|
|
1070
|
-
const radLat1 = toRad(lat1);
|
|
1071
|
-
const radLat2 = toRad(lat2);
|
|
1072
|
-
const dLat = toRad(lat2 - lat1);
|
|
1073
|
-
const dLon = toRad(lon2 - lon1);
|
|
1074
|
-
const a = Math.sin(dLat / 2) ** 2 + Math.cos(radLat1) * Math.cos(radLat2) * Math.sin(dLon / 2) ** 2;
|
|
1075
|
-
return 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
function setUrlOrigin(urlHost, override) {
|
|
1080
|
-
event.request.headers["x-forwarded-host"] = event.request.headers.host;
|
|
1081
|
-
const origin = {
|
|
1082
|
-
domainName: urlHost,
|
|
1083
|
-
customOriginConfig: {
|
|
1084
|
-
port: 443,
|
|
1085
|
-
protocol: "https",
|
|
1086
|
-
sslProtocols: ["TLSv1.2"],
|
|
1087
|
-
},
|
|
1088
|
-
originAccessControlConfig: {
|
|
1089
|
-
enabled: false,
|
|
1090
|
-
}
|
|
1091
|
-
};
|
|
1092
|
-
override = override ?? {};
|
|
1093
|
-
if (override.protocol === "http") {
|
|
1094
|
-
delete origin.customOriginConfig;
|
|
1095
|
-
}
|
|
1096
|
-
if (override.connectionAttempts) {
|
|
1097
|
-
origin.connectionAttempts = override.connectionAttempts;
|
|
1098
|
-
}
|
|
1099
|
-
if (override.timeouts) {
|
|
1100
|
-
origin.timeouts = override.timeouts;
|
|
1101
|
-
}
|
|
1102
|
-
cf.updateRequestOrigin(origin);
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
function setS3Origin(s3Domain, override) {
|
|
1106
|
-
delete event.request.headers["Cookies"];
|
|
1107
|
-
delete event.request.headers["cookies"];
|
|
1108
|
-
delete event.request.cookies;
|
|
1109
|
-
|
|
1110
|
-
const origin = {
|
|
1111
|
-
domainName: s3Domain,
|
|
1112
|
-
originAccessControlConfig: {
|
|
1113
|
-
enabled: true,
|
|
1114
|
-
signingBehavior: "always",
|
|
1115
|
-
signingProtocol: "sigv4",
|
|
1116
|
-
originType: "s3",
|
|
1117
|
-
}
|
|
1118
|
-
};
|
|
1119
|
-
override = override ?? {};
|
|
1120
|
-
if (override.connectionAttempts) {
|
|
1121
|
-
origin.connectionAttempts = override.connectionAttempts;
|
|
1122
|
-
}
|
|
1123
|
-
if (override.timeouts) {
|
|
1124
|
-
origin.timeouts = override.timeouts;
|
|
1125
|
-
}
|
|
1126
|
-
cf.updateRequestOrigin(origin);
|
|
1127
|
-
}`;
|
|
1128
|
-
export function normalizeRouteArgs(route, routeDeprecated) {
|
|
1129
|
-
if (!route && !routeDeprecated)
|
|
1130
|
-
return undefined;
|
|
1131
|
-
return all([route, routeDeprecated]).apply(([route, routeDeprecated]) => {
|
|
1132
|
-
const v = route
|
|
1133
|
-
? route
|
|
1134
|
-
: Object.assign(Object.assign({}, routeDeprecated), { instance: routeDeprecated.router });
|
|
1135
|
-
return v.instance._hasInlineRoutes.apply((hasInlineRoutes) => {
|
|
1136
|
-
if (hasInlineRoutes)
|
|
1137
|
-
throw new VisibleError("Cannot route the site using the provided router. The Router component uses inline routes which has been deprecated.");
|
|
1138
|
-
const pathPrefix = v.path
|
|
1139
|
-
? "/" + v.path.replace(/^\//, "").replace(/\/$/, "")
|
|
1140
|
-
: undefined;
|
|
1141
|
-
return {
|
|
1142
|
-
hostPattern: v.domain
|
|
1143
|
-
? v.domain
|
|
1144
|
-
.replace(/[.+?^${}()|[\]\\]/g, "\\$&") // Escape special regex chars
|
|
1145
|
-
.replace(/\*/g, ".*") // Replace * with .*
|
|
1146
|
-
: undefined,
|
|
1147
|
-
pathPrefix,
|
|
1148
|
-
routerDistributionId: v.instance.nodes.cdn.nodes.distribution.id,
|
|
1149
|
-
routerUrl: v.instance.url.apply((url) => (v.domain ? `https://${v.domain}` : url) + (pathPrefix !== null && pathPrefix !== void 0 ? pathPrefix : "")),
|
|
1150
|
-
routerKvNamespace: v.instance._kvNamespace,
|
|
1151
|
-
routerKvStoreArn: v.instance._kvStoreArn,
|
|
1152
|
-
};
|
|
1153
|
-
});
|
|
1154
|
-
});
|
|
1155
|
-
}
|
|
1156
|
-
//# sourceMappingURL=router.js.map
|