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

42 lines
1.1 KiB
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' },
});
}
2026-05-22 16:08:18 +00:00
export function unauthorized(message: string): Response {
return new Response(JSON.stringify({ error: message }), {
status: 401,
headers: { 'Content-Type': 'application/json' },
});
}
export function forbidden(message: string): Response {
return new Response(JSON.stringify({ error: message }), {
status: 403,
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' },
});
}