cupidgpg/src/main.ts

33 lines
813 B
TypeScript
Raw Normal View History

import type { NestFastifyApplication } from '@nestjs/platform-fastify'
import { FastifyAdapter } from '@nestjs/platform-fastify'
2024-07-27 13:27:38 +02:00
import { NestFactory } from '@nestjs/core'
import handlebars from 'hbs'
2024-07-27 12:55:13 +02:00
2024-07-27 13:27:38 +02:00
import { join } from 'path'
2024-07-27 12:55:13 +02:00
2024-07-27 13:27:38 +02:00
import { AppModule } from './app.module.js'
2024-07-27 12:55:13 +02:00
async function bootstrap(port: string | number) {
2024-07-27 13:27:38 +02:00
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter()
)
2024-07-27 12:55:13 +02:00
2024-07-27 13:27:38 +02:00
const root = import.meta.dirname
2024-07-27 12:55:13 +02:00
2024-07-27 13:27:38 +02:00
app.useStaticAssets({
root: join(root, '..', 'public'),
prefix: '/public/',
})
2024-07-27 12:55:13 +02:00
2024-07-27 13:27:38 +02:00
app.setViewEngine({
engine: {
handlebars,
},
2024-07-27 15:52:19 +02:00
templates: join(root, '..', 'views.dist'),
2024-07-27 13:27:38 +02:00
})
2024-07-27 12:55:13 +02:00
await app.listen(port)
2024-07-27 12:55:13 +02:00
}
bootstrap(11371)
bootstrap(process.env.LISTEN_PORT ?? 8080)