breakout into monorepo
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
export default {
|
||||
async fetch(request, env, ctx): Promise<Response> {
|
||||
const url = new URL(request.url);
|
||||
const prefix = url.pathname.slice(1);
|
||||
|
||||
switch (request.method) {
|
||||
case 'GET':
|
||||
const listResponse = await env.media.list({ prefix, limit: 1000 });
|
||||
const keys = listResponse.objects.map(o => o.key);
|
||||
|
||||
const headers = new Headers();
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
return new Response(JSON.stringify(keys), {
|
||||
headers,
|
||||
status: 200,
|
||||
});
|
||||
|
||||
default:
|
||||
return new Response(`${request.method} is not allowed.`, {
|
||||
status: 405,
|
||||
headers: {
|
||||
Allow: 'GET',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
} satisfies ExportedHandler<Env>;
|
||||
Reference in New Issue
Block a user