45 lines
No EOL
1.5 KiB
TypeScript
45 lines
No EOL
1.5 KiB
TypeScript
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('1.0.0')
|
|
.build();
|
|
const swaggerDocument = SwaggerModule.createDocument(app, swaggerOptions);
|
|
SwaggerModule.setup('/api-docs', app, swaggerDocument);
|
|
await app.listen(parseInt(env.PORT), '0.0.0.0');
|
|
}
|
|
bootstrap(); |