2020-04-29 09:33:39 +00:00
|
|
|
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
|
|
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
|
|
|
|
import { ApplicationModule } from './app/app.module';
|
|
|
|
import { NestFactory } from '@nestjs/core';
|
|
|
|
import { join } from 'path';
|
|
|
|
|
|
|
|
const env = process.env;
|
|
|
|
const __webapp = join(__dirname, '..', '..', 'webapp');
|
|
|
|
|
|
|
|
|
|
|
|
async function bootstrap(): Promise<void> {
|
|
|
|
const app = await NestFactory.create<NestFastifyApplication>(
|
|
|
|
ApplicationModule,
|
|
|
|
new FastifyAdapter({ logger: false }), // Set to true to activate the built in logger
|
|
|
|
);
|
|
|
|
|
|
|
|
app.useStaticAssets({
|
|
|
|
root: join(__webapp, 'assets'),
|
|
|
|
prefix: '/assets/',
|
|
|
|
});
|
|
|
|
app.setViewEngine({
|
|
|
|
engine: {
|
|
|
|
handlebars: require('handlebars'),
|
|
|
|
},
|
|
|
|
templates: join(__webapp, 'src', 'views'),
|
|
|
|
layout: join('layouts', 'main.hbs'),
|
|
|
|
options: {
|
|
|
|
partials: {
|
|
|
|
'head': join('partials', 'head.hbs'),
|
|
|
|
'footer': join('partials', 'footer.hbs'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const swaggerOptions = new DocumentBuilder()
|
|
|
|
.setTitle('Cliffbreak TeamSpeak API')
|
|
|
|
.setDescription('This is the official Cliffbreak TeamSpeak API!')
|
|
|
|
.addBearerAuth()
|
|
|
|
.setVersion(require('./../package.json').version)
|
|
|
|
.build();
|
|
|
|
const swaggerDocument = SwaggerModule.createDocument(app, swaggerOptions);
|
|
|
|
SwaggerModule.setup('/api-docs', app, swaggerDocument);
|
2020-09-21 12:45:45 +00:00
|
|
|
await app.listen(parseInt(env.PORT), '0.0.0.0');
|
2020-04-29 09:33:39 +00:00
|
|
|
}
|
|
|
|
bootstrap();
|