@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.
Files changed (278) hide show
  1. package/dist/commands/config.d.ts +30 -0
  2. package/dist/commands/config.d.ts.map +1 -0
  3. package/dist/commands/config.js +135 -0
  4. package/dist/commands/config.js.map +1 -0
  5. package/dist/commands/deploy.d.ts +2 -0
  6. package/dist/commands/deploy.d.ts.map +1 -0
  7. package/dist/commands/deploy.js +224 -0
  8. package/dist/commands/deploy.js.map +1 -0
  9. package/dist/commands/destroy.d.ts +3 -0
  10. package/dist/commands/destroy.d.ts.map +1 -0
  11. package/dist/commands/destroy.js +110 -0
  12. package/dist/commands/destroy.js.map +1 -0
  13. package/dist/commands/init.d.ts +25 -0
  14. package/dist/commands/init.d.ts.map +1 -0
  15. package/dist/commands/init.js +513 -0
  16. package/dist/commands/init.js.map +1 -0
  17. package/dist/commands/map.d.ts +8 -0
  18. package/dist/commands/map.d.ts.map +1 -0
  19. package/dist/commands/map.js +186 -0
  20. package/dist/commands/map.js.map +1 -0
  21. package/dist/commands/ship.d.ts +20 -0
  22. package/dist/commands/ship.d.ts.map +1 -0
  23. package/dist/commands/ship.js +445 -0
  24. package/dist/commands/ship.js.map +1 -0
  25. package/dist/commands/templates.d.ts +3 -0
  26. package/dist/commands/templates.d.ts.map +1 -0
  27. package/dist/commands/templates.js +120 -0
  28. package/dist/commands/templates.js.map +1 -0
  29. package/dist/index.d.ts +3 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +82 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/templates/_shared/city.config.json.tmpl +24 -0
  34. package/dist/templates/_shared/dotnet-api/Api.csproj +17 -0
  35. package/dist/templates/_shared/dotnet-api/Program.cs +58 -0
  36. package/dist/templates/_shared/dotnet-api/aws-lambda-tools-defaults.json +10 -0
  37. package/dist/templates/_shared/dotnet-api/obj/Api.csproj.nuget.dgspec.json +80 -0
  38. package/dist/templates/_shared/dotnet-api/obj/Api.csproj.nuget.g.props +15 -0
  39. package/dist/templates/_shared/dotnet-api/obj/Api.csproj.nuget.g.targets +2 -0
  40. package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
  41. package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
  42. package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
  43. package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
  44. package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
  45. package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.assets.cache +0 -0
  46. package/dist/templates/_shared/dotnet-api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
  47. package/dist/templates/_shared/dotnet-api/obj/project.assets.json +708 -0
  48. package/dist/templates/_shared/dotnet-api/obj/project.nuget.cache +35 -0
  49. package/dist/templates/_shared/dotnet-api-postgres/Api.csproj +19 -0
  50. package/dist/templates/_shared/dotnet-api-postgres/Program.cs +167 -0
  51. package/dist/templates/_shared/dotnet-api-postgres/aws-lambda-tools-defaults.json +10 -0
  52. package/dist/templates/_shared/dotnet-api-postgres/obj/Api.csproj.nuget.dgspec.json +88 -0
  53. package/dist/templates/_shared/dotnet-api-postgres/obj/Api.csproj.nuget.g.props +15 -0
  54. package/dist/templates/_shared/dotnet-api-postgres/obj/Api.csproj.nuget.g.targets +2 -0
  55. package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
  56. package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
  57. package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
  58. package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
  59. package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
  60. package/dist/templates/_shared/dotnet-api-postgres/obj/Debug/net8.0/Api.assets.cache +0 -0
  61. package/dist/templates/_shared/dotnet-api-postgres/obj/project.assets.json +106 -0
  62. package/dist/templates/_shared/dotnet-api-postgres/obj/project.nuget.cache +15 -0
  63. package/dist/templates/_shared/nuxt-frontend/app.vue +3 -0
  64. package/dist/templates/_shared/nuxt-frontend/nuxt.config.ts +25 -0
  65. package/dist/templates/_shared/nuxt-frontend/package.json.tmpl +19 -0
  66. package/dist/templates/_shared/nuxt-frontend/pages/index.vue +6 -0
  67. package/dist/templates/_shared/nuxt-frontend/public/.gitkeep +0 -0
  68. package/dist/templates/_shared/nuxt-frontend/tsconfig.json +3 -0
  69. package/dist/templates/_shared/webapp-cdk-package.json.tmpl +23 -0
  70. package/dist/templates/_shared/webapp-frontend/app.vue +3 -0
  71. package/dist/templates/_shared/webapp-frontend/nuxt.config.ts +25 -0
  72. package/dist/templates/_shared/webapp-frontend/package.json.tmpl +19 -0
  73. package/dist/templates/_shared/webapp-frontend/pages/index.vue +7 -0
  74. package/dist/templates/_shared/webapp-frontend/public/.gitkeep +0 -0
  75. package/dist/templates/_shared/webapp-frontend/tsconfig.json +3 -0
  76. package/dist/templates/lambda-api-nodejs/README.md.tmpl +203 -0
  77. package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/index.ts +89 -0
  78. package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/package.json +17 -0
  79. package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/tsconfig.json +8 -0
  80. package/dist/templates/lambda-api-nodejs/cdk/app.ts.tmpl +53 -0
  81. package/dist/templates/lambda-api-nodejs/cdk/cdk.json +68 -0
  82. package/dist/templates/lambda-api-nodejs/cdk/package.json +23 -0
  83. package/dist/templates/lambda-api-nodejs/cdk/tsconfig.json +9 -0
  84. package/dist/templates/lambda-api-nodejs/package.json.tmpl +20 -0
  85. package/dist/templates/lambda-api-nodejs/tsconfig.json +27 -0
  86. package/dist/templates/lambda-dynamo-api/README.md.tmpl +184 -0
  87. package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/index.ts +109 -0
  88. package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/package.json +19 -0
  89. package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/tsconfig.json +24 -0
  90. package/dist/templates/lambda-dynamo-api/cdk/app.ts.tmpl +59 -0
  91. package/dist/templates/lambda-dynamo-api/cdk/cdk.json +73 -0
  92. package/dist/templates/lambda-dynamo-api/cdk/package.json +23 -0
  93. package/dist/templates/lambda-dynamo-api/cdk/tsconfig.json +14 -0
  94. package/dist/templates/lambda-dynamo-api/package.json.tmpl +20 -0
  95. package/dist/templates/lambda-dynamo-api/tsconfig.json +27 -0
  96. package/dist/templates/lambda-postgres-api/README.md.tmpl +234 -0
  97. package/dist/templates/lambda-postgres-api/apps/__lambdaName__/index.ts +76 -0
  98. package/dist/templates/lambda-postgres-api/apps/__lambdaName__/package.json +18 -0
  99. package/dist/templates/lambda-postgres-api/apps/__lambdaName__/tsconfig.json +26 -0
  100. package/dist/templates/lambda-postgres-api/cdk/app.ts.tmpl +55 -0
  101. package/dist/templates/lambda-postgres-api/cdk/cdk.json +4 -0
  102. package/dist/templates/lambda-postgres-api/cdk/package.json +23 -0
  103. package/dist/templates/lambda-postgres-api/cdk/tsconfig.json +25 -0
  104. package/dist/templates/lambda-postgres-api/package.json.tmpl +20 -0
  105. package/dist/templates/lambda-postgres-api/tsconfig.json +11 -0
  106. package/dist/templates/static-site/README.md.tmpl +72 -0
  107. package/dist/templates/static-site/cdk/app.ts.tmpl +50 -0
  108. package/dist/templates/static-site/cdk/cdk.json +68 -0
  109. package/dist/templates/static-site/cdk/package.json +23 -0
  110. package/dist/templates/static-site/cdk/tsconfig.json +9 -0
  111. package/dist/templates/static-site/frontend/.gitkeep +0 -0
  112. package/dist/templates/static-site/frontend/README.md +41 -0
  113. package/dist/templates/static-site/frontend/package.json +9 -0
  114. package/dist/templates/static-site/package.json.tmpl +19 -0
  115. package/dist/templates/static-site/tsconfig.json +27 -0
  116. package/dist/templates/webapp-ecs-dotnet/README.md.tmpl +213 -0
  117. package/dist/templates/webapp-ecs-dotnet/apps/api/Api.csproj +12 -0
  118. package/dist/templates/webapp-ecs-dotnet/apps/api/Dockerfile +30 -0
  119. package/dist/templates/webapp-ecs-dotnet/apps/api/Program.cs +85 -0
  120. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +70 -0
  121. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Api.csproj.nuget.g.props +15 -0
  122. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
  123. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
  124. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
  125. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
  126. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
  127. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
  128. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
  129. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/project.assets.json +75 -0
  130. package/dist/templates/webapp-ecs-dotnet/apps/api/obj/project.nuget.cache +8 -0
  131. package/dist/templates/webapp-ecs-dotnet/cdk/app.ts.tmpl +60 -0
  132. package/dist/templates/webapp-ecs-dotnet/cdk/cdk.json +38 -0
  133. package/dist/templates/webapp-ecs-dotnet/cdk/tsconfig.json +25 -0
  134. package/dist/templates/webapp-ecs-dotnet/package.json.tmpl +23 -0
  135. package/dist/templates/webapp-ecs-dotnet/tsconfig.json +26 -0
  136. package/dist/templates/webapp-ecs-node/README.md.tmpl +207 -0
  137. package/dist/templates/webapp-ecs-node/apps/api/Dockerfile +33 -0
  138. package/dist/templates/webapp-ecs-node/apps/api/index.ts +74 -0
  139. package/dist/templates/webapp-ecs-node/apps/api/package.json +22 -0
  140. package/dist/templates/webapp-ecs-node/apps/api/tsconfig.json +18 -0
  141. package/dist/templates/webapp-ecs-node/cdk/app.ts.tmpl +60 -0
  142. package/dist/templates/webapp-ecs-node/cdk/cdk.json +38 -0
  143. package/dist/templates/webapp-ecs-node/cdk/tsconfig.json +25 -0
  144. package/dist/templates/webapp-ecs-node/package.json.tmpl +25 -0
  145. package/dist/templates/webapp-ecs-node/tsconfig.json +26 -0
  146. package/dist/templates/webapp-ecs-postgres-dotnet/README.md.tmpl +271 -0
  147. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/Api.csproj +17 -0
  148. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/Dockerfile +30 -0
  149. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/Program.cs +194 -0
  150. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +80 -0
  151. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.props +19 -0
  152. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +6 -0
  153. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
  154. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
  155. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
  156. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
  157. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
  158. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
  159. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
  160. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/project.assets.json +395 -0
  161. package/dist/templates/webapp-ecs-postgres-dotnet/apps/api/obj/project.nuget.cache +49 -0
  162. package/dist/templates/webapp-ecs-postgres-dotnet/cdk/app.ts.tmpl +62 -0
  163. package/dist/templates/webapp-ecs-postgres-dotnet/cdk/cdk.json +38 -0
  164. package/dist/templates/webapp-ecs-postgres-dotnet/cdk/tsconfig.json +25 -0
  165. package/dist/templates/webapp-ecs-postgres-dotnet/package.json.tmpl +23 -0
  166. package/dist/templates/webapp-ecs-postgres-dotnet/tsconfig.json +26 -0
  167. package/dist/templates/webapp-ecs-postgres-node/README.md.tmpl +261 -0
  168. package/dist/templates/webapp-ecs-postgres-node/apps/api/Dockerfile +33 -0
  169. package/dist/templates/webapp-ecs-postgres-node/apps/api/index.ts +160 -0
  170. package/dist/templates/webapp-ecs-postgres-node/apps/api/package.json +25 -0
  171. package/dist/templates/webapp-ecs-postgres-node/apps/api/tsconfig.json +18 -0
  172. package/dist/templates/webapp-ecs-postgres-node/cdk/app.ts.tmpl +62 -0
  173. package/dist/templates/webapp-ecs-postgres-node/cdk/cdk.json +38 -0
  174. package/dist/templates/webapp-ecs-postgres-node/cdk/tsconfig.json +25 -0
  175. package/dist/templates/webapp-ecs-postgres-node/package.json.tmpl +25 -0
  176. package/dist/templates/webapp-ecs-postgres-node/tsconfig.json +26 -0
  177. package/dist/templates/webapp-lambda-dotnet/README.md.tmpl +188 -0
  178. package/dist/templates/webapp-lambda-dotnet/apps/api/Api.csproj +17 -0
  179. package/dist/templates/webapp-lambda-dotnet/apps/api/Program.cs +58 -0
  180. package/dist/templates/webapp-lambda-dotnet/apps/api/aws-lambda-tools-defaults.json +10 -0
  181. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +80 -0
  182. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Api.csproj.nuget.g.props +15 -0
  183. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
  184. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
  185. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
  186. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
  187. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
  188. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
  189. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
  190. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
  191. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/project.assets.json +708 -0
  192. package/dist/templates/webapp-lambda-dotnet/apps/api/obj/project.nuget.cache +35 -0
  193. package/dist/templates/webapp-lambda-dotnet/cdk/app.ts.tmpl +59 -0
  194. package/dist/templates/webapp-lambda-dotnet/cdk/cdk.json +68 -0
  195. package/dist/templates/webapp-lambda-dotnet/cdk/tsconfig.json +9 -0
  196. package/dist/templates/webapp-lambda-dotnet/package.json.tmpl +23 -0
  197. package/dist/templates/webapp-lambda-dotnet/tsconfig.json +27 -0
  198. package/dist/templates/webapp-lambda-dynamo-dotnet/README.md.tmpl +223 -0
  199. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/Api.csproj +18 -0
  200. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/Program.cs +155 -0
  201. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/aws-lambda-tools-defaults.json +10 -0
  202. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +84 -0
  203. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Api.csproj.nuget.g.props +19 -0
  204. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
  205. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
  206. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
  207. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
  208. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
  209. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
  210. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
  211. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/Debug/net8.0/Api.csproj.AssemblyReference.cache +0 -0
  212. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/project.assets.json +989 -0
  213. package/dist/templates/webapp-lambda-dynamo-dotnet/apps/api/obj/project.nuget.cache +223 -0
  214. package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/app.ts.tmpl +65 -0
  215. package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/cdk.json +68 -0
  216. package/dist/templates/webapp-lambda-dynamo-dotnet/cdk/tsconfig.json +9 -0
  217. package/dist/templates/webapp-lambda-dynamo-dotnet/package.json.tmpl +23 -0
  218. package/dist/templates/webapp-lambda-dynamo-dotnet/tsconfig.json +27 -0
  219. package/dist/templates/webapp-lambda-dynamo-node/README.md.tmpl +189 -0
  220. package/dist/templates/webapp-lambda-dynamo-node/apps/api/index.ts +109 -0
  221. package/dist/templates/webapp-lambda-dynamo-node/apps/api/package.json +19 -0
  222. package/dist/templates/webapp-lambda-dynamo-node/apps/api/tsconfig.json +8 -0
  223. package/dist/templates/webapp-lambda-dynamo-node/cdk/app.ts.tmpl +65 -0
  224. package/dist/templates/webapp-lambda-dynamo-node/cdk/cdk.json +68 -0
  225. package/dist/templates/webapp-lambda-dynamo-node/cdk/tsconfig.json +9 -0
  226. package/dist/templates/webapp-lambda-dynamo-node/package.json.tmpl +24 -0
  227. package/dist/templates/webapp-lambda-dynamo-node/tsconfig.json +27 -0
  228. package/dist/templates/webapp-lambda-node/README.md.tmpl +179 -0
  229. package/dist/templates/webapp-lambda-node/apps/api/index.ts +100 -0
  230. package/dist/templates/webapp-lambda-node/apps/api/package.json +17 -0
  231. package/dist/templates/webapp-lambda-node/apps/api/tsconfig.json +8 -0
  232. package/dist/templates/webapp-lambda-node/cdk/app.ts.tmpl +59 -0
  233. package/dist/templates/webapp-lambda-node/cdk/cdk.json +68 -0
  234. package/dist/templates/webapp-lambda-node/cdk/tsconfig.json +9 -0
  235. package/dist/templates/webapp-lambda-node/package.json.tmpl +24 -0
  236. package/dist/templates/webapp-lambda-node/tsconfig.json +27 -0
  237. package/dist/templates/webapp-lambda-postgres-dotnet/README.md.tmpl +240 -0
  238. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/Api.csproj +19 -0
  239. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/Program.cs +167 -0
  240. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/aws-lambda-tools-defaults.json +10 -0
  241. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Api.csproj.nuget.dgspec.json +88 -0
  242. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.props +15 -0
  243. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Api.csproj.nuget.g.targets +2 -0
  244. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
  245. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfo.cs +22 -0
  246. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.AssemblyInfoInputs.cache +1 -0
  247. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GeneratedMSBuildEditorConfig.editorconfig +19 -0
  248. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.GlobalUsings.g.cs +17 -0
  249. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/Debug/net8.0/Api.assets.cache +0 -0
  250. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/project.assets.json +106 -0
  251. package/dist/templates/webapp-lambda-postgres-dotnet/apps/api/obj/project.nuget.cache +15 -0
  252. package/dist/templates/webapp-lambda-postgres-dotnet/cdk/app.ts.tmpl +61 -0
  253. package/dist/templates/webapp-lambda-postgres-dotnet/cdk/cdk.json +68 -0
  254. package/dist/templates/webapp-lambda-postgres-dotnet/cdk/tsconfig.json +9 -0
  255. package/dist/templates/webapp-lambda-postgres-dotnet/package.json.tmpl +23 -0
  256. package/dist/templates/webapp-lambda-postgres-dotnet/tsconfig.json +27 -0
  257. package/dist/templates/webapp-lambda-postgres-node/README.md.tmpl +190 -0
  258. package/dist/templates/webapp-lambda-postgres-node/apps/api/index.ts +76 -0
  259. package/dist/templates/webapp-lambda-postgres-node/apps/api/package.json +18 -0
  260. package/dist/templates/webapp-lambda-postgres-node/apps/api/tsconfig.json +8 -0
  261. package/dist/templates/webapp-lambda-postgres-node/cdk/app.ts.tmpl +61 -0
  262. package/dist/templates/webapp-lambda-postgres-node/cdk/cdk.json +68 -0
  263. package/dist/templates/webapp-lambda-postgres-node/cdk/tsconfig.json +9 -0
  264. package/dist/templates/webapp-lambda-postgres-node/package.json.tmpl +24 -0
  265. package/dist/templates/webapp-lambda-postgres-node/tsconfig.json +27 -0
  266. package/dist/utils/aws.d.ts +4 -0
  267. package/dist/utils/aws.d.ts.map +1 -0
  268. package/dist/utils/aws.js +90 -0
  269. package/dist/utils/aws.js.map +1 -0
  270. package/dist/utils/dependencies.d.ts +27 -0
  271. package/dist/utils/dependencies.d.ts.map +1 -0
  272. package/dist/utils/dependencies.js +267 -0
  273. package/dist/utils/dependencies.js.map +1 -0
  274. package/dist/utils/template.d.ts +23 -0
  275. package/dist/utils/template.d.ts.map +1 -0
  276. package/dist/utils/template.js +115 -0
  277. package/dist/utils/template.js.map +1 -0
  278. package/package.json +48 -0
