mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 10:25:23 +00:00
typeorm logger
This commit is contained in:
13
src/main.ts
13
src/main.ts
@ -7,6 +7,9 @@ import { ValidationPipe } from '@nestjs/common';
|
||||
import { json, urlencoded } from 'body-parser';
|
||||
import { SeederService } from '@app/common/seed/services/seeder.service';
|
||||
import { HttpExceptionFilter } from './common/filters/http-exception/http-exception.filter';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
|
||||
import { RequestContextMiddleware } from '@app/common/middleware/request-context.middleware';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
@ -18,6 +21,8 @@ async function bootstrap() {
|
||||
app.use(urlencoded({ limit: '1mb', extended: true }));
|
||||
app.useGlobalFilters(new HttpExceptionFilter());
|
||||
|
||||
app.use(new RequestContextMiddleware().use);
|
||||
|
||||
app.use(
|
||||
rateLimit({
|
||||
windowMs: 5 * 60 * 1000,
|
||||
@ -43,14 +48,16 @@ async function bootstrap() {
|
||||
);
|
||||
|
||||
const seederService = app.get(SeederService);
|
||||
const logger = app.get<Logger>(WINSTON_MODULE_NEST_PROVIDER);
|
||||
|
||||
try {
|
||||
await seederService.seed();
|
||||
console.log('Seeding complete!');
|
||||
logger.log('Seeding complete!');
|
||||
} catch (error) {
|
||||
console.error('Seeding failed!', error);
|
||||
logger.error('Seeding failed!', error.stack || error);
|
||||
}
|
||||
|
||||
console.log('Starting auth at port ...', process.env.PORT || 4000);
|
||||
logger.log('Starting auth at port ...', process.env.PORT || 4000);
|
||||
await app.listen(process.env.PORT || 4000);
|
||||
}
|
||||
bootstrap();
|
||||
|
Reference in New Issue
Block a user