diff --git a/src/home.html b/src/home.html new file mode 100644 index 0000000..7a0ca1a --- /dev/null +++ b/src/home.html @@ -0,0 +1,246 @@ + + + + + + TeleUploader ยท S3 File Manager + + + +
+ + + + + + +
+ +
+

Select a bucket to get started

Choose a bucket from the dropdown above, or create a new one.

+
+ + + + + + diff --git a/src/index.ts b/src/index.ts index 9376553..e7f1bee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 }); }, }); diff --git a/src/routes/home.ts b/src/routes/home.ts new file mode 100644 index 0000000..d9af0bb --- /dev/null +++ b/src/routes/home.ts @@ -0,0 +1,9 @@ +export const handleHome = async (): Promise => { + const html = await Bun.file('src/home.html').text(); + return new Response(html, { + status: 200, + headers: { + 'content-type': 'text/html; charset=utf-8', + }, + }); +};