diff options
| author | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2025-10-30 23:40:37 +0000 |
|---|---|---|
| committer | Alex Pooley (@zuedev) <zuedev@gmail.com> | 2025-10-30 23:40:37 +0000 |
| commit | 2131d5fec97f6163678fdec40dd2d6e9f7a5e58c (patch) | |
| tree | 4e914c764809acdaa869598f10fd5016e386ac53 /projects/www/server/index.js | |
| parent | e9b62b2bc620bae72daa32d6b96bd5e59b2a293f (diff) | |
| download | zue.dev-2131d5fec97f6163678fdec40dd2d6e9f7a5e58c.tar zue.dev-2131d5fec97f6163678fdec40dd2d6e9f7a5e58c.tar.gz zue.dev-2131d5fec97f6163678fdec40dd2d6e9f7a5e58c.tar.bz2 zue.dev-2131d5fec97f6163678fdec40dd2d6e9f7a5e58c.tar.xz zue.dev-2131d5fec97f6163678fdec40dd2d6e9f7a5e58c.zip | |
restructure repo into a monorepo
Diffstat (limited to 'projects/www/server/index.js')
| -rw-r--r-- | projects/www/server/index.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/projects/www/server/index.js b/projects/www/server/index.js new file mode 100644 index 0000000..10151ea --- /dev/null +++ b/projects/www/server/index.js @@ -0,0 +1,25 @@ +export default { + async fetch(request, env) { + const url = new URL(request.url); + + if (url.pathname.startsWith("/api")) { + const apiPath = url.pathname.split("/").filter(Boolean); + + if (!apiPath[1]) apiPath[1] = "index"; + + switch (apiPath[1]) { + case "index": + return new Response(JSON.stringify({ message: "Hello, World! :3" }), { + headers: { "Content-Type": "application/json" }, + }); + default: + return new Response(JSON.stringify({ message: "Not Found" }), { + status: 404, + headers: { "Content-Type": "application/json" }, + }); + } + } + + return env.ASSETS.fetch(request); + }, +};
\ No newline at end of file |
