Greatly reduce repeated code

This commit is contained in:
2023-10-19 16:50:48 -04:00
parent 47e639be43
commit dd2d9f2672
34 changed files with 196 additions and 481 deletions

View File

@ -1,15 +1,8 @@
function makeResponse(body: string, status: number): Response {
return new Response(body, {
headers: {
"content-type": "application/json",
},
status,
});
}
import { jsonError } from "../../common.js";
export async function onRequest(context: RequestContext) {
if (!context.data.current_user)
return makeResponse('{"error":"You are not logged in"}', 401);
return jsonError("You are not logged in", 401);
const { permissions } = context.data.current_user;
const departments = {