switch to monorepo structure

This commit is contained in:
2025-05-06 11:00:35 +01:00
parent e1f927ad27
commit 07b7f1b51f
63 changed files with 2440 additions and 1011 deletions

View File

@@ -0,0 +1,22 @@
import { HttpError } from "./error.ts"
function httpHandler<Route extends string>(
handler: (request: Bun.BunRequest<Route>) => Promise<Response>,
): (request: Bun.BunRequest<Route>) => Promise<Response> {
return async (request) => {
try {
const response = await handler(request)
return response
} catch (error) {
if (error instanceof HttpError) {
if (error.message) {
return Response.json({ message: error.message }, { status: error.status })
}
return new Response(undefined, { status: error.status })
}
return new Response(undefined, { status: 500 })
}
}
}
export { httpHandler }