From a068055e4f444015bbf780d3a69d7ac0e95eeec5 Mon Sep 17 00:00:00 2001 From: zombieb Date: Mon, 27 Oct 2025 21:49:35 -0400 Subject: [PATCH] yeah --- .gitignore | 1 + README.md | 12 +++- deno.json | 9 ++- deno.lock | 9 ++- main.ts | 54 +++++++++++++++ pub/index.html | 4 -- res/index.html | 177 +++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 258 insertions(+), 8 deletions(-) create mode 100644 .gitignore delete mode 100644 pub/index.html create mode 100644 res/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f3d6549 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build/ \ No newline at end of file diff --git a/README.md b/README.md index 2059d65..65d9d58 100644 --- a/README.md +++ b/README.md @@ -1 +1,11 @@ -hi miku!!! \ No newline at end of file +# literally hatsune miku +## miku expo 2026 +### ticket prices are just robbery in plain daylight + +using deno and hono framework. + +`deno run dev` + +`deno run compile-win` + +`deno run compile` \ No newline at end of file diff --git a/deno.json b/deno.json index 169bb43..465eeaf 100644 --- a/deno.json +++ b/deno.json @@ -1,9 +1,14 @@ { "tasks": { - "dev": "deno run -A main.ts" + "dev": "deno run -A main.ts", + "compile-win": "deno compile --include res --target x86_64-pc-windows-msvc -o build/go_go_gadget_unofficial_countdown.exe -A main.ts", + "compile": "deno compile --include res --target x86_64-unknown-linux-gnu -o build/go_go_gadget_unofficial_countdown -A main.ts", + "dual-compile": "deno run compile-win && deno run compile" }, "imports": { + "@hono/hono": "jsr:@hono/hono@^4.10.3", "@proxnet/undead-logging": "jsr:@proxnet/undead-logging@^1.5.1", - "@std/assert": "jsr:@std/assert@1" + "@std/assert": "jsr:@std/assert@1", + "@types/node": "npm:@types/node@^24.2.0" } } diff --git a/deno.lock b/deno.lock index f97bdee..e94cab8 100644 --- a/deno.lock +++ b/deno.lock @@ -1,13 +1,18 @@ { "version": "5", "specifiers": { + "jsr:@hono/hono@^4.10.3": "4.10.3", "jsr:@proxnet/undead-logging@^1.5.1": "1.5.1", "jsr:@std/assert@1": "1.0.15", "jsr:@std/internal@^1.0.12": "1.0.12", "npm:@types/node@*": "24.2.0", + "npm:@types/node@^24.2.0": "24.2.0", "npm:chalk@^5.3.0": "5.6.2" }, "jsr": { + "@hono/hono@4.10.3": { + "integrity": "d37db91cace43d80dccdbb49b396bd4f97e019c8566c20201cb1d9e4a3009e45" + }, "@proxnet/undead-logging@1.5.1": { "integrity": "f858b6357d52c4bc1bbab279200dae86ed573ea45d945a8dfaf2f2cb23c4b649", "dependencies": [ @@ -40,8 +45,10 @@ }, "workspace": { "dependencies": [ + "jsr:@hono/hono@^4.10.3", "jsr:@proxnet/undead-logging@^1.5.1", - "jsr:@std/assert@1" + "jsr:@std/assert@1", + "npm:@types/node@^24.2.0" ] } } diff --git a/main.ts b/main.ts index e69de29..a124445 100644 --- a/main.ts +++ b/main.ts @@ -0,0 +1,54 @@ +// deno-lint-ignore-file require-await +import Logging, { LoggingConfiguration, LogTiming, TimeFormat } from "@proxnet/undead-logging"; +import { Hono } from "@hono/hono"; +import path from "node:path"; +import process from "node:process"; + +function resDir() { + return path.resolve(import.meta.dirname?.concat("/res/") ?? process.cwd()); +} + +LoggingConfiguration.timeFormat = TimeFormat.Unix; +LoggingConfiguration.logTiming = LogTiming.Microtask; + +const log = new Logging("Main"); + + +const CONSTANTS = { + page: Deno.readTextFileSync(path.join(resDir(), "index.html")), + port: 39392, + hostname: Deno.args[0] +} + +const app = new Hono(); + +let visits = 0; + +app.get('/', async r => { + return r.html(CONSTANTS.page); +}); +app.get('/hit', async r => { + visits++; + return r.json(visits); +}); + +app.use('*', async r => { + r.status(404); + return r.text("Not Found. Sorry! - zombieb"); +}); + +function getSrcAddr(r: Request, addr: Deno.NetAddr) { + const cf = r.headers.get("Cf-Connecting-Ip"); + if (cf) return cf; + else return `${addr.hostname}:${addr.port}`; +} + +Deno.serve({ port: CONSTANTS.port, hostname: CONSTANTS.hostname, onListen: n => { + log.i(`Listening information: ${JSON.stringify(n)}`); +} }, async (r, addr) => { + const url = new URL(r.url); + + log.n(`${getSrcAddr(r, addr.remoteAddr)} ${r.method} ${url.pathname}${url.searchParams.size > 0 ? `?${url.searchParams.toString()}` : ''}`); + + return await app.fetch(r); +}); \ No newline at end of file diff --git a/pub/index.html b/pub/index.html deleted file mode 100644 index e0a0b22..0000000 --- a/pub/index.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/res/index.html b/res/index.html new file mode 100644 index 0000000..b51d043 --- /dev/null +++ b/res/index.html @@ -0,0 +1,177 @@ + + + + MIKU EXPO 2026 Time Tracker + + + + + +
+ +

go go gadget unofficial countdown

+
+ +
+

loading!!!

+
+ +
+ +
+

3939 visits

+
+ + + + + + \ No newline at end of file