mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
Convert /api/users.
This commit is contained in:
parent
090abcff81
commit
baa3851fb4
61 changed files with 1064 additions and 70 deletions
21
src/lib/response.ts
Normal file
21
src/lib/response.ts
Normal 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 });
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue