40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
/**
|
|
* This is not a production server yet!
|
|
* This is only a minimal backend to get started.
|
|
*/
|
|
|
|
import { NestFactory } from '@nestjs/core';
|
|
import { Logger } from '@nestjs/common';
|
|
import { Logger as PinoLogger } from 'nestjs-pino';
|
|
|
|
import { AppModule } from './app/app.module';
|
|
import { LocalConfig, localConfig } from './app/config/local.config';
|
|
import { patchTypeOrm } from './app/modules/database/typeorm-patch';
|
|
|
|
async function bootstrap() {
|
|
await patchTypeOrm();
|
|
|
|
const appOpts = (() => {
|
|
const loggerOpts = { bufferLogs: true };
|
|
return {
|
|
forceCloseConnections: true,
|
|
...loggerOpts,
|
|
};
|
|
})();
|
|
const app = await NestFactory.create(AppModule, appOpts);
|
|
const globalPrefix = 'api';
|
|
app.setGlobalPrefix(globalPrefix);
|
|
|
|
const config = app.get<LocalConfig>(localConfig.KEY);
|
|
const port = config.port || 3000;
|
|
|
|
app.useLogger(app.get(PinoLogger));
|
|
|
|
await app.listen(port);
|
|
Logger.log(
|
|
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`
|
|
);
|
|
}
|
|
|
|
void bootstrap();
|