Files
twenty_crm/packages/twenty-server/src/main.ts
Brody Over 52bb33b566 Disable buffered logs (#3892)
* Update main.ts

* Update command.ts

* Update queue-worker.ts

* Enable users to disable log buffering

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-02-13 14:50:25 +01:00

56 lines
1.5 KiB
TypeScript

import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import * as bodyParser from 'body-parser';
import { graphqlUploadExpress } from 'graphql-upload';
import bytes from 'bytes';
import { useContainer } from 'class-validator';
import '@sentry/tracing';
import { AppModule } from './app.module';
import { settings } from './constants/settings';
import { LoggerService } from './integrations/logger/logger.service';
import { EnvironmentService } from './integrations/environment/environment.service';
const bootstrap = async () => {
const app = await NestFactory.create(AppModule, {
cors: true,
bufferLogs: process.env.LOGGER_IS_BUFFER_ENABLED === 'true',
});
const logger = app.get(LoggerService);
// Apply class-validator container so that we can use injection in validators
useContainer(app.select(AppModule), { fallbackOnErrors: true });
// Use our logger
app.useLogger(logger);
// Apply validation pipes globally
app.useGlobalPipes(
new ValidationPipe({
transform: true,
}),
);
app.use(bodyParser.json({ limit: settings.storage.maxFileSize }));
app.use(
bodyParser.urlencoded({
limit: settings.storage.maxFileSize,
extended: true,
}),
);
// Graphql file upload
app.use(
graphqlUploadExpress({
maxFieldSize: bytes(settings.storage.maxFileSize),
maxFiles: 10,
}),
);
await app.listen(app.get(EnvironmentService).getPort());
};
bootstrap();