Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Factory functions for creating HTTP Response objects.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
export function internalServerError(err: unknown, body: string = "An unknown error has occurred.") {
console.error("Internal Server Error", String(err));
return new Response(body, {
status: 500,
statusText: "Internal Server Error",
});
}
export function badRequest(body: string = null) {
return new Response(body, {
status: 400,
statusText: "Bad Request",
});
}
export function forbidden(body: string = null) {
return new Response(body, {
status: 401,
statusText: "Forbidden",
});
}
export function success(body: string = null) {
return new Response(body, {
status: 200,
statusText: "OK",
});
}
June 24, 2024