Create very-often used methods
This commit is contained in:
parent
77f5b2db26
commit
47e639be43
12
functions/common.ts
Normal file
12
functions/common.ts
Normal file
@ -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,
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user