Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function bootstrapWorkerInternal(userConfig: Partial): Promise {
const config = disableSynchronize(await preBootstrapConfig(userConfig));
if (!config.workerOptions.runInMainProcess && (config.logger as any).setDefaultContext) {
(config.logger as any).setDefaultContext('Vendure Worker');
}
Logger.useLogger(config.logger);
Logger.info(`Bootstrapping Vendure Worker (pid: ${process.pid})...`);
const workerModule = await import('./worker/worker.module');
DefaultLogger.hideNestBoostrapLogs();
const workerApp = await NestFactory.createMicroservice(workerModule.WorkerModule, {
transport: config.workerOptions.transport,
logger: new Logger(),
options: config.workerOptions.options,
});
DefaultLogger.restoreOriginalLogLevel();
workerApp.useLogger(new Logger());
workerApp.enableShutdownHooks();
// A work-around to correctly handle errors when attempting to start the
// microservice server listening.
// See https://github.com/nestjs/nest/issues/2777
// TODO: Remove if & when the above issue is resolved.
await new Promise((resolve, reject) => {
(workerApp as any).server.server.on('error', (e: any) => {
reject(e);
});
private async bootstrapForTesting(
userConfig: Partial,
): Promise<[INestApplication, INestMicroservice | undefined]> {
const config = await preBootstrapConfig(userConfig);
Logger.useLogger(config.logger);
const appModule = await import('@vendure/core/dist/app.module');
try {
DefaultLogger.hideNestBoostrapLogs();
const app = await NestFactory.create(appModule.AppModule, { cors: config.cors, logger: false });
let worker: INestMicroservice | undefined;
await app.listen(config.port);
if (config.workerOptions.runInMainProcess) {
const workerModule = await import('@vendure/core/dist/worker/worker.module');
worker = await NestFactory.createMicroservice(workerModule.WorkerModule, {
transport: config.workerOptions.transport,
logger: new Logger(),
options: config.workerOptions.options,
});
await worker.listenAsync();
}
DefaultLogger.restoreOriginalLogLevel();
return [app, worker];
} catch (e) {
console.log(e);
throw e;
}
}
}
async function bootstrap() {
const app = await NestFactory.createMicroservice(AppModule, OPTIONS);
app.listen(() => console.log('Database Microservice is listening with HMR enabled'));
if (module.hot) {
module.hot.accept();
module.hot.dispose(() => app.close());
}
}
bootstrap();
async function bootstrap() {
const app = await NestFactory.createMicroservice(ApplicationModule, OPTIONS);
app.listen(() => console.log('Users Microservice is listening'));
}
bootstrap();
async function bootstrap() {
const app = await NestFactory.createMicroservice(AppModule, OPTIONS);
app.listen(() => console.log('Database Microservice is listening'));
}
bootstrap();
async function bootstrapRpc() {
const rpcApp = await NestFactory.createMicroservice(
AppModule,
microserviceServerConfig('nestjs_book')
);
rpcApp.useGlobalFilters(new RpcValidationFilter());
await rpcApp.listenAsync();
}
async function bootstrap() {
const app = await NestFactory.createMicroservice(AppModule, {
transport: Transport.REDIS,
options: {
retryAttempts: 5,
retryDelay: 1000,
url: `redis://${REDIS_HOST}:${REDIS_PORT}`
}
});
await app.listenAsync();
}
bootstrap();
async function bootstrap() {
const app = await NestFactory.createMicroservice(CmsModule, {
transport: Transport.GRPC,
options: {
url: 'localhost:50052',
package: 'nt_module_cms',
protoPath: join(__dirname, 'nt_module_cms.proto'),
loader: {
arrays: true
}
}
});
await app.listenAsync();
}
async function bootstrapMicroservice(tcpPort: number) {
const tcpApp = await NestFactory.createMicroservice(ApplicationModule, {
transport: Transport.TCP,
options: {
host: '0.0.0.0',
port: tcpPort,
},
});
await tcpApp.listenAsync();
}