Working on API route for status.

This commit is contained in:
charles-gauthereau
2024-11-11 18:27:20 +01:00
parent 221d0c4b26
commit 55c5a35918
6 changed files with 104 additions and 2 deletions
+8
View File
@@ -0,0 +1,8 @@
import {NextResponse} from "next/server";
export const errorHandler = (error: any) => {
return new NextResponse(
JSON.stringify({ message: 'An error occurred while processing your request.', status: 500 }),
{ status: 500, headers: { 'Content-Type': 'application/json' } }
);
};
+8
View File
@@ -0,0 +1,8 @@
import { NextRequest, NextResponse } from 'next/server';
export function loggingMiddleware(request: NextRequest) {
if (request.url.includes('/api')) {
console.log(`[API] Received ${request.method} request : ${request.url} at ${new Date()}`);
}
return NextResponse.next();
}