mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-18 15:00:00 +00:00
25 lines
620 B
TypeScript
25 lines
620 B
TypeScript
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: string) {
|
|
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" });
|
|
}
|