myheats

Live heats, scoring and leaderboard for sport events
git clone https://git.in0rdr.ch/myheats.git
Log | Files | Refs | Pull requests | README | LICENSE

commit a652e46d95a2220ead7e5d23ed0a60ea3e4832f7
parent d53fb37a68cbb63a0e689be291a0b066fb47f924
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Sat, 28 Sep 2024 10:22:34 +0200

feat(api): remove duplicate dotenv

Diffstat:
Mdocs/debugging.txt | 7++++---
Msrc/api/db.cjs | 15+--------------
Msrc/api/server.cjs | 8++------
3 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/docs/debugging.txt b/docs/debugging.txt @@ -1,9 +1,10 @@ GET/POST -------- -curl -d '{"data":"hi"}' http://127.0.0.1:8000/v1/echo +curl http://127.0.0.1:8000/v1/healthz +curl http://127.0.0.1:8000/v1/leaderboard/allHeats +curl -XPOST -d '{"data":"hi"}' http://127.0.0.1:8000/v1/echo WEBSOCKET --------- echo "egg fried rice" | websocat ws://127.0.0.1:8000/v1/leaderboard -echo '{"method":"getStartListForHeats","data":{"heatIds":[123]}}' | websocat ws://127.0.0.1:8000/v1/leaderboard -echo '{"method":"getScoreForHeatAndAthlete","data":{"heatId":123,"athleteId":456}}' | websocat ws://127.0.0.1:8000/v1/leaderboard +echo '{"method":"watchScores"}' | websocat ws://127.0.0.1:8000/v1/leaderboard diff --git a/src/api/db.cjs b/src/api/db.cjs @@ -21,19 +21,6 @@ sql = postgres({ ] }) -require('dotenv').config({ - // Configure common config files and modes - // - https://www.npmjs.com/package/dotenv - // - https://vitejs.dev/guide/env-and-mode - path: [ - '.env.local', - '.env.development', '.env.development.local', - '.env.test', '.env.test.local', - '.env.production', '.env.production.local', - '.env' - ] -}); - async function invalidateToken(token) { try { const users = await sql` @@ -367,7 +354,7 @@ async function watchScores(clients) { }, () => { // callback on initial connect and potential reconnects - console.log("Watching scores") + console.log("~ Watching scores") } ) return unsubscribe diff --git a/src/api/server.cjs b/src/api/server.cjs @@ -669,13 +669,13 @@ wss1.on('connection', function connection(sock) { sock.on('message', async function message(m) { try { msg = JSON.parse(m) - console.log(' Uncle roger hears: %s', msg); + console.log(' Uncle roger hears:', msg); if (msg.method === 'watchScores') { db.watchScores(clients) } } catch (error) { - console.error('x Error: %s', error.message); + console.error('x Error:', error.message); } }); @@ -690,10 +690,6 @@ wss1.on('connection', function connection(sock) { clients.add(sock); console.log(`~ Received a new websocket connection`); - console.log(` ${sock} connected`); - - //sock.send('🎵 Streaming leaderboard live data..'); - //sock.close(1000, '< Websocket rice party done 👋 uncle roger disowns niece/nephew'); }); // Listen to upgrade event