Convert /api/users.

This commit is contained in:
Mike Cao 2025-01-21 19:10:34 -08:00
parent 090abcff81
commit baa3851fb4
61 changed files with 1064 additions and 70 deletions

21
src/lib/response.ts Normal file
View file

@ -0,0 +1,21 @@
import { serializeError } from 'serialize-error';
export function ok() {
return Response.json({ ok: true });
}
export function json(data: any) {
return Response.json(data);
}
export function badRequest(message?: any) {
return Response.json({ error: 'Bad request', message }, { status: 400 });
}
export function unauthorized() {
return Response.json({ error: 'Unauthorized' }, { status: 401 });
}
export function serverError(error: any) {
return Response.json({ error: 'Server error', message: serializeError(error), status: 500 });
}