23 lines · 530 B
1 /**
2 * gitfastr Worker entrypoint.
3 * Routes requests to git protocol handlers or REST API handlers.
4 */
5
6 import { router } from './router.js';
7 import { handleError } from './middleware/error-handler.js';
8
9 export interface Env {
10 DB: D1Database;
11 OBJECTS: R2Bucket;
12 }
13
14 export default {
15 async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
16 try {
17 return await router(request, env, ctx);
18 } catch (error) {
19 return handleError(error);
20 }
21 },
22 } satisfies ExportedHandler<Env>;
23