Files
twenty/packages/twenty-server/src/engine/middlewares/rest-core.middleware.ts
T
Félix Malfait 8b4b9ef8da Change type import rule (#13751)
Forcing "type" to be explicit, works best will rollup on the frontend to
exclude depdendencies
2025-08-08 01:27:05 +02:00

23 lines
641 B
TypeScript

import { Injectable, type NestMiddleware } from '@nestjs/common';
import { type NextFunction, type Request, type Response } from 'express';
import { MiddlewareService } from 'src/engine/middlewares/middleware.service';
@Injectable()
export class RestCoreMiddleware implements NestMiddleware {
constructor(private readonly middlewareService: MiddlewareService) {}
async use(req: Request, res: Response, next: NextFunction) {
try {
await this.middlewareService.hydrateRestRequest(req);
} catch (error) {
this.middlewareService.writeRestResponseOnExceptionCaught(res, error);
return;
}
next();
}
}