21 lines
614 B
TypeScript
21 lines
614 B
TypeScript
import HttpCodes from "@Common/system/controller-pattern/HttpCodes";
|
|
import { NextFunction, Request, Response } from "express";
|
|
|
|
export default async function noteHandler(req: Request, response: Response, next: NextFunction) {
|
|
try {
|
|
|
|
const content = req.body.content;
|
|
|
|
if (content && content.length > 250) {
|
|
response.status(HttpCodes.VALIDATION_ERROR).send([{ property: "content", constraints: { content: "La note dépasse 250 caractères" } }]);
|
|
return;
|
|
}
|
|
|
|
next();
|
|
} catch (error) {
|
|
console.error(error);
|
|
response.status(HttpCodes.INTERNAL_ERROR).send("Internal server error");
|
|
return;
|
|
}
|
|
}
|