Files
twenty/packages/twenty-server/src/main.ts
Félix Malfait 6d5d73fbe8 Improve snackbar and fix sentry (#7181)
- Improve snackbar to enable displaying multi-line message (so far we
only displayed the first few words which was very frustrating)

- Followup on previous issue to enable tim@apple.dev on the demo
workspace (prefilled automatically)

- Fix sentry tracing which had been broken when migrating from v7 to v8
2024-09-21 06:33:15 +02:00

66 lines
2.0 KiB
TypeScript

import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
import bytes from 'bytes';
import { useContainer } from 'class-validator';
import { graphqlUploadExpress } from 'graphql-upload';
import { LoggerService } from 'src/engine/core-modules/logger/logger.service';
import { ApplyCorsToExceptions } from 'src/utils/apply-cors-to-exceptions';
import { AppModule } from './app.module';
import './instrument';
import { settings } from './engine/constants/settings';
import { generateFrontConfig } from './utils/generate-front-config';
const bootstrap = async () => {
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
cors: true,
bufferLogs: process.env.LOGGER_IS_BUFFER_ENABLED === 'true',
rawBody: true,
snapshot: process.env.DEBUG_MODE === 'true',
});
const logger = app.get(LoggerService);
// TODO: Double check this as it's not working for now, it's going to be heplful for durable trees in twenty "orm"
// // Apply context id strategy for durable trees
// ContextIdFactory.apply(new AggregateByWorkspaceContextIdStrategy());
// Apply class-validator container so that we can use injection in validators
useContainer(app.select(AppModule), { fallbackOnErrors: true });
// Use our logger
app.useLogger(logger);
app.useGlobalFilters(new ApplyCorsToExceptions());
// Apply validation pipes globally
app.useGlobalPipes(
new ValidationPipe({
transform: true,
}),
);
app.useBodyParser('json', { limit: settings.storage.maxFileSize });
app.useBodyParser('urlencoded', {
limit: settings.storage.maxFileSize,
extended: true,
});
// Graphql file upload
app.use(
graphqlUploadExpress({
maxFieldSize: bytes(settings.storage.maxFileSize),
maxFiles: 10,
}),
);
// Create the env-config.js of the front at runtime
generateFrontConfig();
await app.listen(process.env.PORT ?? 3000);
};
bootstrap();