Backend: DB schema, login API
This commit is contained in:
21
packages/backend/src/RequestError.ts
Normal file
21
packages/backend/src/RequestError.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Data } from "effect";
|
||||
|
||||
export class RequestError extends Data.TaggedError("RequestError")<{
|
||||
readonly status: number,
|
||||
readonly body?: string,
|
||||
}> {
|
||||
get response(): Response {
|
||||
if (this.body) {
|
||||
const body = new TextEncoder().encode(this.body);
|
||||
return new Response(body, {
|
||||
headers: {
|
||||
"Content-Length": body.byteLength.toString(),
|
||||
"Content-Type": "text/plain; charset=utf-8",
|
||||
},
|
||||
status: this.status,
|
||||
});
|
||||
} else {
|
||||
return new Response(null, { status: this.status });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user