From 44d5fb3f50c8e08fc9cc1e93133dad7883e251bd Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 10 Mar 2024 00:45:01 +0800 Subject: [PATCH] refactor: add fullNum props in telemetry badge --- src/client/vite.config.ts | 2 +- src/server/router/telemetry.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client/vite.config.ts b/src/client/vite.config.ts index a0a80e7..3345a24 100644 --- a/src/client/vite.config.ts +++ b/src/client/vite.config.ts @@ -10,7 +10,7 @@ export default defineConfig({ }, clearScreen: false, server: { - host: '0.0.0.0', + // host: '0.0.0.0', proxy: { '/socket.io': { target: 'ws://localhost:12345', diff --git a/src/server/router/telemetry.ts b/src/server/router/telemetry.ts index 7b026ca..aabfe9b 100644 --- a/src/server/router/telemetry.ts +++ b/src/server/router/telemetry.ts @@ -73,18 +73,21 @@ telemetryRouter.get( query('name').optional().isString(), query('url').optional().isURL(), query('title').optional().isString(), - query('start').optional().isNumeric() + query('start').optional().isNumeric(), + query('fullNum').optional().isBoolean() ), async (req, res) => { const title = req.query.title || 'visitor'; const start = req.query.start ? Number(req.query.start) : 0; + const fullNum = req.query.fullNum === 'true'; recordTelemetryEvent(req); const num = await sumTelemetryEvent(req); + const count = num + start; const svg = makeBadge({ label: String(title), - message: numify(num + start), + message: fullNum ? String(count) : numify(count), color: 'green', });