cupidgpg/src/main.ts

33 lines
813 B
TypeScript

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