mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-19 16:05:01 +00:00
Reorganize project. Add folder for shared code between backend/dashboard. Switch from jest to ava for tests.
This commit is contained in:
parent
80a82fe348
commit
16111bbe84
162 changed files with 11056 additions and 9900 deletions
25
backend/src/api/responses.ts
Normal file
25
backend/src/api/responses.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { Response } from "express";
|
||||
|
||||
export function unauthorized(res: Response) {
|
||||
res.status(403).json({ error: "Unauthorized" });
|
||||
}
|
||||
|
||||
export function error(res: Response, message: string, statusCode: number = 500) {
|
||||
res.status(statusCode).json({ error: message });
|
||||
}
|
||||
|
||||
export function serverError(res: Response, message = "Server error") {
|
||||
error(res, message, 500);
|
||||
}
|
||||
|
||||
export function clientError(res: Response, message: string) {
|
||||
error(res, message, 400);
|
||||
}
|
||||
|
||||
export function notFound(res: Response) {
|
||||
res.status(404).json({ error: "Not found" });
|
||||
}
|
||||
|
||||
export function ok(res: Response) {
|
||||
res.json({ result: "ok" });
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue