mirror of
https://github.com/wahyd4/heygo.git
synced 2026-08-08 21:05:48 +10:00
feat: scaffold cloudflare shortlinks app
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
export interface Env {}
|
||||
|
||||
const jsonHeaders = {
|
||||
'content-type': 'application/json; charset=utf-8',
|
||||
};
|
||||
|
||||
function json(body: unknown, init: ResponseInit = {}) {
|
||||
return Response.json(body, {
|
||||
...init,
|
||||
headers: {
|
||||
...jsonHeaders,
|
||||
...init.headers,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
async fetch(request): Promise<Response> {
|
||||
const url = new URL(request.url);
|
||||
|
||||
if (url.pathname === '/api/health') {
|
||||
return json({ ok: true, service: 'heygo-worker' });
|
||||
}
|
||||
|
||||
if (url.pathname.startsWith('/api/')) {
|
||||
return json({ error: 'Not found' }, { status: 404 });
|
||||
}
|
||||
|
||||
return json({ error: 'Not found' }, { status: 404 });
|
||||
},
|
||||
} satisfies ExportedHandler<Env>;
|
||||
Reference in New Issue
Block a user