From 47e639be43c1987613d8ff4b7f9b4552da71fba9 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:50:48 -0400 Subject: [PATCH] Create very-often used methods --- functions/common.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 functions/common.ts diff --git a/functions/common.ts b/functions/common.ts new file mode 100644 index 0000000..03d89d0 --- /dev/null +++ b/functions/common.ts @@ -0,0 +1,12 @@ +export function jsonError(error: string, status: number) { + return jsonResponse(JSON.stringify({ error }), status); +} + +export function jsonResponse(body: string, status = 200) { + return new Response(body, { + headers: { + "content-type": "application/json", + }, + status, + }); +}