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() {
const server = express();
const app = await NestFactory.create(AppModule, new ExpressAdapter(server));
app.use(helmet());
app.use(cookieParser());
app.enableCors(corsOptions);
app.useGlobalPipes(
new ValidationPipe({
transform: true,
})
);
// tslint:disable-next-line: no-unsafe-any
app.useWebSocketAdapter(new WsAdapter(app));
app.use('/voyager', voyagerMiddleware({ endpointUrl: '/graphql' }));
function bootstrapServer(): Promise {
const expressApp = express();
const adapter = new ExpressAdapter(expressApp);
return NestFactory.create(AppModule, adapter)
.then(app => app.enableCors())
.then(app => app.init())
.then(() => serverless.createServer(expressApp));
}
function bootstrapServer(): Promise {
const expressApp = express();
const adapter = new ExpressAdapter(expressApp);
return NestFactory.create(AppModule, adapter)
.then(app => app.enableCors())
.then(app => app.init())
.then(() => serverless.createServer(expressApp));
}
async function bootstrapServer(): Promise {
if (!cachedServer) {
try {
const expressApp = require('express')();
const adapter = new ExpressAdapter(expressApp);
const nestApp = await NestFactory.create(KeycloakModule, adapter);
nestApp.use(eventContext());
await nestApp.init();
cachedServer = createServer(expressApp, undefined, binaryMimeTypes);
} catch (error) {
return Promise.reject(error);
}
}
return Promise.resolve(cachedServer);
}
async function bootstrapServer(): Promise {
if (!cachedServer) {
const expressApp = express();
const nestApp = await NestFactory.create(AppModule, new ExpressAdapter(expressApp))
nestApp.use(eventContext());
await nestApp.init();
cachedServer = createServer(expressApp, undefined, binaryMimeTypes);
}
return cachedServer;
}
export async function bootstrap(port: number): Promise {
const app = await NestFactory.create(AppModule, new ExpressAdapter());
await app.listen(port);
Logger.log(`Application served at http://localhost:${port}`);
return app;
}
private async createNestApp() {
const nestSettings = { logger: this.logger };
if (!this.server) {
this.server = express();
}
this.app = await NestFactory.create(
AppModule.forRoot(this.settings),
new ExpressAdapter(this.server),
nestSettings
);
this.app.useWebSocketAdapter(new IoAdapter(this.app.getHttpServer()));
}
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];
}