Refactor backend folder structure (#4505)
* Refactor backend folder structure Co-authored-by: Charles Bochet <charles@twenty.com> * fix tests * fix * move yoga hooks --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
35
packages/twenty-server/src/command/command.ts
Normal file
35
packages/twenty-server/src/command/command.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { CommandFactory } from 'nest-commander';
|
||||
|
||||
import { filterException } from 'src/engine/filters/utils/global-exception-handler.util';
|
||||
import { ExceptionHandlerService } from 'src/engine/integrations/exception-handler/exception-handler.service';
|
||||
import { LoggerService } from 'src/engine/integrations/logger/logger.service';
|
||||
|
||||
import { CommandModule } from './command.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const errorHandler = (err: Error) => {
|
||||
loggerService.error(err?.message, err?.name);
|
||||
|
||||
if (filterException(err)) {
|
||||
return;
|
||||
}
|
||||
|
||||
exceptionHandlerService.captureExceptions([err]);
|
||||
};
|
||||
|
||||
const app = await CommandFactory.createWithoutRunning(CommandModule, {
|
||||
bufferLogs: process.env.LOGGER_IS_BUFFER_ENABLED === 'true',
|
||||
errorHandler,
|
||||
serviceErrorHandler: errorHandler,
|
||||
});
|
||||
const loggerService = app.get(LoggerService);
|
||||
const exceptionHandlerService = app.get(ExceptionHandlerService);
|
||||
|
||||
// Inject our logger
|
||||
app.useLogger(loggerService);
|
||||
|
||||
await CommandFactory.runApplication(app);
|
||||
|
||||
app.close();
|
||||
}
|
||||
bootstrap();
|
||||
Reference in New Issue
Block a user