From ed406e7eb0dfa2e1c2c9028156628d8b733a4b6a Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sun, 16 Jun 2024 20:26:55 +0530 Subject: [PATCH] Sketch --- infra/workers/uploader/package.json | 10 ++++++++++ infra/workers/uploader/src/index.ts | 19 +++++++++++++++++++ infra/workers/uploader/tsconfig.json | 1 + infra/workers/uploader/wrangler.toml | 7 +++++++ 4 files changed, 37 insertions(+) create mode 100644 infra/workers/uploader/package.json create mode 100644 infra/workers/uploader/src/index.ts create mode 100644 infra/workers/uploader/tsconfig.json create mode 100644 infra/workers/uploader/wrangler.toml diff --git a/infra/workers/uploader/package.json b/infra/workers/uploader/package.json new file mode 100644 index 0000000000..e22b4eb1fc --- /dev/null +++ b/infra/workers/uploader/package.json @@ -0,0 +1,10 @@ +{ + "name": "uploader", + "private": true, + "devDependencies": { + "@cloudflare/workers-types": "^4.20240614.0", + "typescript": "^5", + "wrangler": "^3" + }, + "packageManager": "yarn@1.22.22" +} diff --git a/infra/workers/uploader/src/index.ts b/infra/workers/uploader/src/index.ts new file mode 100644 index 0000000000..e1a90df9d8 --- /dev/null +++ b/infra/workers/uploader/src/index.ts @@ -0,0 +1,19 @@ +/** + * Proxy file uploads. + * + * See: https://ente.io/blog/tech/making-uploads-faster/ + */ + +export default { + async fetch(request: Request) { + switch (request.method) { + // case "OPTIONS": + // return handleOPTIONS(request); + // case "GET": + // return handleGET(request); + default: + console.log(`Unsupported HTTP method ${request.method}`); + return new Response(null, { status: 405 }); + } + }, +} satisfies ExportedHandler; diff --git a/infra/workers/uploader/tsconfig.json b/infra/workers/uploader/tsconfig.json new file mode 100644 index 0000000000..a65b752070 --- /dev/null +++ b/infra/workers/uploader/tsconfig.json @@ -0,0 +1 @@ +{ "extends": "../tsconfig.base.json", "include": ["src"] } diff --git a/infra/workers/uploader/wrangler.toml b/infra/workers/uploader/wrangler.toml new file mode 100644 index 0000000000..9a03d8c6d5 --- /dev/null +++ b/infra/workers/uploader/wrangler.toml @@ -0,0 +1,7 @@ +name = "uploader" +main = "src/index.ts" +compatibility_date = "2024-06-14" + +routes = [{ pattern = "uploader.ente.io", custom_domain = true }] + +tail_consumers = [{ service = "tail" }]