@phila/cli 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/config.d.ts +30 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +135 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/deploy.d.ts +2 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +224 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/destroy.d.ts +3 -0
- package/dist/commands/destroy.d.ts.map +1 -0
- package/dist/commands/destroy.js +110 -0
- package/dist/commands/destroy.js.map +1 -0
- package/dist/commands/init.d.ts +25 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +513 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/map.d.ts +8 -0
- package/dist/commands/map.d.ts.map +1 -0
- package/dist/commands/map.js +186 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/ship.d.ts +20 -0
- package/dist/commands/ship.d.ts.map +1 -0
- package/dist/commands/ship.js +445 -0
- package/dist/commands/ship.js.map +1 -0
- package/dist/commands/templates.d.ts +3 -0
- package/dist/commands/templates.d.ts.map +1 -0
- package/dist/commands/templates.js +120 -0
- package/dist/commands/templates.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/_shared/city.config.json.tmpl +24 -0
- package/dist/templates/_shared/dotnet-api/Api.csproj +17 -0
- package/dist/templates/_shared/dotnet-api/Program.cs +58 -0
- package/dist/templates/_shared/dotnet-api/aws-lambda-tools-defaults.json +10 -0
- package/dist/templates/_shared/dotnet-api/obj/Api.csproj.nuget.dgspec.json +80 -0
- package/dist/templates/_shared/dotnet-api/obj/Api.csproj.nuget.g.props +15 -0
- package/dist/templates/_shared/dotnet-api/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
- package/dist/templates/_shared/dotnet-api/obj/project.assets.json +708 -0
- package/dist/templates/_shared/dotnet-api/obj/project.nuget.cache +35 -0
- package/dist/templates/_shared/dotnet-api-postgres/Api.csproj +19 -0
- package/dist/templates/_shared/dotnet-api-postgres/Program.cs +167 -0
- package/dist/templates/_shared/dotnet-api-postgres/aws-lambda-tools-defaults.json +10 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Api.csproj.nuget.dgspec.json +88 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Api.csproj.nuget.g.props +15 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/project.assets.json +106 -0
- package/dist/templates/_shared/dotnet-api-postgres/obj/project.nuget.cache +15 -0
- package/dist/templates/_shared/nuxt-frontend/app.vue +3 -0
- package/dist/templates/_shared/nuxt-frontend/nuxt.config.ts +25 -0
- package/dist/templates/_shared/nuxt-frontend/package.json.tmpl +19 -0
- package/dist/templates/_shared/nuxt-frontend/pages/index.vue +6 -0
- package/dist/templates/_shared/nuxt-frontend/public/.gitkeep +0 -0
- package/dist/templates/_shared/nuxt-frontend/tsconfig.json +3 -0
- package/dist/templates/_shared/webapp-cdk-package.json.tmpl +23 -0
- package/dist/templates/_shared/webapp-frontend/app.vue +3 -0
- package/dist/templates/_shared/webapp-frontend/nuxt.config.ts +25 -0
- package/dist/templates/_shared/webapp-frontend/package.json.tmpl +19 -0
- package/dist/templates/_shared/webapp-frontend/pages/index.vue +7 -0
- package/dist/templates/_shared/webapp-frontend/public/.gitkeep +0 -0
- package/dist/templates/_shared/webapp-frontend/tsconfig.json +3 -0
- package/dist/templates/lambda-api-nodejs/README.md.tmpl +203 -0
- package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/index.ts +89 -0
- package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/package.json +17 -0
- package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/tsconfig.json +8 -0
- package/dist/templates/lambda-api-nodejs/cdk/app.ts.tmpl +53 -0
- package/dist/templates/lambda-api-nodejs/cdk/cdk.json +68 -0
- package/dist/templates/lambda-api-nodejs/cdk/package.json +23 -0
- package/dist/templates/lambda-api-nodejs/cdk/tsconfig.json +9 -0
- package/dist/templates/lambda-api-nodejs/package.json.tmpl +20 -0
- package/dist/templates/lambda-api-nodejs/tsconfig.json +27 -0
- package/dist/templates/lambda-dynamo-api/README.md.tmpl +184 -0
- package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/index.ts +109 -0
- package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/package.json +19 -0
- package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/tsconfig.json +24 -0
- package/dist/templates/lambda-dynamo-api/cdk/app.ts.tmpl +59 -0
- package/dist/templates/lambda-dynamo-api/cdk/cdk.json +73 -0
- package/dist/templates/lambda-dynamo-api/cdk/package.json +23 -0
- package/dist/templates/lambda-dynamo-api/cdk/tsconfig.json +14 -0
- package/dist/templates/lambda-dynamo-api/package.json.tmpl +20 -0
- package/dist/templates/lambda-dynamo-api/tsconfig.json +27 -0
- package/dist/templates/lambda-postgres-api/README.md.tmpl +234 -0
- package/dist/templates/lambda-postgres-api/apps/__lambdaName__/index.ts +76 -0
- package/dist/templates/lambda-postgres-api/apps/__lambdaName__/package.json +18 -0
- package/dist/templates/lambda-postgres-api/apps/__lambdaName__/tsconfig.json +26 -0
- package/dist/templates/lambda-postgres-api/cdk/app.ts.tmpl +55 -0
- package/dist/templates/lambda-postgres-api/cdk/cdk.json +4 -0
- package/dist/templates/lambda-postgres-api/cdk/package.json +23 -0
- package/dist/templates/lambda-postgres-api/cdk/tsconfig.json +25 -0
- package/dist/templates/lambda-postgres-api/package.json.tmpl +20 -0
- package/dist/templates/lambda-postgres-api/tsconfig.json +11 -0
- package/dist/templates/static-site/README.md.tmpl +72 -0
- package/dist/templates/static-site/cdk/app.ts.tmpl +50 -0
- package/dist/templates/static-site/cdk/cdk.json +68 -0
- package/dist/templates/static-site/cdk/package.json +23 -0
- package/dist/templates/static-site/cdk/tsconfig.json +9 -0
- package/dist/templates/static-site/frontend/.gitkeep +0 -0
- package/dist/templates/static-site/frontend/README.md +41 -0
- package/dist/templates/static-site/frontend/package.json +9 -0
- package/dist/templates/static-site/package.json.tmpl +19 -0
- package/dist/templates/static-site/tsconfig.json +27 -0
- package/dist/templates/webapp-ecs-dotnet/README.md.tmpl +213 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/Api.csproj +12 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/Dockerfile +30 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/Program.cs +85 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +70 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Api.csproj.nuget.g.props +15 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/project.assets.json +75 -0
- package/dist/templates/webapp-ecs-dotnet/apps/api/obj/project.nuget.cache +8 -0
- package/dist/templates/webapp-ecs-dotnet/cdk/app.ts.tmpl +60 -0
- package/dist/templates/webapp-ecs-dotnet/cdk/cdk.json +38 -0
- package/dist/templates/webapp-ecs-dotnet/cdk/tsconfig.json +25 -0
- package/dist/templates/webapp-ecs-dotnet/package.json.tmpl +23 -0
- package/dist/templates/webapp-ecs-dotnet/tsconfig.json +26 -0
- package/dist/templates/webapp-ecs-node/README.md.tmpl +207 -0
- package/dist/templates/webapp-ecs-node/apps/api/Dockerfile +33 -0
- package/dist/templates/webapp-ecs-node/apps/api/index.ts +74 -0
- package/dist/templates/webapp-ecs-node/apps/api/package.json +22 -0
- package/dist/templates/webapp-ecs-node/apps/api/tsconfig.json +18 -0
- package/dist/templates/webapp-ecs-node/cdk/app.ts.tmpl +60 -0
- package/dist/templates/webapp-ecs-node/cdk/cdk.json +38 -0
- package/dist/templates/webapp-ecs-node/cdk/tsconfig.json +25 -0
- package/dist/templates/webapp-ecs-node/package.json.tmpl +25 -0
- package/dist/templates/webapp-ecs-node/tsconfig.json +26 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/README.md.tmpl +271 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/Api.csproj +17 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/Dockerfile +30 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/Program.cs +194 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +80 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.props +19 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +6 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/project.assets.json +395 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/project.nuget.cache +49 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/cdk/app.ts.tmpl +62 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/cdk/cdk.json +38 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/cdk/tsconfig.json +25 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/package.json.tmpl +23 -0
- package/dist/templates/webapp-ecs-postgres-dotnet/tsconfig.json +26 -0
- package/dist/templates/webapp-ecs-postgres-node/README.md.tmpl +261 -0
- package/dist/templates/webapp-ecs-postgres-node/apps/api/Dockerfile +33 -0
- package/dist/templates/webapp-ecs-postgres-node/apps/api/index.ts +160 -0
- package/dist/templates/webapp-ecs-postgres-node/apps/api/package.json +25 -0
- package/dist/templates/webapp-ecs-postgres-node/apps/api/tsconfig.json +18 -0
- package/dist/templates/webapp-ecs-postgres-node/cdk/app.ts.tmpl +62 -0
- package/dist/templates/webapp-ecs-postgres-node/cdk/cdk.json +38 -0
- package/dist/templates/webapp-ecs-postgres-node/cdk/tsconfig.json +25 -0
- package/dist/templates/webapp-ecs-postgres-node/package.json.tmpl +25 -0
- package/dist/templates/webapp-ecs-postgres-node/tsconfig.json +26 -0
- package/dist/templates/webapp-lambda-dotnet/README.md.tmpl +188 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/Api.csproj +17 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/Program.cs +58 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/aws-lambda-tools-defaults.json +10 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +80 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Api.csproj.nuget.g.props +15 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/project.assets.json +708 -0
- package/dist/templates/webapp-lambda-dotnet/apps/api/obj/project.nuget.cache +35 -0
- package/dist/templates/webapp-lambda-dotnet/cdk/app.ts.tmpl +59 -0
- package/dist/templates/webapp-lambda-dotnet/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-dotnet/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-dotnet/package.json.tmpl +23 -0
- package/dist/templates/webapp-lambda-dotnet/tsconfig.json +27 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/README.md.tmpl +223 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/Api.csproj +18 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/Program.cs +155 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/aws-lambda-tools-defaults.json +10 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +84 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Api.csproj.nuget.g.props +19 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/project.assets.json +989 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/project.nuget.cache +223 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/app.ts.tmpl +65 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/package.json.tmpl +23 -0
- package/dist/templates/webapp-lambda-dynamo-dotnet/tsconfig.json +27 -0
- package/dist/templates/webapp-lambda-dynamo-node/README.md.tmpl +189 -0
- package/dist/templates/webapp-lambda-dynamo-node/apps/api/index.ts +109 -0
- package/dist/templates/webapp-lambda-dynamo-node/apps/api/package.json +19 -0
- package/dist/templates/webapp-lambda-dynamo-node/apps/api/tsconfig.json +8 -0
- package/dist/templates/webapp-lambda-dynamo-node/cdk/app.ts.tmpl +65 -0
- package/dist/templates/webapp-lambda-dynamo-node/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-dynamo-node/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-dynamo-node/package.json.tmpl +24 -0
- package/dist/templates/webapp-lambda-dynamo-node/tsconfig.json +27 -0
- package/dist/templates/webapp-lambda-node/README.md.tmpl +179 -0
- package/dist/templates/webapp-lambda-node/apps/api/index.ts +100 -0
- package/dist/templates/webapp-lambda-node/apps/api/package.json +17 -0
- package/dist/templates/webapp-lambda-node/apps/api/tsconfig.json +8 -0
- package/dist/templates/webapp-lambda-node/cdk/app.ts.tmpl +59 -0
- package/dist/templates/webapp-lambda-node/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-node/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-node/package.json.tmpl +24 -0
- package/dist/templates/webapp-lambda-node/tsconfig.json +27 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/README.md.tmpl +240 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/Api.csproj +19 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/Program.cs +167 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/aws-lambda-tools-defaults.json +10 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +88 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.props +15 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/project.assets.json +106 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/project.nuget.cache +15 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/cdk/app.ts.tmpl +61 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/package.json.tmpl +23 -0
- package/dist/templates/webapp-lambda-postgres-dotnet/tsconfig.json +27 -0
- package/dist/templates/webapp-lambda-postgres-node/README.md.tmpl +190 -0
- package/dist/templates/webapp-lambda-postgres-node/apps/api/index.ts +76 -0
- package/dist/templates/webapp-lambda-postgres-node/apps/api/package.json +18 -0
- package/dist/templates/webapp-lambda-postgres-node/apps/api/tsconfig.json +8 -0
- package/dist/templates/webapp-lambda-postgres-node/cdk/app.ts.tmpl +61 -0
- package/dist/templates/webapp-lambda-postgres-node/cdk/cdk.json +68 -0
- package/dist/templates/webapp-lambda-postgres-node/cdk/tsconfig.json +9 -0
- package/dist/templates/webapp-lambda-postgres-node/package.json.tmpl +24 -0
- package/dist/templates/webapp-lambda-postgres-node/tsconfig.json +27 -0
- package/dist/utils/aws.d.ts +4 -0
- package/dist/utils/aws.d.ts.map +1 -0
- package/dist/utils/aws.js +90 -0
- package/dist/utils/aws.js.map +1 -0
- package/dist/utils/dependencies.d.ts +27 -0
- package/dist/utils/dependencies.d.ts.map +1 -0
- package/dist/utils/dependencies.js +267 -0
- package/dist/utils/dependencies.js.map +1 -0
- package/dist/utils/template.d.ts +23 -0
- package/dist/utils/template.d.ts.map +1 -0
- package/dist/utils/template.js +115 -0
- package/dist/utils/template.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import 'source-map-support/register';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { App, Aspects, Stack } from 'aws-cdk-lib';
|
|
5
|
+
import * as ecs from 'aws-cdk-lib/aws-ecs';
|
|
6
|
+
import { AwsSolutionsChecks, NIST80053R5Checks } from 'cdk-nag';
|
|
7
|
+
import { StaticSite, EcsPostgresApi, Confidentiality, Environment } from '@phila/constructs';
|
|
8
|
+
|
|
9
|
+
const app = new App();
|
|
10
|
+
|
|
11
|
+
// Environment is determined by CDK context
|
|
12
|
+
const environment = app.node.tryGetContext('environment') as Environment;
|
|
13
|
+
|
|
14
|
+
if (!environment) {
|
|
15
|
+
throw new Error('Environment must be specified via context. Use: cdk deploy -c environment=dev');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Read compliance frameworks from context
|
|
19
|
+
const compliance = app.node.tryGetContext('compliance');
|
|
20
|
+
const complianceFrameworks = compliance ? compliance.split(',') : [];
|
|
21
|
+
|
|
22
|
+
// Application context with governance metadata
|
|
23
|
+
const context = {
|
|
24
|
+
appName: '{{appName}}',
|
|
25
|
+
environment,
|
|
26
|
+
department: '{{department}}',
|
|
27
|
+
team: '{{team}}',
|
|
28
|
+
contact: '{{contact}}',
|
|
29
|
+
compliance: complianceFrameworks,
|
|
30
|
+
confidentiality: Confidentiality.{{CONFIDENTIALITY}},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Stack name follows pattern: {appName}-{environment}
|
|
34
|
+
const stack = new Stack(app, '{{appName}}-' + environment, {
|
|
35
|
+
env: {
|
|
36
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
37
|
+
region: process.env.CDK_DEFAULT_REGION || 'us-east-1',
|
|
38
|
+
},
|
|
39
|
+
stackName: '{{appName}}-' + environment,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Create the StaticSite construct for the Nuxt frontend
|
|
43
|
+
new StaticSite(stack, '{{appName}}Site', {
|
|
44
|
+
...context,
|
|
45
|
+
assetDir: '../frontend/dist',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Create the EcsPostgresApi construct for the containerized .NET API with PostgreSQL
|
|
49
|
+
new EcsPostgresApi(stack, '{{appName}}Api', {
|
|
50
|
+
...context,
|
|
51
|
+
apiId: 'api',
|
|
52
|
+
image: ecs.ContainerImage.fromAsset(path.join(__dirname, '../apps/api')),
|
|
53
|
+
containerPort: 80,
|
|
54
|
+
// Uncomment for serverless Aurora instead of provisioned RDS:
|
|
55
|
+
// serverless: true,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Apply compliance checks
|
|
59
|
+
Aspects.of(app).add(new NIST80053R5Checks({ verbose: true }));
|
|
60
|
+
Aspects.of(app).add(new AwsSolutionsChecks({ verbose: true }));
|
|
61
|
+
|
|
62
|
+
app.synth();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": "npx ts-node --prefer-ts-exts app.ts",
|
|
3
|
+
"watch": {
|
|
4
|
+
"include": ["**"],
|
|
5
|
+
"exclude": [
|
|
6
|
+
"README.md",
|
|
7
|
+
"cdk*.json",
|
|
8
|
+
"**/*.d.ts",
|
|
9
|
+
"**/*.js",
|
|
10
|
+
"tsconfig.json",
|
|
11
|
+
"package*.json",
|
|
12
|
+
"node_modules",
|
|
13
|
+
"test"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"context": {
|
|
17
|
+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
|
18
|
+
"@aws-cdk/core:checkSecretUsage": true,
|
|
19
|
+
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
|
|
20
|
+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
|
21
|
+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
|
22
|
+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
|
23
|
+
"@aws-cdk/aws-iam:minimizePolicies": true,
|
|
24
|
+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
|
25
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
|
26
|
+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
|
27
|
+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
|
28
|
+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
|
|
29
|
+
"@aws-cdk/core:enablePartitionLiterals": true,
|
|
30
|
+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
|
31
|
+
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
|
|
32
|
+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
|
33
|
+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
|
34
|
+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
|
35
|
+
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
|
36
|
+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"strictNullChecks": true,
|
|
10
|
+
"noImplicitThis": true,
|
|
11
|
+
"alwaysStrict": true,
|
|
12
|
+
"noUnusedLocals": false,
|
|
13
|
+
"noUnusedParameters": false,
|
|
14
|
+
"noImplicitReturns": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": false,
|
|
16
|
+
"inlineSourceMap": true,
|
|
17
|
+
"inlineSources": true,
|
|
18
|
+
"experimentalDecorators": true,
|
|
19
|
+
"strictPropertyInitialization": false,
|
|
20
|
+
"outDir": "./dist",
|
|
21
|
+
"rootDir": "./"
|
|
22
|
+
},
|
|
23
|
+
"include": ["./*.ts"],
|
|
24
|
+
"exclude": ["node_modules", "cdk.out"]
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{appName}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Web application with Nuxt frontend, .NET ECS containerized API backend, and PostgreSQL",
|
|
5
|
+
"private": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "npm run build:frontend && npm run build:api",
|
|
8
|
+
"build:frontend": "cd frontend && npm run build",
|
|
9
|
+
"build:api": "cd apps/api && docker build -t {{appName}}-api .",
|
|
10
|
+
"dev": "cd frontend && npm run dev",
|
|
11
|
+
"test": "npm test --workspaces --if-present",
|
|
12
|
+
"synth": "cd cdk && cdk synth",
|
|
13
|
+
"deploy": "cd cdk && cdk deploy",
|
|
14
|
+
"diff": "cd cdk && cdk diff"
|
|
15
|
+
},
|
|
16
|
+
"workspaces": [
|
|
17
|
+
"cdk",
|
|
18
|
+
"frontend"
|
|
19
|
+
],
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^5.3.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"strictNullChecks": true,
|
|
10
|
+
"noImplicitThis": true,
|
|
11
|
+
"alwaysStrict": true,
|
|
12
|
+
"noUnusedLocals": false,
|
|
13
|
+
"noUnusedParameters": false,
|
|
14
|
+
"noImplicitReturns": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": false,
|
|
16
|
+
"inlineSourceMap": true,
|
|
17
|
+
"inlineSources": true,
|
|
18
|
+
"experimentalDecorators": true,
|
|
19
|
+
"strictPropertyInitialization": false,
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
"esModuleInterop": true,
|
|
22
|
+
"resolveJsonModule": true,
|
|
23
|
+
"forceConsistentCasingInFileNames": true
|
|
24
|
+
},
|
|
25
|
+
"exclude": ["node_modules", "cdk", "apps", "frontend"]
|
|
26
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# {{appName}}
|
|
2
|
+
|
|
3
|
+
Web application with Nuxt SSG frontend, ECS containerized Express API backend, and PostgreSQL using Philadelphia constructs.
|
|
4
|
+
|
|
5
|
+
Generated on {{timestamp}}
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
View the [architecture diagram](https://github.com/CityOfPhiladelphia/phila-ctl/blob/main/packages/constructs/docs/diagrams/webapp-ecs-postgres.drawio) in draw.io or VS Code with the Draw.io extension.
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### Prerequisites
|
|
16
|
+
|
|
17
|
+
- Node.js 20+
|
|
18
|
+
- Docker (for building container images)
|
|
19
|
+
- AWS CLI configured with SSO
|
|
20
|
+
- AWS profile named `phila-{{appName}}`
|
|
21
|
+
|
|
22
|
+
### Setup
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Install dependencies
|
|
26
|
+
npm install
|
|
27
|
+
|
|
28
|
+
# Build all packages
|
|
29
|
+
npm run build
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Development
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Run frontend dev server
|
|
36
|
+
npm run dev
|
|
37
|
+
|
|
38
|
+
# Run API locally (requires local Postgres or connection to dev database)
|
|
39
|
+
npm run dev:api
|
|
40
|
+
|
|
41
|
+
# Build frontend for production
|
|
42
|
+
npm run build:frontend
|
|
43
|
+
|
|
44
|
+
# Build API Docker image
|
|
45
|
+
npm run build:api
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Deployment
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Configure AWS profile
|
|
52
|
+
export AWS_PROFILE=phila-{{appName}}
|
|
53
|
+
|
|
54
|
+
# Deploy to dev environment
|
|
55
|
+
city deploy dev
|
|
56
|
+
|
|
57
|
+
# Deploy to test environment
|
|
58
|
+
city deploy test
|
|
59
|
+
|
|
60
|
+
# Deploy to production (requires confirmation)
|
|
61
|
+
city deploy prod
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Shipping Updates
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Ship frontend changes to S3/CloudFront
|
|
68
|
+
city ship dev --web
|
|
69
|
+
|
|
70
|
+
# Ship API changes (rebuilds and deploys ECS container)
|
|
71
|
+
city ship dev --ecs api
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Project Structure
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
.
|
|
78
|
+
├── cdk/ # CDK infrastructure code
|
|
79
|
+
│ └── app.ts # Main CDK application
|
|
80
|
+
├── frontend/ # Nuxt 3 SSG frontend
|
|
81
|
+
│ ├── pages/ # File-based routing
|
|
82
|
+
│ ├── app.vue # Root component
|
|
83
|
+
│ └── nuxt.config.ts # Nuxt configuration
|
|
84
|
+
├── apps/ # Backend code
|
|
85
|
+
│ └── api/ # Express API container with Postgres
|
|
86
|
+
│ ├── index.ts # API routes
|
|
87
|
+
│ └── Dockerfile # Container build file
|
|
88
|
+
└── city.config.json # City CLI configuration
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Frontend
|
|
92
|
+
|
|
93
|
+
The frontend uses [Nuxt 3](https://nuxt.com) with Static Site Generation (SSG):
|
|
94
|
+
|
|
95
|
+
- Pre-renders to static HTML for S3/CloudFront
|
|
96
|
+
- File-based routing in `pages/` directory
|
|
97
|
+
- TypeScript support enabled
|
|
98
|
+
|
|
99
|
+
### Adding Pages
|
|
100
|
+
|
|
101
|
+
Create Vue files in `frontend/pages/`:
|
|
102
|
+
|
|
103
|
+
```vue
|
|
104
|
+
<!-- frontend/pages/about.vue -->
|
|
105
|
+
<template>
|
|
106
|
+
<div>
|
|
107
|
+
<h1>About</h1>
|
|
108
|
+
</div>
|
|
109
|
+
</template>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This automatically creates a route at `/about`.
|
|
113
|
+
|
|
114
|
+
## API
|
|
115
|
+
|
|
116
|
+
The API uses [Express](https://expressjs.com/) running in an ECS Fargate container with PostgreSQL via `pg` (node-postgres).
|
|
117
|
+
|
|
118
|
+
### Adding Endpoints
|
|
119
|
+
|
|
120
|
+
Edit `apps/api/index.ts`:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
// List all users
|
|
124
|
+
app.get('/users', async (_req, res) => {
|
|
125
|
+
const db = await getPool();
|
|
126
|
+
const result = await db.query('SELECT * FROM users');
|
|
127
|
+
res.json(result.rows);
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Environment Variables
|
|
132
|
+
|
|
133
|
+
ECS containers automatically receive:
|
|
134
|
+
- `APP_NAME` - Application name ({{appName}})
|
|
135
|
+
- `ENVIRONMENT` - Current environment (dev/test/prod)
|
|
136
|
+
- `DB_SECRET_ARN` - ARN of Secrets Manager secret containing database credentials
|
|
137
|
+
- `DB_NAME` - Database name
|
|
138
|
+
|
|
139
|
+
### Database Connection
|
|
140
|
+
|
|
141
|
+
The `getPool()` function handles:
|
|
142
|
+
- Retrieving credentials from AWS Secrets Manager
|
|
143
|
+
- Building connection strings with SSL
|
|
144
|
+
- Connection pooling for container performance
|
|
145
|
+
|
|
146
|
+
### Local Development
|
|
147
|
+
|
|
148
|
+
Run the API locally:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
cd apps/api
|
|
152
|
+
npm run dev
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Or build and run the Docker container:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
cd apps/api
|
|
159
|
+
docker build -t {{appName}}-api .
|
|
160
|
+
docker run -p 80:80 \
|
|
161
|
+
-e APP_NAME={{appName}} \
|
|
162
|
+
-e ENVIRONMENT=dev \
|
|
163
|
+
-e DB_SECRET_ARN=<secret-arn> \
|
|
164
|
+
-e DB_NAME={{appName}} \
|
|
165
|
+
{{appName}}-api
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## PostgreSQL
|
|
169
|
+
|
|
170
|
+
The template creates an RDS PostgreSQL instance with:
|
|
171
|
+
- **Engine**: PostgreSQL 15
|
|
172
|
+
- **Instance class**: db.t3.micro (dev), db.t3.small (test/prod)
|
|
173
|
+
- **Storage**: Encrypted with KMS
|
|
174
|
+
- **Credentials**: Stored in Secrets Manager
|
|
175
|
+
- **Network**: VPC with private subnets
|
|
176
|
+
|
|
177
|
+
### Database Migrations
|
|
178
|
+
|
|
179
|
+
Run migrations manually or via a CI/CD pipeline:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Connect via bastion host or VPN
|
|
183
|
+
psql -h <rds-endpoint> -U postgres -d {{appName}}
|
|
184
|
+
|
|
185
|
+
# Create tables
|
|
186
|
+
CREATE TABLE items (
|
|
187
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
188
|
+
name VARCHAR(255) NOT NULL,
|
|
189
|
+
data JSONB,
|
|
190
|
+
created_at TIMESTAMP DEFAULT NOW(),
|
|
191
|
+
updated_at TIMESTAMP DEFAULT NOW()
|
|
192
|
+
);
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Serverless Option
|
|
196
|
+
|
|
197
|
+
For variable workloads, use Aurora Serverless:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// In cdk/app.ts:
|
|
201
|
+
new EcsPostgresApi(stack, '{{appName}}Api', {
|
|
202
|
+
...context,
|
|
203
|
+
serverless: true, // Use Aurora Serverless v2
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Resources Created
|
|
208
|
+
|
|
209
|
+
This application creates:
|
|
210
|
+
|
|
211
|
+
**Frontend:**
|
|
212
|
+
- **S3 Bucket** - Static asset storage
|
|
213
|
+
- **CloudFront Distribution** - CDN with HTTPS
|
|
214
|
+
- **Origin Access Control** - Secure S3 access
|
|
215
|
+
|
|
216
|
+
**API:**
|
|
217
|
+
- **ECS Fargate Service** - Containerized compute
|
|
218
|
+
- **Application Load Balancer** - HTTP/HTTPS ingress
|
|
219
|
+
- **ECS Cluster** - Container orchestration
|
|
220
|
+
- **ECR Repository** - Docker image storage
|
|
221
|
+
- **RDS PostgreSQL** - Relational database
|
|
222
|
+
- **Secrets Manager** - Database credentials
|
|
223
|
+
- **VPC Security Groups** - Network security
|
|
224
|
+
- **IAM Roles** - Task execution permissions
|
|
225
|
+
|
|
226
|
+
**Shared:**
|
|
227
|
+
- **SSM Parameters** - Resource discovery
|
|
228
|
+
- **CloudWatch Logs** - Application logs
|
|
229
|
+
- **KMS Keys** - Encryption
|
|
230
|
+
|
|
231
|
+
## URLs
|
|
232
|
+
|
|
233
|
+
After deployment, URLs are available via:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Frontend URL
|
|
237
|
+
city config list --env dev | grep cloudfront
|
|
238
|
+
|
|
239
|
+
# API URL (ALB endpoint)
|
|
240
|
+
city config list --env dev | grep ecs-api
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Scaling
|
|
244
|
+
|
|
245
|
+
ECS automatically adjusts:
|
|
246
|
+
- **Dev**: 1 container instance
|
|
247
|
+
- **Test/Prod**: 2+ container instances with auto-scaling
|
|
248
|
+
|
|
249
|
+
Container resources default to:
|
|
250
|
+
- CPU: 256 units (0.25 vCPU)
|
|
251
|
+
- Memory: 512 MB
|
|
252
|
+
|
|
253
|
+
Adjust in `cdk/app.ts` by passing `cpu` and `memoryLimitMiB` props to `EcsPostgresApi`.
|
|
254
|
+
|
|
255
|
+
## Support
|
|
256
|
+
|
|
257
|
+
For issues or questions:
|
|
258
|
+
- [Philadelphia Infrastructure Library Documentation](https://github.com/CityOfPhiladelphia/phila-ctl)
|
|
259
|
+
- [Express Documentation](https://expressjs.com/)
|
|
260
|
+
- [node-postgres Documentation](https://node-postgres.com/)
|
|
261
|
+
- [Nuxt Documentation](https://nuxt.com/docs)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# ABOUTME: Multi-stage Docker build for Express API
|
|
2
|
+
# ABOUTME: Creates minimal production image with compiled TypeScript
|
|
3
|
+
|
|
4
|
+
# Build stage
|
|
5
|
+
FROM node:20-alpine AS builder
|
|
6
|
+
|
|
7
|
+
WORKDIR /app
|
|
8
|
+
|
|
9
|
+
COPY package*.json ./
|
|
10
|
+
RUN npm ci
|
|
11
|
+
|
|
12
|
+
COPY tsconfig.json ./
|
|
13
|
+
COPY *.ts ./
|
|
14
|
+
RUN npm run build
|
|
15
|
+
|
|
16
|
+
# Production stage
|
|
17
|
+
FROM node:20-alpine
|
|
18
|
+
|
|
19
|
+
WORKDIR /app
|
|
20
|
+
|
|
21
|
+
# Copy package files and install production dependencies only
|
|
22
|
+
COPY package*.json ./
|
|
23
|
+
RUN npm ci --omit=dev
|
|
24
|
+
|
|
25
|
+
# Copy compiled JavaScript from builder
|
|
26
|
+
COPY --from=builder /app/dist ./dist
|
|
27
|
+
|
|
28
|
+
# Run as non-root user for security
|
|
29
|
+
USER node
|
|
30
|
+
|
|
31
|
+
EXPOSE 80
|
|
32
|
+
|
|
33
|
+
CMD ["node", "dist/index.js"]
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// ABOUTME: Express API server for ECS container deployment with PostgreSQL
|
|
2
|
+
// ABOUTME: Provides REST endpoints with database connection scaffolding
|
|
3
|
+
|
|
4
|
+
import express, { Request, Response, NextFunction } from 'express';
|
|
5
|
+
import cors from 'cors';
|
|
6
|
+
import { SecretsManagerClient, GetSecretValueCommand } from '@aws-sdk/client-secrets-manager';
|
|
7
|
+
import { Pool } from 'pg';
|
|
8
|
+
|
|
9
|
+
const app = express();
|
|
10
|
+
const PORT = process.env.PORT || 80;
|
|
11
|
+
|
|
12
|
+
// Middleware
|
|
13
|
+
app.use(cors());
|
|
14
|
+
app.use(express.json());
|
|
15
|
+
|
|
16
|
+
// Request logging
|
|
17
|
+
app.use((req: Request, _res: Response, next: NextFunction) => {
|
|
18
|
+
console.log(`${new Date().toISOString()} ${req.method} ${req.path}`);
|
|
19
|
+
next();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Database connection pool with lazy initialization.
|
|
24
|
+
* Credentials are retrieved from AWS Secrets Manager.
|
|
25
|
+
*/
|
|
26
|
+
let pool: Pool | null = null;
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
29
|
+
async function getPool(): Promise<Pool> {
|
|
30
|
+
if (pool) return pool;
|
|
31
|
+
|
|
32
|
+
const secretArn = process.env.DB_SECRET_ARN;
|
|
33
|
+
if (!secretArn) {
|
|
34
|
+
throw new Error('DB_SECRET_ARN environment variable not set');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const client = new SecretsManagerClient({});
|
|
38
|
+
const secret = await client.send(
|
|
39
|
+
new GetSecretValueCommand({
|
|
40
|
+
SecretId: secretArn,
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (!secret.SecretString) {
|
|
45
|
+
throw new Error('Failed to retrieve database credentials');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const credentials = JSON.parse(secret.SecretString);
|
|
49
|
+
|
|
50
|
+
pool = new Pool({
|
|
51
|
+
host: credentials.host,
|
|
52
|
+
port: credentials.port,
|
|
53
|
+
database: process.env.DB_NAME || credentials.database,
|
|
54
|
+
user: credentials.username,
|
|
55
|
+
password: credentials.password,
|
|
56
|
+
ssl: { rejectUnauthorized: false },
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return pool;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Health check endpoint (required for ALB health checks)
|
|
63
|
+
app.get('/health', (_req: Request, res: Response) => {
|
|
64
|
+
res.json({
|
|
65
|
+
status: 'healthy',
|
|
66
|
+
timestamp: new Date().toISOString(),
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Hello world endpoint
|
|
71
|
+
app.get('/hello', (req: Request, res: Response) => {
|
|
72
|
+
const name = req.query.name || 'World';
|
|
73
|
+
res.json({
|
|
74
|
+
message: `Hello, ${name}!`,
|
|
75
|
+
appName: process.env.APP_NAME,
|
|
76
|
+
environment: process.env.ENVIRONMENT,
|
|
77
|
+
timestamp: new Date().toISOString(),
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Example: List items from database
|
|
82
|
+
app.get('/items', async (_req: Request, res: Response) => {
|
|
83
|
+
try {
|
|
84
|
+
// TODO: Uncomment and implement database query
|
|
85
|
+
// const db = await getPool();
|
|
86
|
+
// const result = await db.query('SELECT * FROM items');
|
|
87
|
+
// res.json(result.rows);
|
|
88
|
+
|
|
89
|
+
res.json({
|
|
90
|
+
items: [],
|
|
91
|
+
message: 'Database query not implemented - see code comments',
|
|
92
|
+
});
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error('Database error:', error);
|
|
95
|
+
res.status(500).json({ error: 'Database error' });
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Example POST endpoint
|
|
100
|
+
app.post('/items', async (req: Request, res: Response) => {
|
|
101
|
+
const body = req.body;
|
|
102
|
+
console.log('Creating item:', body);
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
// TODO: Uncomment and implement database insert
|
|
106
|
+
// const db = await getPool();
|
|
107
|
+
// const result = await db.query(
|
|
108
|
+
// 'INSERT INTO items (name, data) VALUES ($1, $2) RETURNING *',
|
|
109
|
+
// [body.name, body.data]
|
|
110
|
+
// );
|
|
111
|
+
// res.status(201).json(result.rows[0]);
|
|
112
|
+
|
|
113
|
+
res.status(201).json({
|
|
114
|
+
message: 'Item created (database insert not implemented)',
|
|
115
|
+
item: body,
|
|
116
|
+
});
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error('Database error:', error);
|
|
119
|
+
res.status(500).json({ error: 'Database error' });
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Example GET with path parameter
|
|
124
|
+
app.get('/items/:id', async (req: Request, res: Response) => {
|
|
125
|
+
const { id } = req.params;
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
// TODO: Uncomment and implement database query
|
|
129
|
+
// const db = await getPool();
|
|
130
|
+
// const result = await db.query('SELECT * FROM items WHERE id = $1', [id]);
|
|
131
|
+
// if (result.rows.length === 0) {
|
|
132
|
+
// return res.status(404).json({ error: 'Not found' });
|
|
133
|
+
// }
|
|
134
|
+
// res.json(result.rows[0]);
|
|
135
|
+
|
|
136
|
+
res.json({
|
|
137
|
+
id,
|
|
138
|
+
message: `Database query not implemented for item ${id}`,
|
|
139
|
+
});
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error('Database error:', error);
|
|
142
|
+
res.status(500).json({ error: 'Database error' });
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Error handler
|
|
147
|
+
app.use((err: Error, _req: Request, res: Response, _next: NextFunction) => {
|
|
148
|
+
console.error('Error:', err);
|
|
149
|
+
res.status(500).json({
|
|
150
|
+
error: 'Internal Server Error',
|
|
151
|
+
message: err.message,
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// Start server
|
|
156
|
+
app.listen(PORT, () => {
|
|
157
|
+
console.log(`Server running on port ${PORT}`);
|
|
158
|
+
console.log(`APP_NAME: ${process.env.APP_NAME}`);
|
|
159
|
+
console.log(`ENVIRONMENT: ${process.env.ENVIRONMENT}`);
|
|
160
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"start": "node dist/index.js",
|
|
9
|
+
"dev": "ts-node index.ts"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@aws-sdk/client-secrets-manager": "^3.400.0",
|
|
13
|
+
"cors": "^2.8.5",
|
|
14
|
+
"express": "^4.18.2",
|
|
15
|
+
"pg": "^8.11.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/cors": "^2.8.17",
|
|
19
|
+
"@types/express": "^4.17.21",
|
|
20
|
+
"@types/node": "^20.10.0",
|
|
21
|
+
"@types/pg": "^8.10.0",
|
|
22
|
+
"ts-node": "^10.9.0",
|
|
23
|
+
"typescript": "^5.3.0"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2022"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"declarationMap": true,
|
|
14
|
+
"sourceMap": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["*.ts"],
|
|
17
|
+
"exclude": ["node_modules", "dist"]
|
|
18
|
+
}
|