Files
zeavis-edu/apps/api/src/lib/http-errors.ts
T

28 lines
785 B
TypeScript
Raw Normal View History

export function badRequest(message: string): Response {
return new Response(JSON.stringify({ error: message }), {
status: 400,
headers: { 'Content-Type': 'application/json' },
});
}
export function notFound(message: string): Response {
return new Response(JSON.stringify({ error: message }), {
status: 404,
headers: { 'Content-Type': 'application/json' },
});
}
export function badGateway(message: string): Response {
return new Response(JSON.stringify({ error: message }), {
status: 502,
headers: { 'Content-Type': 'application/json' },
});
}
export function serviceUnavailable(message: string): Response {
return new Response(JSON.stringify({ error: message }), {
status: 503,
headers: { 'Content-Type': 'application/json' },
});
}