aboutsummaryrefslogtreecommitdiff
path: root/projects/www/server/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'projects/www/server/index.js')
-rw-r--r--projects/www/server/index.js25
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