mirror of
https://github.com/saltbo/zpan.git
synced 2026-08-31 02:04:40 +08:00
b5be4c5ebd
- server/entry-lambda.ts: Hono app via hono/aws-lambda handle(); lazy init pattern for CJS compatibility and warm-start reuse; serves SPA static files from dist/ with MIME detection and index.html fallback - deploy/aws-lambda/template.yaml: SAM template with Function URL (no API Gateway), Node 22, TURSO_* / BETTER_AUTH_SECRET / APP_URL env vars, minimal IAM (AWSLambdaBasicExecutionRole) - .github/workflows/deploy-aws-lambda.yml: 8-step contract (guard upstream, check secrets with exact names, resolve tag, checkout, ensure SAM artifact bucket, apply Turso migrations, build + sam deploy, post-deploy auto-gen BETTER_AUTH_SECRET + patch BETTER_AUTH_URL + write URL to summary) - package.json: build:lambda script (tsup CJS, external @libsql/client) - docs/deploy/aws-lambda.md: Prerequisites / Secrets / Trigger / First-boot storage / Cost sections - README.md, V2_ROADMAP.md: link new doc Agent-Profile: https://agent-kanban.dev/agents/a6bb038c4226a87f Co-authored-by: Bob <aibob@mails.agent-kanban.dev>
64 lines
1.5 KiB
YAML
64 lines
1.5 KiB
YAML
AWSTemplateFormatVersion: '2010-09-09'
|
|
Transform: AWS::Serverless-2016-10-31
|
|
Description: ZPan — S3-native file hosting platform on AWS Lambda
|
|
|
|
Globals:
|
|
Function:
|
|
Timeout: 30
|
|
MemorySize: 512
|
|
Runtime: nodejs22.x
|
|
Architectures:
|
|
- x86_64
|
|
|
|
Parameters:
|
|
TursoDatabaseUrl:
|
|
Type: String
|
|
Description: Turso database URL (e.g. libsql://your-db.turso.io)
|
|
NoEcho: true
|
|
TursoAuthToken:
|
|
Type: String
|
|
Description: Turso auth token
|
|
NoEcho: true
|
|
BetterAuthSecret:
|
|
Type: String
|
|
Description: Signing secret for auth sessions
|
|
NoEcho: true
|
|
AppUrl:
|
|
Type: String
|
|
Description: Public Function URL of the deployed application (set after first deploy)
|
|
Default: ''
|
|
|
|
Resources:
|
|
ZPanFunction:
|
|
Type: AWS::Serverless::Function
|
|
Properties:
|
|
FunctionName: zpan
|
|
CodeUri: ../../dist-lambda-pkg/
|
|
Handler: entry-lambda.handler
|
|
Description: ZPan file hosting platform
|
|
Policies:
|
|
- AWSLambdaBasicExecutionRole
|
|
Environment:
|
|
Variables:
|
|
NODE_ENV: production
|
|
TURSO_DATABASE_URL: !Ref TursoDatabaseUrl
|
|
TURSO_AUTH_TOKEN: !Ref TursoAuthToken
|
|
BETTER_AUTH_SECRET: !Ref BetterAuthSecret
|
|
APP_URL: !Ref AppUrl
|
|
BETTER_AUTH_URL: !Ref AppUrl
|
|
|
|
FunctionUrlConfig:
|
|
AuthType: NONE
|
|
Cors:
|
|
AllowOrigins:
|
|
- '*'
|
|
AllowHeaders:
|
|
- '*'
|
|
AllowMethods:
|
|
- '*'
|
|
|
|
Outputs:
|
|
FunctionUrl:
|
|
Description: ZPan public URL
|
|
Value: !GetAtt ZPanFunctionUrl.FunctionUrl
|