Skip to content
This repository was archived by the owner on May 5, 2024. It is now read-only.

Commit 8ca3b2e

Browse files
feat: add respondWithError() function
1 parent 14a980d commit 8ca3b2e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

respondWithError.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const ERRORS = {
2+
BAD_MODULE: 400,
3+
BAD_VERSION: 400,
4+
UNINDEXED_MODULE: 404,
5+
NOT_FOUND: 404,
6+
}
7+
8+
export function respondWithError(message: keyof typeof ERRORS) {
9+
return new Response(message, {
10+
status: ERRORS[message],
11+
headers: {
12+
'content-type': 'text/plain; charset=utf-8',
13+
},
14+
})
15+
}

0 commit comments

Comments
 (0)