* fix: wip better field metadata validation * fix: remove files * fix: default value and options validation * fix: small fix * fix: try to limit patch * fix: tests * Update server/src/metadata/field-metadata/validators/is-field-metadata-options.validator.ts Co-authored-by: Weiko <corentin@twenty.com> * fix: lint * fix: standard fields update security --------- Co-authored-by: Weiko <corentin@twenty.com>
58 lines
1.6 KiB
TypeScript
58 lines
1.6 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 { 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,
|
|
logger: process.env.DEBUG_MODE
|
|
? ['error', 'warn', 'log', 'verbose', 'debug']
|
|
: ['error', 'warn', 'log'],
|
|
});
|
|
|
|
// Apply class-validator container so that we can use injection in validators
|
|
useContainer(app.select(AppModule), { fallbackOnErrors: true });
|
|
|
|
// Apply validation pipes globally
|
|
app.useGlobalPipes(
|
|
new ValidationPipe({
|
|
// whitelist: true,
|
|
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,
|
|
}),
|
|
);
|
|
const loggerService = app.get(LoggerService);
|
|
|
|
app.useLogger(loggerService);
|
|
app.useLogger(app.get(EnvironmentService).getLogLevels());
|
|
|
|
await app.listen(app.get(EnvironmentService).getPort());
|
|
};
|
|
|
|
bootstrap();
|