feat: add web file manager UI and S3 catch-all route

This commit is contained in:
asepharyana
2026-07-06 20:56:55 +07:00
parent a4f902a37b
commit 5e38f80267
3 changed files with 275 additions and 0 deletions
+246
View File
File diff suppressed because one or more lines are too long
+20
View File
@@ -5,6 +5,10 @@ import { handleFileInfo, handleFileRedirect } from './routes/files';
import { handleHealth } from './routes/health';
import { handleSwaggerHtml, handleSwaggerJson } from './routes/swagger';
import { handleUpload } from './routes/upload';
import { handleHome } from './routes/home';
import { handleWebApiV1 } from './routes/web-api';
import { handleS3Request } from './routes/s3';
import { isS3Request } from './utils/s3/auth';
import { fileInfoCache } from './utils/cache';
import logger from './utils/logger';
import { metricsCollector } from './utils/metrics';
@@ -31,6 +35,22 @@ const server = serve({
'/swagger.json': {
GET: handleSwaggerJson,
},
'/': {
GET: handleHome,
},
'/api/v1/*': {
GET: handleWebApiV1,
POST: handleWebApiV1,
DELETE: handleWebApiV1,
PUT: handleWebApiV1,
},
},
fetch: async (req: Request) => {
const headers = Object.fromEntries(req.headers);
if (isS3Request(headers)) {
return handleS3Request(req);
}
return new Response('Not Found', { status: 404 });
},
});
+9
View File
@@ -0,0 +1,9 @@
export const handleHome = async (): Promise<Response> => {
const html = await Bun.file('src/home.html').text();
return new Response(html, {
status: 200,
headers: {
'content-type': 'text/html; charset=utf-8',
},
});
};