feat: add nestjs api and worker skeletons
This commit is contained in:
20
backend/apps/worker/src/main.ts
Normal file
20
backend/apps/worker/src/main.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { INestApplicationContext, Type } from '@nestjs/common';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { WorkerModule } from './worker.module';
|
||||
|
||||
type ContextFactory = (
|
||||
module: Type<unknown>,
|
||||
) => Promise<INestApplicationContext>;
|
||||
|
||||
export async function bootstrapWorker(
|
||||
createContext: ContextFactory = (module) =>
|
||||
NestFactory.createApplicationContext(module),
|
||||
): Promise<INestApplicationContext> {
|
||||
const app = await createContext(WorkerModule);
|
||||
app.enableShutdownHooks();
|
||||
return app;
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
void bootstrapWorker();
|
||||
}
|
||||
Reference in New Issue
Block a user