Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Init swagger
*/
let documentBuilder = new DocumentBuilder()
.setTitle(config.project.package.name)
.setDescription(config.project.package.description)
.setContactEmail(config.project.package.author.email)
.setExternalDoc('Project on Github', config.project.package.homepage)
.setLicense(config.project.package.license, '')
.setVersion(config.project.package.version)
.addBearerAuth('Authorization', 'header');
documentBuilder = documentBuilder.setSchemes(
config.env.protocol === 'https' ? 'https' : 'http',
config.env.protocol === 'https' ? 'http' : 'https'
);
SwaggerModule.setup('/swagger', app, SwaggerModule.createDocument(app, documentBuilder.build()));
/**
* Start nest application
*/
await app.listen(config.env.port);
/* hmr
if (module.hot) {
module.hot.accept();
module.hot.dispose(() => app.close());
}
*/
}
bootstrap();
'Too many accounts created from this IP, please try again after an hour',
});
app.use('/auth/signup', signupLimiter);
// Swagger API Documentation
const options = new DocumentBuilder()
.setTitle('NestJS Hackathon Starter by @ahmetuysal')
.setDescription('NestJS Hackathon Starter API description')
.setVersion('1.0')
.addTag('auth')
.addTag('users')
// You can add new tags for your controllers here
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
await app.listen(3000);
}
bootstrap();
async function initSwagger(app) {
const options = new DocumentBuilder()
.setTitle('Nestify')
.setDescription('The Nestify API Documents')
.setVersion('0.0.1')
.addTag('Nestify')
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('docs', app, document);
}
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
credentials: true,
preflightContinue: true,
});
app.enableShutdownHooks();
app.use(bloodTearsMiddleware);
AppUtils.killAppWithGrace(app);
authSetup(app);
const document = SwaggerModule.createDocument(app, setupSwagger());
SwaggerModule.setup('api', app, document);
await app.listenAsync(
parseInt(process.env.PORT, 10) ||
parseInt(config.services?.tenant?.port, 10) ||
9200,
);
await setupGrpc(app, 'tenant', 'tenant.proto', config.services?.tenant?.grpcPort || 7200);
}
bootstrap();
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const options = new DocumentBuilder()
.setTitle('Cats example')
.setDescription('The cats API description')
.setVersion('1.0')
.addTag('cats')
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
await app.listen(3000);
}
bootstrap();
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
const options = new DocumentBuilder()
.setTitle('Todos example')
.setDescription('The Todos API description')
.setVersion('1.0')
.addTag('todos')
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
await app.listen(3000);
}
bootstrap();
credentials: true,
exposedHeaders: 'Authorization',
allowedHeaders: 'authorization, content-type',
});
if (configModule.isDev) {
const options = new DocumentBuilder()
.setTitle(configModule.swaggerConfig.swaggerTitle)
.setDescription(configModule.swaggerConfig.swaggerDescription)
.setVersion(configModule.swaggerConfig.swaggerVersion)
.setHost(configModule.host + ':' + configModule.port)
.setBasePath(configModule.swaggerConfig.swaggerBasepath)
.addBearerAuth('Authorization', 'header')
.build();
const swaggerDoc = SwaggerModule.createDocument(app, options);
SwaggerModule.setup((configModule.globalPrefix || '') + '/api', app, swaggerDoc);
}
await app.listen(configModule.port);
}
bootstrap();
function setupSwagger(app) {
const options = new DocumentBuilder()
.setTitle(`NestJS Starter-Kit API`)
.setDescription(``)
.setVersion(`1.0`)
.setBasePath(`/api`)
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup(`api/docs`, app, document);
}
logger: LogService,
});
application.use(express.static(process.cwd() + "/public/"));
application.useGlobalPipes(new ValidationPipe());
if (swaggerConfiguration.enable) {
const options = new DocumentBuilder()
.setTitle("Notadd")
.setDescription("API document for Notadd.")
.setVersion("2.0")
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(application, options);
SwaggerModule.setup(`/${swaggerConfiguration.endpoint}`, application, document);
}
const callback = () => {
if (graphqlConfiguration.ide.enable) {
this.logger.log(`Graphql IDE Server on: ${address}/graphiql`);
}
if (swaggerConfiguration.enable) {
this.logger.log(`Swagger Server on: ${address}/${swaggerConfiguration.endpoint}`);
}
this.logger.log(`Server on: ${address}`);
};
index = process.argv.indexOf("--host");
if (index > -1) {
await application.listen(port, process.argv[ index + 1 ], callback);
} else if (serverConfiguration.http.host && serverConfiguration.http.host !== "*") {