From a23540112583436b242307a229691b6a5beded71 Mon Sep 17 00:00:00 2001 From: Alex Pooley Date: Wed, 19 Mar 2025 05:13:20 +0000 Subject: remove ts --- package-lock.json | 3 +-- package.json | 3 +-- source/index.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 60 ------------------------------------------------------- tsconfig.json | 17 ---------------- wrangler.json | 2 +- 6 files changed, 63 insertions(+), 82 deletions(-) create mode 100644 source/index.js delete mode 100644 src/index.ts delete mode 100644 tsconfig.json diff --git a/package-lock.json b/package-lock.json index 4e19cdd..f47e3eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,9 @@ { - "name": "my-app", + "name": "api.zue.dev", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "my-app", "dependencies": { "hono": "^4.6.20" }, diff --git a/package.json b/package.json index 23ab601..94412c1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,4 @@ { - "name": "my-app", "scripts": { "dev": "wrangler dev", "deploy": "wrangler deploy --minify" @@ -11,4 +10,4 @@ "@cloudflare/workers-types": "^4.20250109.0", "wrangler": "^3.101.0" } -} \ No newline at end of file +} diff --git a/source/index.js b/source/index.js new file mode 100644 index 0000000..c20041b --- /dev/null +++ b/source/index.js @@ -0,0 +1,60 @@ +import { Hono } from "hono"; +import { cors } from "hono/cors"; + +const app = new Hono(); + +// unlock cors for all routes +app.use("*", cors()); + +// return a simple message +app.get("/", (c) => { + return c.json({ + message: "Hello, World! :3", + }); +}); + +// return own status of the server +app.get("/status", (c) => { + return c.json({ + status: "ok", + }); +}); + +// return status of a given service +app.get("/status/:service", (c) => { + const { service } = c.req.param(); + + const acceptedServices = [ + "dns", + "load-balancer", + "cdn", + "functions", + "mysql-cluster", + "mongodb-cluster", + "redis-cluster", + "elasticsearch-cluster", + "git-connector", + "job-runners", + "container-registry", + "kubernetes-cluster", + "bare-metal-servers", + "game-server-api", + "anti-ddos-protection", + "anti-cheat-api", + ]; + + if (!acceptedServices.includes(service)) { + return c.json( + { + error: "unknown service", + }, + 400 + ); + } + + return c.json({ + status: "ok", + }); +}); + +export default app; diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index c20041b..0000000 --- a/src/index.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { Hono } from "hono"; -import { cors } from "hono/cors"; - -const app = new Hono(); - -// unlock cors for all routes -app.use("*", cors()); - -// return a simple message -app.get("/", (c) => { - return c.json({ - message: "Hello, World! :3", - }); -}); - -// return own status of the server -app.get("/status", (c) => { - return c.json({ - status: "ok", - }); -}); - -// return status of a given service -app.get("/status/:service", (c) => { - const { service } = c.req.param(); - - const acceptedServices = [ - "dns", - "load-balancer", - "cdn", - "functions", - "mysql-cluster", - "mongodb-cluster", - "redis-cluster", - "elasticsearch-cluster", - "git-connector", - "job-runners", - "container-registry", - "kubernetes-cluster", - "bare-metal-servers", - "game-server-api", - "anti-ddos-protection", - "anti-cheat-api", - ]; - - if (!acceptedServices.includes(service)) { - return c.json( - { - error: "unknown service", - }, - 400 - ); - } - - return c.json({ - status: "ok", - }); -}); - -export default app; diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 934f03c..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "lib": [ - "ESNext" - ], - "types": [ - "@cloudflare/workers-types/2023-07-01" - ], - "jsx": "react-jsx", - "jsxImportSource": "hono/jsx" - }, -} \ No newline at end of file diff --git a/wrangler.json b/wrangler.json index 7fd68de..01aed61 100644 --- a/wrangler.json +++ b/wrangler.json @@ -1,7 +1,7 @@ { "$schema": "node_modules/wrangler/config-schema.json", "name": "api-zue-dev", - "main": "src/index.ts", + "main": "source/index.js", "compatibility_date": "2025-02-05", "routes": [ { -- cgit v1.2.3