fosrl.pangolin/server/middlewares/notFound.ts

18 lines
498 B
TypeScript
Raw Permalink Normal View History

2024-10-01 20:48:03 -04:00
import { NextFunction, Request, Response } from "express";
import createHttpError from "http-errors";
import HttpCode from "@server/types/HttpCode";
export function notFoundMiddleware(
req: Request,
res: Response,
next: NextFunction,
) {
2024-10-06 12:39:05 -04:00
if (req.path.startsWith("/api")) {
const message = `The requests url is not found - ${req.originalUrl}`;
return next(createHttpError(HttpCode.NOT_FOUND, message));
}
return next();
2024-10-01 20:48:03 -04:00
}
export default notFoundMiddleware;