@@ -0,0 +1,60 @@
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, EcsApi, 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 EcsApi construct for the containerized API backend
49
+ new EcsApi(stack, '{{appName}}Api', {
50
+ ...context,
51
+ apiId: 'api',
52
+ image: ecs.ContainerImage.fromAsset(path.join(__dirname, '../apps/api')),
53
+ containerPort: 80,
54
+ });
55
+
56
+ // Apply compliance checks
57
+ Aspects.of(app).add(new NIST80053R5Checks({ verbose: true }));
58
+ Aspects.of(app).add(new AwsSolutionsChecks({ verbose: true }));
59
+
60
+ 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,25 @@
1
+ {
2
+ "name": "{{appName}}",
3
+ "version": "1.0.0",
4
+ "description": "Web application with Nuxt frontend and ECS containerized API backend",
5
+ "private": true,
6
+ "scripts": {
7
+ "build": "npm run build --workspaces",
8
+ "build:frontend": "cd frontend && npm run build",
9
+ "build:api": "cd apps/api && npm run build",
10
+ "dev": "cd frontend && npm run dev",
11
+ "dev:api": "cd apps/api && npm run dev",
12
+ "test": "npm test --workspaces --if-present",
13
+ "synth": "cd cdk && cdk synth",
14
+ "deploy": "cd cdk && cdk deploy",
15
+ "diff": "cd cdk && cdk diff"
16
+ },
17
+ "workspaces": [
18
+ "cdk",
19
+ "apps/*",
20
+ "frontend"
21
+ ],
22
+ "devDependencies": {
23
+ "typescript": "^5.3.0"
24
+ }
25
+ }
@@ -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,271 @@
1
+ # {{appName}}
2
+
3
+ Web application with Nuxt SSG frontend, ECS containerized .NET API backend, and PostgreSQL using Philadelphia constructs.
4
+
5
+ Generated on {{timestamp}}
6
+
7
+ ## Architecture
8
+
9
+ ![Architecture Diagram](https://github.com/CityOfPhiladelphia/phila-ctl/blob/main/packages/constructs/docs/diagrams/webapp-ecs-postgres.drawio)
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
+ - .NET 8 SDK
19
+ - Docker (for building container images)
20
+ - AWS CLI configured with SSO
21
+ - AWS profile named `phila-{{appName}}`
22
+
23
+ ### Setup
24
+
25
+ ```bash
26
+ # Install frontend and CDK dependencies
27
+ npm install
28
+
29
+ # Restore .NET dependencies
30
+ cd apps/api && dotnet restore && cd ../..
31
+ ```
32
+
33
+ ### Development
34
+
35
+ ```bash
36
+ # Run frontend dev server
37
+ npm run dev
38
+
39
+ # Run API locally (requires local Postgres or connection to dev database)
40
+ cd apps/api && dotnet run
41
+
42
+ # Build frontend for production
43
+ npm run build:frontend
44
+
45
+ # Build API Docker image
46
+ npm run build:api
47
+ ```
48
+
49
+ ### Deployment
50
+
51
+ ```bash
52
+ # Configure AWS profile
53
+ export AWS_PROFILE=phila-{{appName}}
54
+
55
+ # Deploy to dev environment
56
+ city deploy dev
57
+
58
+ # Deploy to test environment
59
+ city deploy test
60
+
61
+ # Deploy to production (requires confirmation)
62
+ city deploy prod
63
+ ```
64
+
65
+ ### Shipping Updates
66
+
67
+ ```bash
68
+ # Ship frontend changes to S3/CloudFront
69
+ city ship dev --web
70
+
71
+ # Ship API changes (rebuilds and deploys ECS container)
72
+ city ship dev --ecs api
73
+ ```
74
+
75
+ ## Project Structure
76
+
77
+ ```
78
+ .
79
+ ├── cdk/ # CDK infrastructure code
80
+ │ └── app.ts # Main CDK application
81
+ ├── frontend/ # Nuxt 3 SSG frontend
82
+ │ ├── pages/ # File-based routing
83
+ │ ├── app.vue # Root component
84
+ │ └── nuxt.config.ts # Nuxt configuration
85
+ ├── apps/ # Backend code
86
+ │ └── api/ # .NET Minimal API container with Postgres
87
+ │ ├── Program.cs # API entry point and routes
88
+ │ ├── Api.csproj # Project file
89
+ │ └── Dockerfile # Container build file
90
+ └── city.config.json # City CLI configuration
91
+ ```
92
+
93
+ ## Frontend
94
+
95
+ The frontend uses [Nuxt 3](https://nuxt.com) with Static Site Generation (SSG):
96
+
97
+ - Pre-renders to static HTML for S3/CloudFront
98
+ - File-based routing in `pages/` directory
99
+ - TypeScript support enabled
100
+
101
+ ### Adding Pages
102
+
103
+ Create Vue files in `frontend/pages/`:
104
+
105
+ ```vue
106
+ <!-- frontend/pages/about.vue -->
107
+ <template>
108
+ <div>
109
+ <h1>About</h1>
110
+ </div>
111
+ </template>
112
+ ```
113
+
114
+ This automatically creates a route at `/about`.
115
+
116
+ ## API
117
+
118
+ The API uses [.NET Minimal API](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis) running in an ECS Fargate container with PostgreSQL via Npgsql.
119
+
120
+ ### Adding Endpoints
121
+
122
+ Edit `apps/api/Program.cs`:
123
+
124
+ ```csharp
125
+ // List all users
126
+ app.MapGet("/users", async (DbConnectionFactory db) =>
127
+ {
128
+ await using var conn = await db.GetConnectionAsync();
129
+ await using var cmd = new NpgsqlCommand("SELECT * FROM users", conn);
130
+ await using var reader = await cmd.ExecuteReaderAsync();
131
+
132
+ var users = new List<object>();
133
+ while (await reader.ReadAsync())
134
+ {
135
+ users.Add(new { Id = reader.GetString(0), Name = reader.GetString(1) });
136
+ }
137
+ return Results.Ok(users);
138
+ });
139
+ ```
140
+
141
+ ### Environment Variables
142
+
143
+ ECS containers automatically receive:
144
+ - `APP_NAME` - Application name ({{appName}})
145
+ - `ENVIRONMENT` - Current environment (dev/test/prod)
146
+ - `DB_SECRET_ARN` - ARN of Secrets Manager secret containing database credentials
147
+ - `DB_NAME` - Database name
148
+
149
+ ### Database Connection
150
+
151
+ The `DbConnectionFactory` class handles:
152
+ - Retrieving credentials from AWS Secrets Manager
153
+ - Building connection strings with SSL
154
+ - Connection caching for container performance
155
+
156
+ ### Local Development
157
+
158
+ Run the API locally:
159
+
160
+ ```bash
161
+ cd apps/api
162
+ dotnet run
163
+ ```
164
+
165
+ Or build and run the Docker container:
166
+
167
+ ```bash
168
+ cd apps/api
169
+ docker build -t {{appName}}-api .
170
+ docker run -p 80:80 \
171
+ -e APP_NAME={{appName}} \
172
+ -e ENVIRONMENT=dev \
173
+ -e DB_SECRET_ARN=<secret-arn> \
174
+ -e DB_NAME={{appName}} \
175
+ {{appName}}-api
176
+ ```
177
+
178
+ ## PostgreSQL
179
+
180
+ The template creates an RDS PostgreSQL instance with:
181
+ - **Engine**: PostgreSQL 15
182
+ - **Instance class**: db.t3.micro (dev), db.t3.small (test/prod)
183
+ - **Storage**: Encrypted with KMS
184
+ - **Credentials**: Stored in Secrets Manager
185
+ - **Network**: VPC with private subnets
186
+
187
+ ### Database Migrations
188
+
189
+ Run migrations manually or via a CI/CD pipeline:
190
+
191
+ ```bash
192
+ # Connect via bastion host or VPN
193
+ psql -h <rds-endpoint> -U postgres -d {{appName}}
194
+
195
+ # Create tables
196
+ CREATE TABLE items (
197
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
198
+ name VARCHAR(255) NOT NULL,
199
+ description TEXT,
200
+ created_at TIMESTAMP DEFAULT NOW(),
201
+ updated_at TIMESTAMP DEFAULT NOW()
202
+ );
203
+ ```
204
+
205
+ ### Serverless Option
206
+
207
+ For variable workloads, use Aurora Serverless:
208
+
209
+ ```typescript
210
+ // In cdk/app.ts:
211
+ new EcsPostgresApi(stack, '{{appName}}Api', {
212
+ ...context,
213
+ serverless: true, // Use Aurora Serverless v2
214
+ });
215
+ ```
216
+
217
+ ## Resources Created
218
+
219
+ This application creates:
220
+
221
+ **Frontend:**
222
+ - **S3 Bucket** - Static asset storage
223
+ - **CloudFront Distribution** - CDN with HTTPS
224
+ - **Origin Access Control** - Secure S3 access
225
+
226
+ **API:**
227
+ - **ECS Fargate Service** - Containerized compute
228
+ - **Application Load Balancer** - HTTP/HTTPS ingress
229
+ - **ECS Cluster** - Container orchestration
230
+ - **ECR Repository** - Docker image storage
231
+ - **RDS PostgreSQL** - Relational database
232
+ - **Secrets Manager** - Database credentials
233
+ - **VPC Security Groups** - Network security
234
+ - **IAM Roles** - Task execution permissions
235
+
236
+ **Shared:**
237
+ - **SSM Parameters** - Resource discovery
238
+ - **CloudWatch Logs** - Application logs
239
+ - **KMS Keys** - Encryption
240
+
241
+ ## URLs
242
+
243
+ After deployment, URLs are available via:
244
+
245
+ ```bash
246
+ # Frontend URL
247
+ city config list --env dev | grep cloudfront
248
+
249
+ # API URL (ALB endpoint)
250
+ city config list --env dev | grep ecs-api
251
+ ```
252
+
253
+ ## Scaling
254
+
255
+ ECS automatically adjusts:
256
+ - **Dev**: 1 container instance
257
+ - **Test/Prod**: 2+ container instances with auto-scaling
258
+
259
+ Container resources default to:
260
+ - CPU: 256 units (0.25 vCPU)
261
+ - Memory: 512 MB
262
+
263
+ Adjust in `cdk/app.ts` by passing `cpu` and `memoryLimitMiB` props to `EcsPostgresApi`.
264
+
265
+ ## Support
266
+
267
+ For issues or questions:
268
+ - [Philadelphia Infrastructure Library Documentation](https://github.com/CityOfPhiladelphia/phila-ctl)
269
+ - [.NET Minimal APIs Documentation](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis)
270
+ - [Npgsql Documentation](https://www.npgsql.org/)
271
+ - [Nuxt Documentation](https://nuxt.com/docs)
@@ -0,0 +1,17 @@
1
+ <!-- ABOUTME: .NET 8 Minimal API project for ECS with PostgreSQL -->
2
+ <!-- ABOUTME: Uses Npgsql for database access and AWS SDK for Secrets Manager -->
3
+ <Project Sdk="Microsoft.NET.Sdk.Web">
4
+ <PropertyGroup>
5
+ <TargetFramework>net8.0</TargetFramework>
6
+ <Nullable>enable</Nullable>
7
+ <ImplicitUsings>enable</ImplicitUsings>
8
+ <OutputType>Exe</OutputType>
9
+ <AssemblyName>Api</AssemblyName>
10
+ <RootNamespace>Api</RootNamespace>
11
+ </PropertyGroup>
12
+
13
+ <ItemGroup>
14
+ <PackageReference Include="AWSSDK.SecretsManager" Version="3.7.400" />
15
+ <PackageReference Include="Npgsql" Version="8.0.0" />
16
+ </ItemGroup>
17
+ </Project>
@@ -0,0 +1,30 @@
1
+ # ABOUTME: Multi-stage Docker build for .NET Minimal API
2
+ # ABOUTME: Creates minimal production image with compiled application
3
+
4
+ # Build stage
5
+ FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS builder
6
+
7
+ WORKDIR /app
8
+
9
+ # Copy project file and restore dependencies
10
+ COPY *.csproj ./
11
+ RUN dotnet restore
12
+
13
+ # Copy source and build
14
+ COPY . ./
15
+ RUN dotnet publish -c Release -o publish --no-restore
16
+
17
+ # Production stage
18
+ FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
19
+
20
+ WORKDIR /app
21
+
22
+ # Copy published output from builder
23
+ COPY --from=builder /app/publish ./
24
+
25
+ # Run as non-root user for security
26
+ USER app
27
+
28
+ EXPOSE 80
29
+
30
+ ENTRYPOINT ["dotnet", "Api.dll"]
@@ -0,0 +1,194 @@
1
+ // ABOUTME: ASP.NET Core Minimal API for ECS with PostgreSQL database
2
+ // ABOUTME: Provides REST endpoints with database connection examples
3
+
4
+ using System.Text.Json;
5
+ using Amazon.SecretsManager;
6
+ using Amazon.SecretsManager.Model;
7
+ using Npgsql;
8
+
9
+ var builder = WebApplication.CreateBuilder(args);
10
+
11
+ // Configure Kestrel to listen on port 80
12
+ builder.WebHost.ConfigureKestrel(options =>
13
+ {
14
+ options.ListenAnyIP(80);
15
+ });
16
+
17
+ // Add CORS
18
+ builder.Services.AddCors(options =>
19
+ {
20
+ options.AddDefaultPolicy(policy =>
21
+ {
22
+ policy.AllowAnyOrigin()
23
+ .AllowAnyMethod()
24
+ .AllowAnyHeader();
25
+ });
26
+ });
27
+
28
+ // Register database connection factory as singleton
29
+ builder.Services.AddSingleton<DbConnectionFactory>();
30
+
31
+ var app = builder.Build();
32
+
33
+ app.UseCors();
34
+
35
+ // Request logging middleware
36
+ app.Use(async (context, next) =>
37
+ {
38
+ Console.WriteLine($"{DateTime.UtcNow:o} {context.Request.Method} {context.Request.Path}");
39
+ await next();
40
+ });
41
+
42
+ // Health check endpoint (required for ALB health checks)
43
+ app.MapGet("/health", () => Results.Ok(new
44
+ {
45
+ Status = "healthy",
46
+ Timestamp = DateTime.UtcNow.ToString("o")
47
+ }));
48
+
49
+ // Hello world endpoint
50
+ app.MapGet("/hello", (HttpContext context) =>
51
+ {
52
+ var name = context.Request.Query["name"].FirstOrDefault() ?? "World";
53
+ return Results.Ok(new
54
+ {
55
+ Message = $"Hello, {name}!",
56
+ AppName = Environment.GetEnvironmentVariable("APP_NAME"),
57
+ Environment = Environment.GetEnvironmentVariable("ENVIRONMENT"),
58
+ Timestamp = DateTime.UtcNow.ToString("o")
59
+ });
60
+ });
61
+
62
+ // Example: List items from database
63
+ app.MapGet("/items", async (DbConnectionFactory db) =>
64
+ {
65
+ // TODO: Implement database query
66
+ // await using var conn = await db.GetConnectionAsync();
67
+ // await using var cmd = new NpgsqlCommand("SELECT * FROM items", conn);
68
+ // await using var reader = await cmd.ExecuteReaderAsync();
69
+ // var items = new List<object>();
70
+ // while (await reader.ReadAsync())
71
+ // {
72
+ // items.Add(new { Id = reader.GetString(0), Name = reader.GetString(1) });
73
+ // }
74
+ // return Results.Ok(items);
75
+
76
+ return Results.Ok(new
77
+ {
78
+ Items = Array.Empty<object>(),
79
+ Message = "Database query not implemented - see code comments for Npgsql example"
80
+ });
81
+ });
82
+
83
+ // Example: Create item in database
84
+ app.MapPost("/items", async (ItemRequest request, DbConnectionFactory db) =>
85
+ {
86
+ Console.WriteLine($"Creating item: {request.Name}");
87
+
88
+ // TODO: Implement database insert
89
+ // await using var conn = await db.GetConnectionAsync();
90
+ // await using var cmd = new NpgsqlCommand(
91
+ // "INSERT INTO items (name, description) VALUES (@name, @desc) RETURNING id", conn);
92
+ // cmd.Parameters.AddWithValue("name", request.Name);
93
+ // cmd.Parameters.AddWithValue("desc", request.Description ?? (object)DBNull.Value);
94
+ // var id = await cmd.ExecuteScalarAsync();
95
+ // return Results.Created($"/items/{id}", new { Id = id, Name = request.Name });
96
+
97
+ return Results.Created($"/items/{Guid.NewGuid()}", new
98
+ {
99
+ Message = "Item created (database insert not implemented)",
100
+ Item = request
101
+ });
102
+ });
103
+
104
+ // Example: Get item by ID
105
+ app.MapGet("/items/{id}", async (string id, DbConnectionFactory db) =>
106
+ {
107
+ // TODO: Implement database query
108
+ // await using var conn = await db.GetConnectionAsync();
109
+ // await using var cmd = new NpgsqlCommand("SELECT * FROM items WHERE id = @id", conn);
110
+ // cmd.Parameters.AddWithValue("id", id);
111
+ // await using var reader = await cmd.ExecuteReaderAsync();
112
+ // if (!await reader.ReadAsync())
113
+ // {
114
+ // return Results.NotFound(new { Error = "Item not found" });
115
+ // }
116
+ // return Results.Ok(new { Id = reader.GetString(0), Name = reader.GetString(1) });
117
+
118
+ return Results.Ok(new
119
+ {
120
+ Id = id,
121
+ Message = $"Database query not implemented for item {id}"
122
+ });
123
+ });
124
+
125
+ Console.WriteLine($"Server starting on port 80");
126
+ Console.WriteLine($"APP_NAME: {Environment.GetEnvironmentVariable("APP_NAME")}");
127
+ Console.WriteLine($"ENVIRONMENT: {Environment.GetEnvironmentVariable("ENVIRONMENT")}");
128
+
129
+ app.Run();
130
+
131
+ /// <summary>
132
+ /// Request model for creating items
133
+ /// </summary>
134
+ public record ItemRequest(string Name, string? Description);
135
+
136
+ /// <summary>
137
+ /// Factory for creating database connections using credentials from Secrets Manager.
138
+ /// Credentials are cached after first retrieval for container performance.
139
+ /// </summary>
140
+ public class DbConnectionFactory
141
+ {
142
+ private string? _connectionString;
143
+
144
+ public async Task<NpgsqlConnection> GetConnectionAsync()
145
+ {
146
+ if (_connectionString == null)
147
+ {
148
+ _connectionString = await BuildConnectionStringAsync();
149
+ }
150
+
151
+ var conn = new NpgsqlConnection(_connectionString);
152
+ await conn.OpenAsync();
153
+ return conn;
154
+ }
155
+
156
+ private static async Task<string> BuildConnectionStringAsync()
157
+ {
158
+ var secretArn = Environment.GetEnvironmentVariable("DB_SECRET_ARN");
159
+ var dbName = Environment.GetEnvironmentVariable("DB_NAME");
160
+
161
+ if (string.IsNullOrEmpty(secretArn))
162
+ {
163
+ throw new InvalidOperationException("DB_SECRET_ARN environment variable not set");
164
+ }
165
+
166
+ using var client = new AmazonSecretsManagerClient();
167
+ var response = await client.GetSecretValueAsync(new GetSecretValueRequest
168
+ {
169
+ SecretId = secretArn
170
+ });
171
+
172
+ var credentials = JsonSerializer.Deserialize<DbCredentials>(response.SecretString)
173
+ ?? throw new InvalidOperationException("Failed to deserialize database credentials");
174
+
175
+ return new NpgsqlConnectionStringBuilder
176
+ {
177
+ Host = credentials.Host,
178
+ Port = credentials.Port,
179
+ Database = dbName ?? credentials.Database,
180
+ Username = credentials.Username,
181
+ Password = credentials.Password,
182
+ SslMode = SslMode.Require,
183
+ TrustServerCertificate = true
184
+ }.ConnectionString;
185
+ }
186
+
187
+ private record DbCredentials(
188
+ string Host,
189
+ int Port,
190
+ string Database,
191
+ string Username,
192
+ string Password
193
+ );
194
+ }