@geekmidas/cli 9.0.2 → 10.0.0-alpha.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/README.md +66 -122
- package/dist/{CachedStateProvider-BdX7klRc.cjs → CachedStateProvider-BLo7zv7S.cjs} +1 -1
- package/dist/CachedStateProvider-BxoAm-B2.mjs +3 -0
- package/dist/{CachedStateProvider-klLWZXWF.cjs → CachedStateProvider-CqPdW7CB.cjs} +1 -1
- package/dist/{CachedStateProvider-klLWZXWF.cjs.map → CachedStateProvider-CqPdW7CB.cjs.map} +1 -1
- package/dist/{CachedStateProvider-CzyFct42.mjs → CachedStateProvider-DTniehMP.mjs} +1 -1
- package/dist/{CachedStateProvider-CzyFct42.mjs.map → CachedStateProvider-DTniehMP.mjs.map} +1 -1
- package/dist/{HostingerProvider-B2ZYz7Yc.mjs → HostingerProvider-Cft7lEYr.mjs} +4 -3
- package/dist/HostingerProvider-Cft7lEYr.mjs.map +1 -0
- package/dist/{HostingerProvider-CrHfsgz9.cjs → HostingerProvider-h3EbEp-Z.cjs} +4 -3
- package/dist/HostingerProvider-h3EbEp-Z.cjs.map +1 -0
- package/dist/{LocalStateProvider-CP49rjzt.mjs → LocalStateProvider-Bn6tS-oL.mjs} +1 -1
- package/dist/{LocalStateProvider-CP49rjzt.mjs.map → LocalStateProvider-Bn6tS-oL.mjs.map} +1 -1
- package/dist/{LocalStateProvider-CalzNfNA.cjs → LocalStateProvider-Db9SEjyH.cjs} +1 -1
- package/dist/{LocalStateProvider-CalzNfNA.cjs.map → LocalStateProvider-Db9SEjyH.cjs.map} +1 -1
- package/dist/{Route53Provider-tlgBzrRQ.mjs → Route53Provider-RdpUDJQk.mjs} +1 -1
- package/dist/{Route53Provider-tlgBzrRQ.mjs.map → Route53Provider-RdpUDJQk.mjs.map} +1 -1
- package/dist/{Route53Provider-DwgXiLxt.cjs → Route53Provider-di2fMM5N.cjs} +1 -1
- package/dist/{Route53Provider-DwgXiLxt.cjs.map → Route53Provider-di2fMM5N.cjs.map} +1 -1
- package/dist/{SSMStateProvider-BlrTiV5m.mjs → SSMStateProvider-BRt2py-A.mjs} +1 -1
- package/dist/{SSMStateProvider-BlrTiV5m.mjs.map → SSMStateProvider-BRt2py-A.mjs.map} +1 -1
- package/dist/{SSMStateProvider-Bt6r8CTL.cjs → SSMStateProvider-DyX8s9HI.cjs} +1 -1
- package/dist/{SSMStateProvider-Bt6r8CTL.cjs.map → SSMStateProvider-DyX8s9HI.cjs.map} +1 -1
- package/dist/{backup-provisioner-Xunq-p_8.mjs → backup-provisioner-Bgj5Vi_L.mjs} +2 -2
- package/dist/{backup-provisioner-Xunq-p_8.mjs.map → backup-provisioner-Bgj5Vi_L.mjs.map} +1 -1
- package/dist/{backup-provisioner-B3HBN-2k.cjs → backup-provisioner-BrsHwYG0.cjs} +2 -2
- package/dist/{backup-provisioner-B3HBN-2k.cjs.map → backup-provisioner-BrsHwYG0.cjs.map} +1 -1
- package/dist/{bundler-Dufq3uvI.cjs → bundler-BY1OmV1e.cjs} +44 -14
- package/dist/bundler-BY1OmV1e.cjs.map +1 -0
- package/dist/{bundler-DkA4qzUD.mjs → bundler-Be8Zg4Wd.mjs} +45 -15
- package/dist/bundler-Be8Zg4Wd.mjs.map +1 -0
- package/dist/config-D8o6I_7Z.mjs +469 -0
- package/dist/config-D8o6I_7Z.mjs.map +1 -0
- package/dist/config-DbPE1KXF.cjs +535 -0
- package/dist/config-DbPE1KXF.cjs.map +1 -0
- package/dist/config.cjs +3 -2
- package/dist/config.d.cts +2 -2
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +3 -2
- package/dist/{credentials-s1kLcIzK.mjs → credentials-B5zRHdAl.mjs} +21 -6
- package/dist/credentials-B5zRHdAl.mjs.map +1 -0
- package/dist/{credentials-C8DWtnMY.cjs → credentials-BapzjyV5.cjs} +26 -5
- package/dist/credentials-BapzjyV5.cjs.map +1 -0
- package/dist/credentials-Dh0Q6HzY.mjs +2548 -0
- package/dist/credentials-Dh0Q6HzY.mjs.map +1 -0
- package/dist/credentials-K961ThG3.cjs +2680 -0
- package/dist/credentials-K961ThG3.cjs.map +1 -0
- package/dist/deploy/sniffer-routes-worker.cjs +6 -2
- package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
- package/dist/deploy/sniffer-routes-worker.mjs +6 -2
- package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
- package/dist/discover-CAlFgYec.mjs +229 -0
- package/dist/discover-CAlFgYec.mjs.map +1 -0
- package/dist/discover-DTmFeloL.cjs +271 -0
- package/dist/discover-DTmFeloL.cjs.map +1 -0
- package/dist/dokploy-api-BS2xnJLZ.mjs +3 -0
- package/dist/{dokploy-api-CqOIKHme.cjs → dokploy-api-BsVH0y_s.cjs} +141 -32
- package/dist/dokploy-api-BsVH0y_s.cjs.map +1 -0
- package/dist/dokploy-api-BuxDRo3l.cjs +3 -0
- package/dist/{dokploy-api-sfZFlWuE.mjs → dokploy-api-aTFPz7_4.mjs} +141 -32
- package/dist/dokploy-api-aTFPz7_4.mjs.map +1 -0
- package/dist/emit-CbcRolsa.cjs +236 -0
- package/dist/emit-CbcRolsa.cjs.map +1 -0
- package/dist/emit-CiZS_5Ub.mjs +206 -0
- package/dist/emit-CiZS_5Ub.mjs.map +1 -0
- package/dist/{encryption-MfXAiFTm.cjs → encryption-C6jaU0hE.cjs} +1 -1
- package/dist/{encryption-MfXAiFTm.cjs.map → encryption-C6jaU0hE.cjs.map} +1 -1
- package/dist/{encryption-BVS7Vmzs.cjs → encryption-CHzzeR8a.cjs} +1 -1
- package/dist/encryption-CQUncu7v.mjs +3 -0
- package/dist/{encryption-CO5Q4Bhf.mjs → encryption-D-abyhZx.mjs} +1 -1
- package/dist/{encryption-CO5Q4Bhf.mjs.map → encryption-D-abyhZx.mjs.map} +1 -1
- package/dist/fullstack-secrets-C-GGohke.cjs +111 -0
- package/dist/fullstack-secrets-C-GGohke.cjs.map +1 -0
- package/dist/fullstack-secrets-D1o9-G5l.mjs +87 -0
- package/dist/fullstack-secrets-D1o9-G5l.mjs.map +1 -0
- package/dist/{fullstack-secrets-BYzi6Hwl.cjs → generator-CNzBw7g5.cjs} +1 -114
- package/dist/generator-CNzBw7g5.cjs.map +1 -0
- package/dist/{fullstack-secrets-l8s3II_H.mjs → generator-VE2JrFlY.mjs} +2 -85
- package/dist/generator-VE2JrFlY.mjs.map +1 -0
- package/dist/index-BThUzEIp.d.mts +175 -0
- package/dist/index-BThUzEIp.d.mts.map +1 -0
- package/dist/index-CHB4tSzX.d.cts +175 -0
- package/dist/index-CHB4tSzX.d.cts.map +1 -0
- package/dist/index.cjs +2530 -1810
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2506 -1786
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-Cfwi0fqF.mjs → openapi-CgpMWMmM.mjs} +174 -95
- package/dist/openapi-CgpMWMmM.mjs.map +1 -0
- package/dist/{openapi-BzNOC7_i.cjs → openapi-CljONd_M.cjs} +175 -108
- package/dist/openapi-CljONd_M.cjs.map +1 -0
- package/dist/{openapi-react-query-C4iIvpPf.mjs → openapi-react-query-Byltvm_7.mjs} +2 -2
- package/dist/openapi-react-query-Byltvm_7.mjs.map +1 -0
- package/dist/{openapi-react-query-CYWik72n.cjs → openapi-react-query-CmJ1xDbn.cjs} +2 -2
- package/dist/openapi-react-query-CmJ1xDbn.cjs.map +1 -0
- package/dist/openapi-react-query.cjs +1 -1
- package/dist/openapi-react-query.mjs +1 -1
- package/dist/openapi.cjs +4 -3
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +4 -3
- package/dist/reconcile/public.cjs +9 -0
- package/dist/reconcile/public.d.cts +125 -0
- package/dist/reconcile/public.d.cts.map +1 -0
- package/dist/reconcile/public.d.mts +125 -0
- package/dist/reconcile/public.d.mts.map +1 -0
- package/dist/reconcile/public.mjs +4 -0
- package/dist/{reconcile-B2FoJE0a.mjs → reconcile-CFs8C_1a.mjs} +5 -4
- package/dist/reconcile-CFs8C_1a.mjs.map +1 -0
- package/dist/{reconcile-BzqKJ2Rt.cjs → reconcile-D0pimNiy.cjs} +5 -4
- package/dist/reconcile-D0pimNiy.cjs.map +1 -0
- package/dist/setup-CJiQM2pX.cjs +473 -0
- package/dist/setup-CJiQM2pX.cjs.map +1 -0
- package/dist/setup-DMtU3p41.cjs +11 -0
- package/dist/setup-DOsYueeQ.mjs +443 -0
- package/dist/setup-DOsYueeQ.mjs.map +1 -0
- package/dist/setup-DSutDAlt.mjs +11 -0
- package/dist/{storage-B1wvztiJ.cjs → storage-BJmzYxt8.cjs} +1 -1
- package/dist/{storage-B1wvztiJ.cjs.map → storage-BJmzYxt8.cjs.map} +1 -1
- package/dist/{storage-DOEtT2Hr.cjs → storage-BM9hGpgv.cjs} +1 -1
- package/dist/{storage-dbb9RyBl.mjs → storage-Bi24WfoW.mjs} +1 -1
- package/dist/{storage-dbb9RyBl.mjs.map → storage-Bi24WfoW.mjs.map} +1 -1
- package/dist/{storage-Cs4WBsc4.mjs → storage-CYlGwWTj.mjs} +1 -1
- package/dist/{sync-CSooqRQ8.mjs → sync-CmEuNZsB.mjs} +2 -2
- package/dist/{sync-CSooqRQ8.mjs.map → sync-CmEuNZsB.mjs.map} +1 -1
- package/dist/sync-D306yOWu.cjs +4 -0
- package/dist/{sync-o_CtEbvR.cjs → sync-SizaChmC.cjs} +2 -2
- package/dist/{sync-o_CtEbvR.cjs.map → sync-SizaChmC.cjs.map} +1 -1
- package/dist/{sync-B5UHXwRM.mjs → sync-hOqAWHR6.mjs} +1 -1
- package/dist/{index-Bw548Bta.d.mts → types-C-arnQ1r.d.mts} +590 -143
- package/dist/types-C-arnQ1r.d.mts.map +1 -0
- package/dist/{index-DTpkeFb8.d.cts → types-abJQuk7m.d.cts} +590 -143
- package/dist/types-abJQuk7m.d.cts.map +1 -0
- package/dist/workspace/index.cjs +5 -1
- package/dist/workspace/index.d.cts +3 -3
- package/dist/workspace/index.d.mts +3 -3
- package/dist/workspace/index.mjs +2 -2
- package/dist/{workspace-D-37Ylqo.mjs → workspace-7FqprxuJ.mjs} +117 -30
- package/dist/workspace-7FqprxuJ.mjs.map +1 -0
- package/dist/workspace-8acupeaI.cjs +9 -0
- package/dist/{workspace-CQTT7HJQ.cjs → workspace-XvqO9jIv.cjs} +139 -28
- package/dist/workspace-XvqO9jIv.cjs.map +1 -0
- package/dist/workspace-yP5AHnrn.mjs +8 -0
- package/package.json +26 -9
- package/CHANGELOG.md +0 -650
- package/FUNCTION_CRON_SUPPORT.md +0 -266
- package/dist/CachedStateProvider-GcGziXh1.mjs +0 -3
- package/dist/HostingerProvider-B2ZYz7Yc.mjs.map +0 -1
- package/dist/HostingerProvider-CrHfsgz9.cjs.map +0 -1
- package/dist/bundler-DkA4qzUD.mjs.map +0 -1
- package/dist/bundler-Dufq3uvI.cjs.map +0 -1
- package/dist/config-Bbu1JKvf.mjs +0 -211
- package/dist/config-Bbu1JKvf.mjs.map +0 -1
- package/dist/config-DujV8DbR.cjs +0 -253
- package/dist/config-DujV8DbR.cjs.map +0 -1
- package/dist/credentials-C8DWtnMY.cjs.map +0 -1
- package/dist/credentials-s1kLcIzK.mjs.map +0 -1
- package/dist/dokploy-api-BPYkG-ZZ.cjs +0 -3
- package/dist/dokploy-api-BiSzWM4v.mjs +0 -3
- package/dist/dokploy-api-CqOIKHme.cjs.map +0 -1
- package/dist/dokploy-api-sfZFlWuE.mjs.map +0 -1
- package/dist/encryption-Bd_m4q3g.mjs +0 -3
- package/dist/fullstack-secrets-BYzi6Hwl.cjs.map +0 -1
- package/dist/fullstack-secrets-l8s3II_H.mjs.map +0 -1
- package/dist/index-Bw548Bta.d.mts.map +0 -1
- package/dist/index-DTpkeFb8.d.cts.map +0 -1
- package/dist/openapi-BzNOC7_i.cjs.map +0 -1
- package/dist/openapi-Cfwi0fqF.mjs.map +0 -1
- package/dist/openapi-react-query-C4iIvpPf.mjs.map +0 -1
- package/dist/openapi-react-query-CYWik72n.cjs.map +0 -1
- package/dist/reconcile-B2FoJE0a.mjs.map +0 -1
- package/dist/reconcile-BzqKJ2Rt.cjs.map +0 -1
- package/dist/setup-DDXUXzzl.mjs +0 -765
- package/dist/setup-DDXUXzzl.mjs.map +0 -1
- package/dist/setup-DLwhfyt-.cjs +0 -8
- package/dist/setup-Dh-B7YTX.mjs +0 -8
- package/dist/setup-WZ-xqAQO.cjs +0 -849
- package/dist/setup-WZ-xqAQO.cjs.map +0 -1
- package/dist/sync-BLA94rgC.cjs +0 -4
- package/dist/types-B3GQUg3k.d.mts +0 -280
- package/dist/types-B3GQUg3k.d.mts.map +0 -1
- package/dist/types-BWQDiooe.d.cts +0 -280
- package/dist/types-BWQDiooe.d.cts.map +0 -1
- package/dist/workspace-CQTT7HJQ.cjs.map +0 -1
- package/dist/workspace-D-37Ylqo.mjs.map +0 -1
- package/docs/OPENAPI_TYPESCRIPT_DESIGN.md +0 -408
- package/docs/dev-server-resilience-design.md +0 -189
- package/docs/manifest-refactor-design.md +0 -287
- package/examples/cron-example.ts +0 -45
- package/examples/env.ts +0 -33
- package/examples/function-example.ts +0 -40
- package/examples/gkm.config.json +0 -22
- package/examples/gkm.config.ts +0 -14
- package/examples/gkm.minimal.config.json +0 -7
- package/examples/gkm.production.config.json +0 -27
- package/examples/logger.ts +0 -10
- package/scripts/sync-versions.ts +0 -108
- package/src/__tests__/EndpointGenerator.hooks.spec.ts +0 -204
- package/src/__tests__/config.spec.ts +0 -422
- package/src/__tests__/loadEnvFiles.spec.ts +0 -131
- package/src/__tests__/normalizeHooksConfig.spec.ts +0 -63
- package/src/__tests__/openapi-react-query.spec.ts +0 -506
- package/src/__tests__/openapi.spec.ts +0 -625
- package/src/__tests__/test-helpers.ts +0 -181
- package/src/auth/__tests__/credentials.spec.ts +0 -331
- package/src/auth/__tests__/index.spec.ts +0 -237
- package/src/auth/credentials.ts +0 -286
- package/src/auth/index.ts +0 -233
- package/src/build/__tests__/bundler.spec.ts +0 -446
- package/src/build/__tests__/endpoint-analyzer.spec.ts +0 -623
- package/src/build/__tests__/handler-templates.spec.ts +0 -1287
- package/src/build/__tests__/index-new.spec.ts +0 -550
- package/src/build/__tests__/manifests.spec.ts +0 -583
- package/src/build/__tests__/partitions.spec.ts +0 -110
- package/src/build/__tests__/workspace-build.spec.ts +0 -215
- package/src/build/bundler.ts +0 -256
- package/src/build/endpoint-analyzer.ts +0 -236
- package/src/build/handler-templates.ts +0 -1253
- package/src/build/index.ts +0 -616
- package/src/build/manifests.ts +0 -285
- package/src/build/partitions.ts +0 -58
- package/src/build/providerResolver.ts +0 -184
- package/src/build/types.ts +0 -104
- package/src/config.ts +0 -330
- package/src/credentials/__tests__/fullDockerPorts.spec.ts +0 -144
- package/src/credentials/__tests__/helpers.ts +0 -112
- package/src/credentials/__tests__/prepareEntryCredentials.spec.ts +0 -125
- package/src/credentials/__tests__/readonlyDockerPorts.spec.ts +0 -190
- package/src/credentials/__tests__/workspaceCredentials.spec.ts +0 -209
- package/src/credentials/index.ts +0 -843
- package/src/debug.ts +0 -68
- package/src/deploy/CachedStateProvider.ts +0 -86
- package/src/deploy/LocalStateProvider.ts +0 -57
- package/src/deploy/SSMStateProvider.ts +0 -117
- package/src/deploy/StateProvider.ts +0 -175
- package/src/deploy/__tests__/CachedStateProvider.spec.ts +0 -235
- package/src/deploy/__tests__/HostingerProvider.spec.ts +0 -347
- package/src/deploy/__tests__/LocalStateProvider.spec.ts +0 -130
- package/src/deploy/__tests__/Route53Provider.spec.ts +0 -425
- package/src/deploy/__tests__/SSMStateProvider.spec.ts +0 -201
- package/src/deploy/__tests__/__fixtures__/entry-apps/async-entry.ts +0 -24
- package/src/deploy/__tests__/__fixtures__/entry-apps/nested-config-entry.ts +0 -24
- package/src/deploy/__tests__/__fixtures__/entry-apps/no-env-entry.ts +0 -12
- package/src/deploy/__tests__/__fixtures__/entry-apps/simple-entry.ts +0 -14
- package/src/deploy/__tests__/__fixtures__/entry-apps/throwing-entry.ts +0 -16
- package/src/deploy/__tests__/__fixtures__/env-parsers/non-function-export.ts +0 -10
- package/src/deploy/__tests__/__fixtures__/env-parsers/optional-env-parser.ts +0 -21
- package/src/deploy/__tests__/__fixtures__/env-parsers/parseable-env-parser.ts +0 -18
- package/src/deploy/__tests__/__fixtures__/env-parsers/throwing-env-parser.ts +0 -16
- package/src/deploy/__tests__/__fixtures__/env-parsers/valid-env-parser.ts +0 -16
- package/src/deploy/__tests__/__fixtures__/route-apps/endpoints/auth.ts +0 -16
- package/src/deploy/__tests__/__fixtures__/route-apps/endpoints/health.ts +0 -13
- package/src/deploy/__tests__/__fixtures__/route-apps/endpoints/users.ts +0 -15
- package/src/deploy/__tests__/__fixtures__/route-apps/services.ts +0 -55
- package/src/deploy/__tests__/backup-provisioner.spec.ts +0 -428
- package/src/deploy/__tests__/createDnsProvider.spec.ts +0 -195
- package/src/deploy/__tests__/createStateProvider.spec.ts +0 -126
- package/src/deploy/__tests__/dns-orchestration.spec.ts +0 -192
- package/src/deploy/__tests__/dns-verification.spec.ts +0 -229
- package/src/deploy/__tests__/docker.spec.ts +0 -149
- package/src/deploy/__tests__/dokploy-api.spec.ts +0 -697
- package/src/deploy/__tests__/dokploy.spec.ts +0 -435
- package/src/deploy/__tests__/domain.spec.ts +0 -235
- package/src/deploy/__tests__/env-resolver.spec.ts +0 -903
- package/src/deploy/__tests__/index.spec.ts +0 -1091
- package/src/deploy/__tests__/init.spec.ts +0 -793
- package/src/deploy/__tests__/secrets.spec.ts +0 -303
- package/src/deploy/__tests__/sniffer.spec.ts +0 -838
- package/src/deploy/__tests__/state-e2e.spec.ts +0 -387
- package/src/deploy/__tests__/state.spec.ts +0 -876
- package/src/deploy/__tests__/undeploy.spec.ts +0 -758
- package/src/deploy/backup-provisioner.ts +0 -316
- package/src/deploy/dns/DnsProvider.ts +0 -201
- package/src/deploy/dns/HostingerProvider.ts +0 -174
- package/src/deploy/dns/Route53Provider.ts +0 -340
- package/src/deploy/dns/hostinger-api.ts +0 -261
- package/src/deploy/dns/index.ts +0 -627
- package/src/deploy/docker.ts +0 -260
- package/src/deploy/dokploy-api.ts +0 -1101
- package/src/deploy/dokploy.ts +0 -177
- package/src/deploy/domain.ts +0 -134
- package/src/deploy/env-resolver.ts +0 -305
- package/src/deploy/index.ts +0 -2094
- package/src/deploy/init.ts +0 -427
- package/src/deploy/secrets.ts +0 -187
- package/src/deploy/sniffer-envkit-patch.ts +0 -61
- package/src/deploy/sniffer-hooks.ts +0 -57
- package/src/deploy/sniffer-loader.ts +0 -28
- package/src/deploy/sniffer-routes-worker.ts +0 -104
- package/src/deploy/sniffer-worker.ts +0 -75
- package/src/deploy/sniffer.ts +0 -578
- package/src/deploy/state-commands.ts +0 -274
- package/src/deploy/state.ts +0 -482
- package/src/deploy/types.ts +0 -102
- package/src/deploy/undeploy.ts +0 -407
- package/src/dev/__tests__/entry-integration.spec.ts +0 -347
- package/src/dev/__tests__/entry.spec.ts +0 -144
- package/src/dev/__tests__/index.spec.ts +0 -2084
- package/src/dev/index.ts +0 -1649
- package/src/docker/__tests__/compose.spec.ts +0 -1142
- package/src/docker/__tests__/templates.spec.ts +0 -694
- package/src/docker/compose.ts +0 -808
- package/src/docker/index.ts +0 -523
- package/src/docker/templates.ts +0 -1067
- package/src/exec/index.ts +0 -118
- package/src/generators/CronGenerator.ts +0 -105
- package/src/generators/EndpointGenerator.ts +0 -954
- package/src/generators/FunctionGenerator.ts +0 -117
- package/src/generators/Generator.ts +0 -147
- package/src/generators/OpenApiTsGenerator.ts +0 -821
- package/src/generators/QueueGenerator.ts +0 -245
- package/src/generators/SubscriberGenerator.ts +0 -282
- package/src/generators/TopicGenerator.ts +0 -45
- package/src/generators/__tests__/CronGenerator.spec.ts +0 -445
- package/src/generators/__tests__/EndpointGenerator.spec.ts +0 -544
- package/src/generators/__tests__/FunctionGenerator.spec.ts +0 -256
- package/src/generators/__tests__/Generator.bustCache.spec.ts +0 -72
- package/src/generators/__tests__/OpenApiTsGenerator.registry.spec.ts +0 -98
- package/src/generators/__tests__/OpenApiTsGenerator.responseType.spec.ts +0 -56
- package/src/generators/__tests__/QueueGenerator.spec.ts +0 -141
- package/src/generators/__tests__/SubscriberGenerator.spec.ts +0 -410
- package/src/generators/index.ts +0 -11
- package/src/index.ts +0 -972
- package/src/init/__tests__/generators.spec.ts +0 -1070
- package/src/init/__tests__/init.spec.ts +0 -577
- package/src/init/__tests__/utils.spec.ts +0 -104
- package/src/init/generators/auth.ts +0 -225
- package/src/init/generators/config.ts +0 -316
- package/src/init/generators/docker.ts +0 -388
- package/src/init/generators/env.ts +0 -62
- package/src/init/generators/index.ts +0 -6
- package/src/init/generators/mobile-expo.ts +0 -576
- package/src/init/generators/models.ts +0 -153
- package/src/init/generators/monorepo.ts +0 -475
- package/src/init/generators/package.ts +0 -95
- package/src/init/generators/source.ts +0 -15
- package/src/init/generators/test.ts +0 -178
- package/src/init/generators/ui.ts +0 -1473
- package/src/init/generators/web-tanstack.ts +0 -348
- package/src/init/generators/web.ts +0 -363
- package/src/init/index.ts +0 -542
- package/src/init/templates/api.ts +0 -404
- package/src/init/templates/index.ts +0 -342
- package/src/init/templates/minimal.ts +0 -207
- package/src/init/templates/serverless.ts +0 -148
- package/src/init/templates/worker.ts +0 -216
- package/src/init/utils.ts +0 -197
- package/src/init/versions.ts +0 -52
- package/src/openapi-react-query.ts +0 -288
- package/src/openapi.ts +0 -259
- package/src/secrets/__tests__/encryption.spec.ts +0 -226
- package/src/secrets/__tests__/generator.spec.ts +0 -575
- package/src/secrets/__tests__/index.spec.ts +0 -91
- package/src/secrets/__tests__/reconcile.spec.ts +0 -123
- package/src/secrets/__tests__/storage.spec.ts +0 -645
- package/src/secrets/encryption.ts +0 -91
- package/src/secrets/generator.ts +0 -329
- package/src/secrets/index.ts +0 -417
- package/src/secrets/keystore.ts +0 -144
- package/src/secrets/reconcile.ts +0 -53
- package/src/secrets/storage.ts +0 -337
- package/src/secrets/sync.ts +0 -136
- package/src/secrets/types.ts +0 -70
- package/src/setup/__tests__/auto-setup.spec.ts +0 -147
- package/src/setup/__tests__/reconcile-secrets.spec.ts +0 -439
- package/src/setup/fullstack-secrets.ts +0 -140
- package/src/setup/index.ts +0 -411
- package/src/test/__tests__/__fixtures__/workspace.ts +0 -104
- package/src/test/__tests__/api.spec.ts +0 -199
- package/src/test/__tests__/auth.spec.ts +0 -162
- package/src/test/__tests__/index.spec.ts +0 -502
- package/src/test/__tests__/web.spec.ts +0 -210
- package/src/test/index.ts +0 -198
- package/src/types.ts +0 -363
- package/src/upgrade/__tests__/index.spec.ts +0 -354
- package/src/upgrade/index.ts +0 -253
- package/src/workspace/__tests__/client-generator.spec.ts +0 -326
- package/src/workspace/__tests__/index.spec.ts +0 -766
- package/src/workspace/__tests__/publicEnv.spec.ts +0 -64
- package/src/workspace/__tests__/schema.spec.ts +0 -737
- package/src/workspace/__tests__/type-inference.spec.ts +0 -251
- package/src/workspace/client-generator.ts +0 -109
- package/src/workspace/index.ts +0 -433
- package/src/workspace/publicEnv.ts +0 -57
- package/src/workspace/schema.ts +0 -861
- package/src/workspace/types.ts +0 -943
- package/tsconfig.json +0 -9
- package/tsdown.config.ts +0 -22
|
@@ -1,954 +0,0 @@
|
|
|
1
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
-
import { dirname, join, relative } from 'node:path';
|
|
3
|
-
import { Endpoint } from '@geekmidas/constructs/endpoints';
|
|
4
|
-
import {
|
|
5
|
-
analyzeEndpoint,
|
|
6
|
-
type EndpointAnalysis,
|
|
7
|
-
summarizeAnalysis,
|
|
8
|
-
} from '../build/endpoint-analyzer';
|
|
9
|
-
import {
|
|
10
|
-
type EndpointImportInfo,
|
|
11
|
-
generateEndpointFilesNested,
|
|
12
|
-
} from '../build/handler-templates';
|
|
13
|
-
import type { BuildContext } from '../build/types';
|
|
14
|
-
import type { LegacyProvider, RouteInfo } from '../types';
|
|
15
|
-
import {
|
|
16
|
-
ConstructGenerator,
|
|
17
|
-
type GeneratedConstruct,
|
|
18
|
-
type GeneratorOptions,
|
|
19
|
-
} from './Generator';
|
|
20
|
-
|
|
21
|
-
export class EndpointGenerator extends ConstructGenerator<
|
|
22
|
-
Endpoint<
|
|
23
|
-
any,
|
|
24
|
-
any,
|
|
25
|
-
any,
|
|
26
|
-
any,
|
|
27
|
-
any,
|
|
28
|
-
any,
|
|
29
|
-
any,
|
|
30
|
-
any,
|
|
31
|
-
any,
|
|
32
|
-
any,
|
|
33
|
-
any,
|
|
34
|
-
any,
|
|
35
|
-
any,
|
|
36
|
-
any
|
|
37
|
-
>,
|
|
38
|
-
RouteInfo[]
|
|
39
|
-
> {
|
|
40
|
-
isConstruct(
|
|
41
|
-
value: any,
|
|
42
|
-
): value is Endpoint<
|
|
43
|
-
any,
|
|
44
|
-
any,
|
|
45
|
-
any,
|
|
46
|
-
any,
|
|
47
|
-
any,
|
|
48
|
-
any,
|
|
49
|
-
any,
|
|
50
|
-
any,
|
|
51
|
-
any,
|
|
52
|
-
any,
|
|
53
|
-
any,
|
|
54
|
-
any,
|
|
55
|
-
any,
|
|
56
|
-
any
|
|
57
|
-
> {
|
|
58
|
-
return Endpoint.isEndpoint(value);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async build(
|
|
62
|
-
context: BuildContext,
|
|
63
|
-
constructs: GeneratedConstruct<
|
|
64
|
-
Endpoint<
|
|
65
|
-
any,
|
|
66
|
-
any,
|
|
67
|
-
any,
|
|
68
|
-
any,
|
|
69
|
-
any,
|
|
70
|
-
any,
|
|
71
|
-
any,
|
|
72
|
-
any,
|
|
73
|
-
any,
|
|
74
|
-
any,
|
|
75
|
-
any,
|
|
76
|
-
any,
|
|
77
|
-
any,
|
|
78
|
-
any
|
|
79
|
-
>
|
|
80
|
-
>[],
|
|
81
|
-
outputDir: string,
|
|
82
|
-
options?: GeneratorOptions,
|
|
83
|
-
): Promise<RouteInfo[]> {
|
|
84
|
-
const provider = options?.provider || 'aws-apigatewayv2';
|
|
85
|
-
const enableOpenApi = options?.enableOpenApi || false;
|
|
86
|
-
const logger = console;
|
|
87
|
-
const routes: RouteInfo[] = [];
|
|
88
|
-
|
|
89
|
-
if (constructs.length === 0) {
|
|
90
|
-
return routes;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (provider === 'server') {
|
|
94
|
-
// Generate endpoints.ts and app.ts
|
|
95
|
-
await this.generateEndpointsFile(outputDir, constructs, context);
|
|
96
|
-
const appFile = await this.generateAppFile(outputDir, context);
|
|
97
|
-
|
|
98
|
-
routes.push({
|
|
99
|
-
path: '*',
|
|
100
|
-
method: 'ALL',
|
|
101
|
-
handler: relative(process.cwd(), appFile),
|
|
102
|
-
authorizer: 'none',
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
logger.log(
|
|
106
|
-
`Generated server with ${constructs.length} endpoints${enableOpenApi ? ' (OpenAPI enabled)' : ''}`,
|
|
107
|
-
);
|
|
108
|
-
} else if (provider === 'aws-lambda') {
|
|
109
|
-
// For aws-lambda, create routes subdirectory
|
|
110
|
-
const routesDir = join(outputDir, 'routes');
|
|
111
|
-
await mkdir(routesDir, { recursive: true });
|
|
112
|
-
|
|
113
|
-
// Generate individual handlers for API Gateway routes
|
|
114
|
-
for (const { key, construct, path } of constructs) {
|
|
115
|
-
const handlerFile = await this.generateHandlerFile(
|
|
116
|
-
routesDir,
|
|
117
|
-
path.relative,
|
|
118
|
-
key,
|
|
119
|
-
'aws-apigatewayv2',
|
|
120
|
-
construct,
|
|
121
|
-
context,
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
const routeInfo: RouteInfo = {
|
|
125
|
-
path: construct._path,
|
|
126
|
-
method: construct.method,
|
|
127
|
-
handler: relative(process.cwd(), handlerFile).replace(
|
|
128
|
-
/\.ts$/,
|
|
129
|
-
'.handler',
|
|
130
|
-
),
|
|
131
|
-
timeout: construct.timeout,
|
|
132
|
-
memorySize: construct.memorySize,
|
|
133
|
-
environment: await construct.getEnvironment({
|
|
134
|
-
markOptional: context.markOptional,
|
|
135
|
-
}),
|
|
136
|
-
authorizer: construct.authorizer?.name ?? 'none',
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
routes.push(routeInfo);
|
|
140
|
-
logger.log(
|
|
141
|
-
`Generated handler for ${routeInfo.method} ${routeInfo.path}`,
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
} else {
|
|
145
|
-
// Generate individual handler files for AWS API Gateway providers
|
|
146
|
-
for (const { key, construct, path } of constructs) {
|
|
147
|
-
const handlerFile = await this.generateHandlerFile(
|
|
148
|
-
outputDir,
|
|
149
|
-
path.relative,
|
|
150
|
-
key,
|
|
151
|
-
provider,
|
|
152
|
-
construct,
|
|
153
|
-
context,
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
const routeInfo: RouteInfo = {
|
|
157
|
-
path: construct._path,
|
|
158
|
-
method: construct.method,
|
|
159
|
-
handler: relative(process.cwd(), handlerFile).replace(
|
|
160
|
-
/\.ts$/,
|
|
161
|
-
'.handler',
|
|
162
|
-
),
|
|
163
|
-
timeout: construct.timeout,
|
|
164
|
-
memorySize: construct.memorySize,
|
|
165
|
-
environment: await construct.getEnvironment({
|
|
166
|
-
markOptional: context.markOptional,
|
|
167
|
-
}),
|
|
168
|
-
authorizer: construct.authorizer?.name ?? 'none',
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
routes.push(routeInfo);
|
|
172
|
-
logger.log(
|
|
173
|
-
`Generated handler for ${routeInfo.method} ${routeInfo.path}`,
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return routes;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
private async generateHandlerFile(
|
|
182
|
-
outputDir: string,
|
|
183
|
-
sourceFile: string,
|
|
184
|
-
exportName: string,
|
|
185
|
-
provider: LegacyProvider,
|
|
186
|
-
_endpoint: Endpoint<
|
|
187
|
-
any,
|
|
188
|
-
any,
|
|
189
|
-
any,
|
|
190
|
-
any,
|
|
191
|
-
any,
|
|
192
|
-
any,
|
|
193
|
-
any,
|
|
194
|
-
any,
|
|
195
|
-
any,
|
|
196
|
-
any,
|
|
197
|
-
any,
|
|
198
|
-
any,
|
|
199
|
-
any,
|
|
200
|
-
any
|
|
201
|
-
>,
|
|
202
|
-
context: BuildContext,
|
|
203
|
-
): Promise<string> {
|
|
204
|
-
const handlerFileName = `${exportName}.ts`;
|
|
205
|
-
const handlerPath = join(outputDir, handlerFileName);
|
|
206
|
-
|
|
207
|
-
const relativePath = relative(dirname(handlerPath), sourceFile);
|
|
208
|
-
const importPath = relativePath.replace(/\.ts$/, '.js');
|
|
209
|
-
|
|
210
|
-
const relativeEnvParserPath = relative(
|
|
211
|
-
dirname(handlerPath),
|
|
212
|
-
context.envParserPath,
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
let content: string;
|
|
216
|
-
|
|
217
|
-
switch (provider) {
|
|
218
|
-
case 'aws-apigatewayv1':
|
|
219
|
-
content = this.generateAWSApiGatewayV1Handler(
|
|
220
|
-
importPath,
|
|
221
|
-
exportName,
|
|
222
|
-
relativeEnvParserPath,
|
|
223
|
-
context.envParserImportPattern,
|
|
224
|
-
);
|
|
225
|
-
break;
|
|
226
|
-
case 'aws-apigatewayv2':
|
|
227
|
-
content = this.generateAWSApiGatewayV2Handler(
|
|
228
|
-
importPath,
|
|
229
|
-
exportName,
|
|
230
|
-
relativeEnvParserPath,
|
|
231
|
-
context.envParserImportPattern,
|
|
232
|
-
);
|
|
233
|
-
break;
|
|
234
|
-
case 'server':
|
|
235
|
-
content = this.generateServerHandler(importPath, exportName);
|
|
236
|
-
break;
|
|
237
|
-
default:
|
|
238
|
-
throw new Error(`Unsupported provider: ${provider}`);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
await writeFile(handlerPath, content);
|
|
242
|
-
return handlerPath;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
private async generateEndpointsFile(
|
|
246
|
-
outputDir: string,
|
|
247
|
-
endpoints: GeneratedConstruct<
|
|
248
|
-
Endpoint<
|
|
249
|
-
any,
|
|
250
|
-
any,
|
|
251
|
-
any,
|
|
252
|
-
any,
|
|
253
|
-
any,
|
|
254
|
-
any,
|
|
255
|
-
any,
|
|
256
|
-
any,
|
|
257
|
-
any,
|
|
258
|
-
any,
|
|
259
|
-
any,
|
|
260
|
-
any,
|
|
261
|
-
any,
|
|
262
|
-
any
|
|
263
|
-
>
|
|
264
|
-
>[],
|
|
265
|
-
context: BuildContext,
|
|
266
|
-
): Promise<string> {
|
|
267
|
-
const endpointsFileName = 'endpoints.ts';
|
|
268
|
-
const endpointsPath = join(outputDir, endpointsFileName);
|
|
269
|
-
|
|
270
|
-
// Group imports by file
|
|
271
|
-
const importsByFile = new Map<string, string[]>();
|
|
272
|
-
|
|
273
|
-
for (const { path, key } of endpoints) {
|
|
274
|
-
const relativePath = relative(dirname(endpointsPath), path.relative);
|
|
275
|
-
const importPath = relativePath.replace(/\.ts$/, '.js');
|
|
276
|
-
|
|
277
|
-
if (!importsByFile.has(importPath)) {
|
|
278
|
-
importsByFile.set(importPath, []);
|
|
279
|
-
}
|
|
280
|
-
importsByFile.get(importPath)?.push(key);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Generate import statements for endpoints
|
|
284
|
-
const endpointImports = Array.from(importsByFile.entries())
|
|
285
|
-
.map(
|
|
286
|
-
([importPath, exports]) =>
|
|
287
|
-
`import { ${exports.join(', ')} } from '${importPath}';`,
|
|
288
|
-
)
|
|
289
|
-
.join('\n');
|
|
290
|
-
|
|
291
|
-
const allExportNames = endpoints.map(({ key }) => key);
|
|
292
|
-
|
|
293
|
-
// Check if we should use optimized handler generation
|
|
294
|
-
if (context.production?.enabled && context.production.optimizedHandlers) {
|
|
295
|
-
return this.generateOptimizedEndpointsFile(
|
|
296
|
-
endpointsPath,
|
|
297
|
-
endpoints,
|
|
298
|
-
endpointImports,
|
|
299
|
-
allExportNames,
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// Standard generation (development or optimizedHandlers: false)
|
|
304
|
-
const content = `import type { EnvironmentParser } from '@geekmidas/envkit';
|
|
305
|
-
import type { Logger } from '@geekmidas/logger';
|
|
306
|
-
import { HonoEndpoint } from '@geekmidas/constructs/hono';
|
|
307
|
-
import { Endpoint } from '@geekmidas/constructs/endpoints';
|
|
308
|
-
import { ServiceDiscovery } from '@geekmidas/services';
|
|
309
|
-
import type { Hono } from 'hono';
|
|
310
|
-
${endpointImports}
|
|
311
|
-
|
|
312
|
-
export const endpoints: Endpoint<any, any, any, any, any, any, any, any, any, any, any, any, any, any>[] = [
|
|
313
|
-
${allExportNames.join(',\n ')}
|
|
314
|
-
];
|
|
315
|
-
|
|
316
|
-
export async function setupEndpoints(
|
|
317
|
-
app: Hono,
|
|
318
|
-
envParser: EnvironmentParser<any>,
|
|
319
|
-
logger: Logger,
|
|
320
|
-
enableOpenApi: boolean = true,
|
|
321
|
-
): Promise<void> {
|
|
322
|
-
const serviceDiscovery = ServiceDiscovery.getInstance(envParser);
|
|
323
|
-
|
|
324
|
-
// Configure OpenAPI options based on enableOpenApi flag
|
|
325
|
-
const openApiOptions: any = enableOpenApi ? {
|
|
326
|
-
docsPath: '/__docs',
|
|
327
|
-
openApiOptions: {
|
|
328
|
-
title: 'API Documentation',
|
|
329
|
-
version: '1.0.0',
|
|
330
|
-
description: 'Generated API documentation'
|
|
331
|
-
}
|
|
332
|
-
} : { docsPath: false };
|
|
333
|
-
|
|
334
|
-
HonoEndpoint.addRoutes(endpoints, serviceDiscovery, app, openApiOptions);
|
|
335
|
-
|
|
336
|
-
// Add Swagger UI if OpenAPI is enabled
|
|
337
|
-
if (enableOpenApi) {
|
|
338
|
-
try {
|
|
339
|
-
const { swaggerUI } = await import('@hono/swagger-ui');
|
|
340
|
-
app.get('/__docs/ui', swaggerUI({ url: '/__docs' }));
|
|
341
|
-
} catch {
|
|
342
|
-
// @hono/swagger-ui not installed, skip Swagger UI
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
`;
|
|
347
|
-
|
|
348
|
-
await writeFile(endpointsPath, content);
|
|
349
|
-
|
|
350
|
-
return endpointsPath;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Generate optimized endpoints files with nested folder structure (per-endpoint files)
|
|
355
|
-
*/
|
|
356
|
-
private async generateOptimizedEndpointsFile(
|
|
357
|
-
endpointsPath: string,
|
|
358
|
-
endpoints: GeneratedConstruct<
|
|
359
|
-
Endpoint<
|
|
360
|
-
any,
|
|
361
|
-
any,
|
|
362
|
-
any,
|
|
363
|
-
any,
|
|
364
|
-
any,
|
|
365
|
-
any,
|
|
366
|
-
any,
|
|
367
|
-
any,
|
|
368
|
-
any,
|
|
369
|
-
any,
|
|
370
|
-
any,
|
|
371
|
-
any,
|
|
372
|
-
any,
|
|
373
|
-
any
|
|
374
|
-
>
|
|
375
|
-
>[],
|
|
376
|
-
_endpointImports: string,
|
|
377
|
-
_allExportNames: string[],
|
|
378
|
-
): Promise<string> {
|
|
379
|
-
const logger = console;
|
|
380
|
-
const outputDir = dirname(endpointsPath);
|
|
381
|
-
|
|
382
|
-
// Create endpoints subdirectory with tier folders
|
|
383
|
-
const endpointsDir = join(outputDir, 'endpoints');
|
|
384
|
-
await mkdir(join(endpointsDir, 'minimal'), { recursive: true });
|
|
385
|
-
await mkdir(join(endpointsDir, 'standard'), { recursive: true });
|
|
386
|
-
await mkdir(join(endpointsDir, 'full'), { recursive: true });
|
|
387
|
-
|
|
388
|
-
// Analyze each endpoint
|
|
389
|
-
const analyses: EndpointAnalysis[] = endpoints.map(({ key, construct }) =>
|
|
390
|
-
analyzeEndpoint(construct, key),
|
|
391
|
-
);
|
|
392
|
-
|
|
393
|
-
// Build endpoint import info with correct relative paths from each tier folder
|
|
394
|
-
// Use paths relative to the tier folder (e.g., endpoints/standard/)
|
|
395
|
-
const endpointImports: EndpointImportInfo[] = endpoints.map(
|
|
396
|
-
({ key, path }) => {
|
|
397
|
-
// Calculate relative path from tier folder (one level deeper than endpointsDir)
|
|
398
|
-
const tierDir = join(endpointsDir, 'standard'); // Use any tier as reference - same depth
|
|
399
|
-
const relativePath = relative(tierDir, path.relative);
|
|
400
|
-
const importPath = relativePath.replace(/\.ts$/, '.js');
|
|
401
|
-
return { exportName: key, importPath };
|
|
402
|
-
},
|
|
403
|
-
);
|
|
404
|
-
|
|
405
|
-
// Log analysis summary
|
|
406
|
-
const summary = summarizeAnalysis(analyses);
|
|
407
|
-
logger.log(`\n📊 Endpoint Analysis:`);
|
|
408
|
-
logger.log(` Total: ${summary.total} endpoints`);
|
|
409
|
-
logger.log(
|
|
410
|
-
` - Minimal (near-raw-Hono): ${summary.byTier.minimal} endpoints`,
|
|
411
|
-
);
|
|
412
|
-
logger.log(
|
|
413
|
-
` - Standard (auth/services): ${summary.byTier.standard} endpoints`,
|
|
414
|
-
);
|
|
415
|
-
logger.log(
|
|
416
|
-
` - Full (audits/rls/rate-limit): ${summary.byTier.full} endpoints`,
|
|
417
|
-
);
|
|
418
|
-
|
|
419
|
-
// Generate files with nested structure (per-endpoint files)
|
|
420
|
-
const files = generateEndpointFilesNested(analyses, endpointImports);
|
|
421
|
-
|
|
422
|
-
// Write each file, creating directories as needed
|
|
423
|
-
for (const [filename, content] of Object.entries(files)) {
|
|
424
|
-
const filePath = join(endpointsDir, filename);
|
|
425
|
-
await mkdir(dirname(filePath), { recursive: true });
|
|
426
|
-
await writeFile(filePath, content);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// Count files by type
|
|
430
|
-
const endpointFiles = Object.keys(files).filter(
|
|
431
|
-
(f) => !f.endsWith('index.ts') && !f.endsWith('validators.ts'),
|
|
432
|
-
).length;
|
|
433
|
-
const indexFiles = Object.keys(files).filter((f) =>
|
|
434
|
-
f.endsWith('index.ts'),
|
|
435
|
-
).length;
|
|
436
|
-
|
|
437
|
-
logger.log(
|
|
438
|
-
` Generated ${endpointFiles} endpoint files + ${indexFiles} index files + validators.ts`,
|
|
439
|
-
);
|
|
440
|
-
|
|
441
|
-
// Return path to index file
|
|
442
|
-
return join(endpointsDir, 'index.ts');
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
private async generateAppFile(
|
|
446
|
-
outputDir: string,
|
|
447
|
-
context: BuildContext,
|
|
448
|
-
): Promise<string> {
|
|
449
|
-
// Use production generator if in production mode
|
|
450
|
-
if (context.production?.enabled) {
|
|
451
|
-
return this.generateProductionAppFile(outputDir, context);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
const appFileName = 'app.ts';
|
|
455
|
-
const appPath = join(outputDir, appFileName);
|
|
456
|
-
|
|
457
|
-
const relativeLoggerPath = relative(dirname(appPath), context.loggerPath);
|
|
458
|
-
|
|
459
|
-
const relativeEnvParserPath = relative(
|
|
460
|
-
dirname(appPath),
|
|
461
|
-
context.envParserPath,
|
|
462
|
-
);
|
|
463
|
-
|
|
464
|
-
// Generate telescope imports and setup if enabled
|
|
465
|
-
const telescopeEnabled = context.telescope?.enabled;
|
|
466
|
-
const telescopeWebSocketEnabled = context.telescope?.websocket;
|
|
467
|
-
const usesExternalTelescope = !!context.telescope?.telescopePath;
|
|
468
|
-
|
|
469
|
-
// Generate studio imports and setup if enabled
|
|
470
|
-
const studioEnabled = context.studio?.enabled;
|
|
471
|
-
const usesExternalStudio = !!context.studio?.studioPath;
|
|
472
|
-
|
|
473
|
-
// Generate imports based on whether telescope is external or inline
|
|
474
|
-
let telescopeImports = '';
|
|
475
|
-
if (telescopeEnabled) {
|
|
476
|
-
if (usesExternalTelescope) {
|
|
477
|
-
const relativeTelescopePath = relative(
|
|
478
|
-
dirname(appPath),
|
|
479
|
-
context.telescope?.telescopePath!,
|
|
480
|
-
);
|
|
481
|
-
telescopeImports = `import ${context.telescope?.telescopeImportPattern} from '${relativeTelescopePath}';
|
|
482
|
-
import { createMiddleware, createUI } from '@geekmidas/telescope/hono';`;
|
|
483
|
-
} else {
|
|
484
|
-
telescopeImports = `import { Telescope, InMemoryStorage } from '@geekmidas/telescope';
|
|
485
|
-
import { createMiddleware, createUI } from '@geekmidas/telescope/hono';`;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// Generate imports for studio
|
|
490
|
-
let studioImports = '';
|
|
491
|
-
if (studioEnabled) {
|
|
492
|
-
if (usesExternalStudio) {
|
|
493
|
-
const relativeStudioPath = relative(
|
|
494
|
-
dirname(appPath),
|
|
495
|
-
context.studio?.studioPath!,
|
|
496
|
-
);
|
|
497
|
-
studioImports = `import ${context.studio?.studioImportPattern} from '${relativeStudioPath}';
|
|
498
|
-
import { createStudioApp } from '@geekmidas/studio/server/hono';`;
|
|
499
|
-
} else {
|
|
500
|
-
studioImports = `// Studio requires a configured instance - use studio config path
|
|
501
|
-
// import { createStudioApp } from '@geekmidas/studio/server/hono';`;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
// Generate imports for server hooks
|
|
506
|
-
let hooksImports = '';
|
|
507
|
-
let beforeSetupCall = '';
|
|
508
|
-
let afterSetupCall = '';
|
|
509
|
-
if (context.hooks?.serverHooksPath) {
|
|
510
|
-
const relativeHooksPath = relative(
|
|
511
|
-
dirname(appPath),
|
|
512
|
-
context.hooks.serverHooksPath,
|
|
513
|
-
);
|
|
514
|
-
hooksImports = `import * as serverHooks from '${relativeHooksPath}';`;
|
|
515
|
-
beforeSetupCall = `
|
|
516
|
-
// Call beforeSetup hook if defined
|
|
517
|
-
if (typeof serverHooks.beforeSetup === 'function') {
|
|
518
|
-
await serverHooks.beforeSetup(honoApp, { envParser, logger });
|
|
519
|
-
}
|
|
520
|
-
`;
|
|
521
|
-
afterSetupCall = `
|
|
522
|
-
// Call afterSetup hook if defined
|
|
523
|
-
if (typeof serverHooks.afterSetup === 'function') {
|
|
524
|
-
await serverHooks.afterSetup(honoApp, { envParser, logger });
|
|
525
|
-
}
|
|
526
|
-
`;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
const telescopeWebSocketSetupCode = telescopeWebSocketEnabled
|
|
530
|
-
? `
|
|
531
|
-
// Setup WebSocket for real-time telescope updates
|
|
532
|
-
try {
|
|
533
|
-
const { createNodeWebSocket } = await import('@hono/node-ws');
|
|
534
|
-
const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app: honoApp });
|
|
535
|
-
// Add WebSocket route directly to main app (sub-app routes don't support WS upgrade)
|
|
536
|
-
honoApp.get('${context.telescope?.path}/ws', upgradeWebSocket(() => ({
|
|
537
|
-
onOpen: (_event: Event, ws: any) => {
|
|
538
|
-
telescope.addWsClient(ws);
|
|
539
|
-
},
|
|
540
|
-
onClose: (_event: Event, ws: any) => {
|
|
541
|
-
telescope.removeWsClient(ws);
|
|
542
|
-
},
|
|
543
|
-
onMessage: (event: MessageEvent, ws: any) => {
|
|
544
|
-
try {
|
|
545
|
-
const data = JSON.parse(event.data);
|
|
546
|
-
if (data.type === 'ping') {
|
|
547
|
-
ws.send(JSON.stringify({ type: 'pong' }));
|
|
548
|
-
}
|
|
549
|
-
} catch {
|
|
550
|
-
// Ignore invalid messages
|
|
551
|
-
}
|
|
552
|
-
},
|
|
553
|
-
})));
|
|
554
|
-
// Store injectWebSocket for server entry to call after serve()
|
|
555
|
-
(honoApp as any).__injectWebSocket = injectWebSocket;
|
|
556
|
-
logger.info('Telescope WebSocket enabled');
|
|
557
|
-
} catch (e) {
|
|
558
|
-
logger.warn({ error: e }, 'WebSocket support not available - install @hono/node-ws for real-time updates');
|
|
559
|
-
}
|
|
560
|
-
`
|
|
561
|
-
: '';
|
|
562
|
-
|
|
563
|
-
// Generate telescope setup - either use external instance or create inline
|
|
564
|
-
let telescopeSetup = '';
|
|
565
|
-
if (telescopeEnabled) {
|
|
566
|
-
if (usesExternalTelescope) {
|
|
567
|
-
// Use external telescope instance - no need to create one
|
|
568
|
-
telescopeSetup = `
|
|
569
|
-
${telescopeWebSocketSetupCode}
|
|
570
|
-
// Add telescope middleware (before endpoints to capture all requests)
|
|
571
|
-
honoApp.use('*', createMiddleware(telescope));
|
|
572
|
-
|
|
573
|
-
// Mount telescope UI
|
|
574
|
-
const telescopeUI = createUI(telescope);
|
|
575
|
-
honoApp.route('${context.telescope?.path}', telescopeUI);
|
|
576
|
-
`;
|
|
577
|
-
} else {
|
|
578
|
-
// Create inline telescope instance
|
|
579
|
-
telescopeSetup = `
|
|
580
|
-
// Setup Telescope for debugging/monitoring
|
|
581
|
-
const telescopeStorage = new InMemoryStorage({ maxEntries: ${context.telescope?.maxEntries} });
|
|
582
|
-
const telescope = new Telescope({
|
|
583
|
-
enabled: true,
|
|
584
|
-
path: '${context.telescope?.path}',
|
|
585
|
-
ignorePatterns: ${JSON.stringify(context.telescope?.ignore)},
|
|
586
|
-
recordBody: ${context.telescope?.recordBody},
|
|
587
|
-
storage: telescopeStorage,
|
|
588
|
-
});
|
|
589
|
-
${telescopeWebSocketSetupCode}
|
|
590
|
-
// Add telescope middleware (before endpoints to capture all requests)
|
|
591
|
-
honoApp.use('*', createMiddleware(telescope));
|
|
592
|
-
|
|
593
|
-
// Mount telescope UI
|
|
594
|
-
const telescopeUI = createUI(telescope);
|
|
595
|
-
honoApp.route('${context.telescope?.path}', telescopeUI);
|
|
596
|
-
`;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
// Generate studio setup - requires external instance
|
|
601
|
-
let studioSetup = '';
|
|
602
|
-
if (studioEnabled && usesExternalStudio) {
|
|
603
|
-
studioSetup = `
|
|
604
|
-
// Mount Studio data browser UI
|
|
605
|
-
const studioApp = createStudioApp(studio);
|
|
606
|
-
honoApp.route('${context.studio?.path}', studioApp);
|
|
607
|
-
`;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
const content = `/**
|
|
611
|
-
* Generated server application
|
|
612
|
-
*
|
|
613
|
-
* ⚠️ WARNING: This is for LOCAL DEVELOPMENT ONLY
|
|
614
|
-
* The subscriber polling mechanism is not production-ready.
|
|
615
|
-
* For production, use AWS Lambda with SQS/SNS event sources.
|
|
616
|
-
*/
|
|
617
|
-
import { Hono } from 'hono';
|
|
618
|
-
import type { Hono as HonoType } from 'hono';
|
|
619
|
-
import { setupEndpoints } from './endpoints.js';
|
|
620
|
-
import { setupSubscribers } from './subscribers.js';
|
|
621
|
-
import { setupQueues } from './queues.js';
|
|
622
|
-
import ${context.envParserImportPattern} from '${relativeEnvParserPath}';
|
|
623
|
-
import ${context.loggerImportPattern} from '${relativeLoggerPath}';
|
|
624
|
-
${telescopeImports}
|
|
625
|
-
${studioImports}
|
|
626
|
-
${hooksImports}
|
|
627
|
-
|
|
628
|
-
export interface ServerApp {
|
|
629
|
-
app: HonoType;
|
|
630
|
-
start: (options?: {
|
|
631
|
-
port?: number;
|
|
632
|
-
serve: (app: HonoType, port: number) => void | Promise<void>;
|
|
633
|
-
}) => Promise<void>;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Create and configure the Hono application
|
|
638
|
-
*
|
|
639
|
-
* @param app - Optional Hono app instance to configure (creates new one if not provided)
|
|
640
|
-
* @param enableOpenApi - Enable OpenAPI documentation (default: true)
|
|
641
|
-
* @returns Server app with configured Hono app and start function
|
|
642
|
-
*
|
|
643
|
-
* @example
|
|
644
|
-
* // With Bun
|
|
645
|
-
* import { createApp } from './.gkm/server/app.js';
|
|
646
|
-
*
|
|
647
|
-
* const { app, start } = await createApp();
|
|
648
|
-
*
|
|
649
|
-
* await start({
|
|
650
|
-
* port: 3000,
|
|
651
|
-
* serve: (app, port) => {
|
|
652
|
-
* Bun.serve({ port, fetch: app.fetch });
|
|
653
|
-
* }
|
|
654
|
-
* });
|
|
655
|
-
*
|
|
656
|
-
* @example
|
|
657
|
-
* // With Node.js (using @hono/node-server)
|
|
658
|
-
* import { serve } from '@hono/node-server';
|
|
659
|
-
* import { createApp } from './.gkm/server/app.js';
|
|
660
|
-
*
|
|
661
|
-
* const { app, start } = await createApp();
|
|
662
|
-
*
|
|
663
|
-
* await start({
|
|
664
|
-
* port: 3000,
|
|
665
|
-
* serve: (app, port) => {
|
|
666
|
-
* serve({ fetch: app.fetch, port });
|
|
667
|
-
* }
|
|
668
|
-
* });
|
|
669
|
-
*/
|
|
670
|
-
export async function createApp(app?: HonoType, enableOpenApi: boolean = true): Promise<ServerApp> {
|
|
671
|
-
const honoApp = app || new Hono();
|
|
672
|
-
${telescopeSetup}${beforeSetupCall}${studioSetup}
|
|
673
|
-
// Setup HTTP endpoints
|
|
674
|
-
await setupEndpoints(honoApp, envParser, logger, enableOpenApi);
|
|
675
|
-
${afterSetupCall}
|
|
676
|
-
|
|
677
|
-
return {
|
|
678
|
-
app: honoApp,
|
|
679
|
-
async start(options) {
|
|
680
|
-
if (!options?.serve) {
|
|
681
|
-
throw new Error(
|
|
682
|
-
'serve function is required. Pass a serve function for your runtime:\\n' +
|
|
683
|
-
' - Bun: (app, port) => Bun.serve({ port, fetch: app.fetch })\\n' +
|
|
684
|
-
' - Node: (app, port) => serve({ fetch: app.fetch, port })'
|
|
685
|
-
);
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
const port = options.port ?? 3000;
|
|
689
|
-
|
|
690
|
-
// Start subscribers in background (non-blocking, local development only)
|
|
691
|
-
await setupSubscribers(envParser, logger).catch((error) => {
|
|
692
|
-
logger.error({ error }, 'Failed to start subscribers');
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
// Start queue workers in background (non-blocking, local development only)
|
|
696
|
-
await setupQueues(envParser, logger).catch((error) => {
|
|
697
|
-
logger.error({ error }, 'Failed to start queue workers');
|
|
698
|
-
});
|
|
699
|
-
|
|
700
|
-
logger.info({ port }, 'Starting server');
|
|
701
|
-
|
|
702
|
-
// Start HTTP server using provided serve function
|
|
703
|
-
await options.serve(honoApp, port);
|
|
704
|
-
|
|
705
|
-
logger.info({ port }, 'Server started');
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
// Default export for convenience
|
|
711
|
-
export default createApp;
|
|
712
|
-
`;
|
|
713
|
-
|
|
714
|
-
await writeFile(appPath, content);
|
|
715
|
-
|
|
716
|
-
return appPath;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
private generateAWSApiGatewayV1Handler(
|
|
720
|
-
importPath: string,
|
|
721
|
-
exportName: string,
|
|
722
|
-
envParserPath: string,
|
|
723
|
-
envParserImportPattern: string,
|
|
724
|
-
): string {
|
|
725
|
-
return `import { AmazonApiGatewayV1Endpoint } from '@geekmidas/constructs/aws';
|
|
726
|
-
import { ${exportName} } from '${importPath}';
|
|
727
|
-
import ${envParserImportPattern} from '${envParserPath}';
|
|
728
|
-
|
|
729
|
-
const adapter = new AmazonApiGatewayV1Endpoint(envParser, ${exportName});
|
|
730
|
-
|
|
731
|
-
export const handler = adapter.handler;
|
|
732
|
-
`;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
private generateAWSApiGatewayV2Handler(
|
|
736
|
-
importPath: string,
|
|
737
|
-
exportName: string,
|
|
738
|
-
envParserPath: string,
|
|
739
|
-
envParserImportPattern: string,
|
|
740
|
-
): string {
|
|
741
|
-
return `import { AmazonApiGatewayV2Endpoint } from '@geekmidas/constructs/aws';
|
|
742
|
-
import { ${exportName} } from '${importPath}';
|
|
743
|
-
import ${envParserImportPattern} from '${envParserPath}';
|
|
744
|
-
|
|
745
|
-
const adapter = new AmazonApiGatewayV2Endpoint(envParser, ${exportName});
|
|
746
|
-
|
|
747
|
-
export const handler = adapter.handler;
|
|
748
|
-
`;
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
private generateServerHandler(
|
|
752
|
-
importPath: string,
|
|
753
|
-
exportName: string,
|
|
754
|
-
): string {
|
|
755
|
-
return `import { ${exportName} } from '${importPath}';
|
|
756
|
-
|
|
757
|
-
// Server handler - implement based on your server framework
|
|
758
|
-
export const handler = ${exportName};
|
|
759
|
-
`;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
/**
|
|
763
|
-
* Generate a production-optimized app.ts file
|
|
764
|
-
* No dev tools (Telescope, Studio, WebSocket), includes health checks and graceful shutdown
|
|
765
|
-
*/
|
|
766
|
-
private async generateProductionAppFile(
|
|
767
|
-
outputDir: string,
|
|
768
|
-
context: BuildContext,
|
|
769
|
-
): Promise<string> {
|
|
770
|
-
const appFileName = 'app.ts';
|
|
771
|
-
const appPath = join(outputDir, appFileName);
|
|
772
|
-
|
|
773
|
-
const relativeLoggerPath = relative(dirname(appPath), context.loggerPath);
|
|
774
|
-
const relativeEnvParserPath = relative(
|
|
775
|
-
dirname(appPath),
|
|
776
|
-
context.envParserPath,
|
|
777
|
-
);
|
|
778
|
-
|
|
779
|
-
const production = context.production!;
|
|
780
|
-
const healthCheckPath = production.healthCheck;
|
|
781
|
-
const enableGracefulShutdown = production.gracefulShutdown;
|
|
782
|
-
const enableOpenApi = production.openapi;
|
|
783
|
-
const includeSubscribers = production.subscribers === 'include';
|
|
784
|
-
|
|
785
|
-
// Generate imports for server hooks
|
|
786
|
-
let hooksImports = '';
|
|
787
|
-
let beforeSetupCall = '';
|
|
788
|
-
let afterSetupCall = '';
|
|
789
|
-
if (context.hooks?.serverHooksPath) {
|
|
790
|
-
const relativeHooksPath = relative(
|
|
791
|
-
dirname(appPath),
|
|
792
|
-
context.hooks.serverHooksPath,
|
|
793
|
-
);
|
|
794
|
-
hooksImports = `import * as serverHooks from '${relativeHooksPath}';`;
|
|
795
|
-
beforeSetupCall = `
|
|
796
|
-
// Call beforeSetup hook if defined
|
|
797
|
-
if (typeof serverHooks.beforeSetup === 'function') {
|
|
798
|
-
await serverHooks.beforeSetup(honoApp, { envParser, logger });
|
|
799
|
-
}
|
|
800
|
-
`;
|
|
801
|
-
afterSetupCall = `
|
|
802
|
-
// Call afterSetup hook if defined
|
|
803
|
-
if (typeof serverHooks.afterSetup === 'function') {
|
|
804
|
-
await serverHooks.afterSetup(honoApp, { envParser, logger });
|
|
805
|
-
}
|
|
806
|
-
`;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
// Subscriber + queue setup code (background workers share the same flag)
|
|
810
|
-
const subscriberSetup = includeSubscribers
|
|
811
|
-
? `
|
|
812
|
-
// Start subscribers in background
|
|
813
|
-
await setupSubscribers(envParser, logger).catch((error) => {
|
|
814
|
-
logger.error({ error }, 'Failed to start subscribers');
|
|
815
|
-
});
|
|
816
|
-
|
|
817
|
-
// Start queue workers in background
|
|
818
|
-
await setupQueues(envParser, logger).catch((error) => {
|
|
819
|
-
logger.error({ error }, 'Failed to start queue workers');
|
|
820
|
-
});
|
|
821
|
-
`
|
|
822
|
-
: '';
|
|
823
|
-
|
|
824
|
-
const subscriberImport = includeSubscribers
|
|
825
|
-
? `import { setupSubscribers } from './subscribers.js';
|
|
826
|
-
import { setupQueues } from './queues.js';`
|
|
827
|
-
: '';
|
|
828
|
-
|
|
829
|
-
// Graceful shutdown code
|
|
830
|
-
const gracefulShutdownCode = enableGracefulShutdown
|
|
831
|
-
? `
|
|
832
|
-
// Graceful shutdown handling
|
|
833
|
-
let isShuttingDown = false;
|
|
834
|
-
|
|
835
|
-
const shutdown = async () => {
|
|
836
|
-
if (isShuttingDown) return;
|
|
837
|
-
isShuttingDown = true;
|
|
838
|
-
logger.info('Graceful shutdown initiated');
|
|
839
|
-
// Allow in-flight requests to complete (30s timeout)
|
|
840
|
-
setTimeout(() => process.exit(0), 30000);
|
|
841
|
-
};
|
|
842
|
-
|
|
843
|
-
process.on('SIGTERM', shutdown);
|
|
844
|
-
process.on('SIGINT', shutdown);
|
|
845
|
-
`
|
|
846
|
-
: '';
|
|
847
|
-
|
|
848
|
-
// Use endpoints/index.js for optimized builds, endpoints.js otherwise
|
|
849
|
-
const endpointsImportPath = production.optimizedHandlers
|
|
850
|
-
? './endpoints/index.js'
|
|
851
|
-
: './endpoints.js';
|
|
852
|
-
|
|
853
|
-
const content = `/**
|
|
854
|
-
* Generated production server application
|
|
855
|
-
*
|
|
856
|
-
* This is a production-optimized build without dev tools.
|
|
857
|
-
* - No Telescope debugging dashboard
|
|
858
|
-
* - No Studio database browser
|
|
859
|
-
* - No WebSocket updates
|
|
860
|
-
* - Includes health checks and graceful shutdown
|
|
861
|
-
*/
|
|
862
|
-
import { Hono } from 'hono';
|
|
863
|
-
import type { Hono as HonoType } from 'hono';
|
|
864
|
-
import { setupEndpoints } from '${endpointsImportPath}';
|
|
865
|
-
${subscriberImport}
|
|
866
|
-
import ${context.envParserImportPattern} from '${relativeEnvParserPath}';
|
|
867
|
-
import ${context.loggerImportPattern} from '${relativeLoggerPath}';
|
|
868
|
-
${hooksImports}
|
|
869
|
-
|
|
870
|
-
export interface ServerApp {
|
|
871
|
-
app: HonoType;
|
|
872
|
-
start: (options?: {
|
|
873
|
-
port?: number;
|
|
874
|
-
serve: (app: HonoType, port: number) => void | Promise<void>;
|
|
875
|
-
}) => Promise<void>;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
* Create and configure the production Hono application
|
|
880
|
-
*/
|
|
881
|
-
export async function createApp(app?: HonoType): Promise<ServerApp> {
|
|
882
|
-
const honoApp = app || new Hono();
|
|
883
|
-
|
|
884
|
-
// Health check endpoint (always first)
|
|
885
|
-
honoApp.get('${healthCheckPath}', (c) => c.json({ status: 'ok', timestamp: Date.now() }));
|
|
886
|
-
honoApp.get('/ready', (c) => c.json({ ready: true }));
|
|
887
|
-
${beforeSetupCall}
|
|
888
|
-
// Setup HTTP endpoints (OpenAPI: ${enableOpenApi})
|
|
889
|
-
await setupEndpoints(honoApp, envParser, logger, ${enableOpenApi});
|
|
890
|
-
${afterSetupCall}
|
|
891
|
-
return {
|
|
892
|
-
app: honoApp,
|
|
893
|
-
async start(options) {
|
|
894
|
-
if (!options?.serve) {
|
|
895
|
-
throw new Error(
|
|
896
|
-
'serve function is required. Pass a serve function for your runtime:\\n' +
|
|
897
|
-
' - Bun: (app, port) => Bun.serve({ port, fetch: app.fetch })\\n' +
|
|
898
|
-
' - Node: (app, port) => serve({ fetch: app.fetch, port })'
|
|
899
|
-
);
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
const port = options.port ?? Number(process.env.PORT) ?? 3000;
|
|
903
|
-
${gracefulShutdownCode}${subscriberSetup}
|
|
904
|
-
logger.info({ port }, 'Starting production server');
|
|
905
|
-
|
|
906
|
-
// Start HTTP server using provided serve function
|
|
907
|
-
await options.serve(honoApp, port);
|
|
908
|
-
|
|
909
|
-
logger.info({ port }, 'Production server started');
|
|
910
|
-
}
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
// Default export for convenience
|
|
915
|
-
export default createApp;
|
|
916
|
-
`;
|
|
917
|
-
|
|
918
|
-
await writeFile(appPath, content);
|
|
919
|
-
|
|
920
|
-
// Also generate the production server entry point
|
|
921
|
-
await this.generateProductionServerEntry(outputDir);
|
|
922
|
-
|
|
923
|
-
return appPath;
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
/**
|
|
927
|
-
* Generate production server.ts entry point
|
|
928
|
-
*/
|
|
929
|
-
private async generateProductionServerEntry(
|
|
930
|
-
outputDir: string,
|
|
931
|
-
): Promise<void> {
|
|
932
|
-
const serverPath = join(outputDir, 'server.ts');
|
|
933
|
-
|
|
934
|
-
const content = `#!/usr/bin/env node
|
|
935
|
-
/**
|
|
936
|
-
* Production server entry point
|
|
937
|
-
* Generated by 'gkm build --provider server --production'
|
|
938
|
-
*/
|
|
939
|
-
import { serve } from '@hono/node-server';
|
|
940
|
-
import { createApp } from './app.js';
|
|
941
|
-
|
|
942
|
-
const port = Number(process.env.PORT) || 3000;
|
|
943
|
-
|
|
944
|
-
const { start } = await createApp();
|
|
945
|
-
|
|
946
|
-
await start({
|
|
947
|
-
port,
|
|
948
|
-
serve: (app, port) => { serve({ fetch: app.fetch, port }); },
|
|
949
|
-
});
|
|
950
|
-
`;
|
|
951
|
-
|
|
952
|
-
await writeFile(serverPath, content);
|
|
953
|
-
}
|
|
954
|
-
}
|