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 bootstrap() {
// 亦可以读取配置文件
let apiConfig = new ApiConfig("Javen", "wx614c453e0d1dcd12", "19a02e4927d346484fc70327970457f9", false, "xxxx");
// 支持多公众号
ApiConfigKit.putApiConfig(apiConfig);
ApiConfigKit.setCurrentAppId();
// 开启开发模式,方便调试
ApiConfigKit.devMode = true;
const app = await NestFactory.create(
AppModule,
new FastifyAdapter(),
);
console.log("__dirname:", __dirname);
app.useStaticAssets({
root: join(__dirname, 'public'),
prefix: '/public/',
});
app.setViewEngine({
engine: {
handlebars: require('handlebars'),
},
templates: join(__dirname, 'views'),
});
await app.listen(8888);
}
bootstrap();
async function bootstrap() {
const nextjs = Nextjs({ dev });
await nextjs.prepare();
// Nestjs
const app = await NestFactory.create(
AppModule,
new FastifyAdapter(await initFastify(nextjs)),
{
logger: false
}
);
await initScripts(app);
await initSwagger(app);
app.enableCors();
app.useGlobalFilters(new ExceptionsFilter());
await mq.init();
await wf.init();
io.server.listen(app.getHttpServer());
await io.init();
async function bootstrap() {
try {
const app = await NestFactory.create(
AppServerModule,
new FastifyAdapter(),
{
logger: new MyLogger()
}
);
configure(app);
await app.listen(PORT, HOST);
MyLogger.log(`Application stated on ${HOST}:${PORT}.`, 'Main');
} catch (err) {
MyLogger.error(err.message, err.stack, 'Main');
process.exit(0);
}
}
async function bootstrap() {
const app = await NestFactory.create(
ApplicationModule,
new FastifyAdapter(),
);
app.useStaticAssets({
root: join(__dirname, '..', 'public'),
prefix: '/public/',
});
app.setViewEngine({
engine: {
handlebars: require('handlebars'),
},
templates: join(__dirname, '..', 'views'),
});
await app.listen(3000);
}
bootstrap();
async function bootstrap() {
const app = await NestFactory.create(
AppModule,
new FastifyAdapter(),
);
app.enableCors({
credentials: true,
preflightContinue: true,
});
app.enableShutdownHooks();
app.use(bloodTearsMiddleware);
await app.listenAsync(
parseInt(process.env.PORT, 10) ||
parseInt(config.services?.notification?.port, 10) ||
9400,
);
}
bootstrap();
export async function bootstrapModule(
options: TerminusModuleAsyncOptions,
useDb: boolean = false,
useMongoose: boolean = false,
useFastify?: boolean,
tcpPort?: number,
): Promise<[INestApplication, number]> {
const app = await NestFactory.create(
ApplicationModule.forRoot(options, useDb, useMongoose),
useFastify ? new FastifyAdapter() : new ExpressAdapter(),
);
if (tcpPort) {
await bootstrapMicroservice(tcpPort);
}
const port = await portfinder.getPortPromise({
port: 3000,
stopPort: 8888,
});
await app.listen(port, '0.0.0.0');
return [app, port];
}
async function bootstrap() {
const app = await NestFactory.create(
AppModule,
new FastifyAdapter(),
);
app.useGlobalPipes(new ValidationPipe());
await app.listen(3000);
}
bootstrap();