From 415bc164159530dde4d134df47f332a205753fa2 Mon Sep 17 00:00:00 2001 From: Dhruv Patel Date: Thu, 14 Dec 2023 17:41:37 -0600 Subject: [PATCH 1/2] fix: Properly load routes for apps using js entrypoint --- src/bootstrap.ts | 1 + src/express-app/app.ts | 5 +++-- src/types.ts | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bootstrap.ts b/src/bootstrap.ts index a63bbdd..98090cf 100644 --- a/src/bootstrap.ts +++ b/src/bootstrap.ts @@ -126,6 +126,7 @@ export async function bootstrap< rootDirectory, service: impl.default || impl.service, codepath, + useJsEntrypoint, }; const { startApp, listen } = await import('./express-app/app.js'); const app = await startApp(opts); diff --git a/src/express-app/app.ts b/src/express-app/app.ts index a5b5b23..884f5fc 100644 --- a/src/express-app/app.ts +++ b/src/express-app/app.ts @@ -87,7 +87,7 @@ export async function startApp< RLocals extends RequestLocals = RequestLocals, >(startOptions: ServiceStartOptions): Promise> { const { - service, rootDirectory, codepath = 'build', name, + service, rootDirectory, codepath = 'build', name, useJsEntrypoint, } = startOptions; const shouldPrettyPrint = isDev() && !process.env.NO_PRETTY_LOGS; const destination = pino.destination({ @@ -258,10 +258,11 @@ export async function startApp< } if (routing?.routes) { + const routeFileExtension = useJsEntrypoint ? 'js' : 'ts'; await loadRoutes( app, path.resolve(rootDirectory, codepath, config.get('routing:routes')), - codepath === 'build' ? '**/*.js' : '**/*.ts', + codepath === 'build' ? '**/*.js' : `**/*.${routeFileExtension}`, ); } if (routing?.openapi) { diff --git a/src/types.ts b/src/types.ts index 8236b3f..f28e82d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -96,6 +96,8 @@ export interface ServiceStartOptions< // locals: { stuff } as Partial locals?: Partial; + useJsEntrypoint?: boolean; + // And finally, the function that creates the service instance service: () => Service; } From e23efa827f9f19885e7f31644fc4a25bae1cf82c Mon Sep 17 00:00:00 2001 From: Dhruv Patel Date: Thu, 14 Dec 2023 17:46:27 -0600 Subject: [PATCH 2/2] 12.20.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6abe6fb..ba55a6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gasbuddy/service", - "version": "12.20.0", + "version": "12.20.1", "description": "An opinionated framework for building configuration driven services - web, api, or job. Uses swagger, pino logging, express, confit, Typescript and Jest.", "main": "build/index.js", "scripts": {