From 7b66b30309096b803a4c8a4306b2203685068ecf Mon Sep 17 00:00:00 2001 From: kyuuseiryuu Date: Tue, 3 Mar 2026 17:46:30 +0900 Subject: [PATCH] fix(env): move validation to server.ts and add debug logging for missing variables --- src/index.tsx | 10 ---------- src/utils/server.ts | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 581f3c9..ecee0bb 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,16 +3,6 @@ import { getMatchInfo, listEvent, xcxApi } from "./utils/server"; import index from "./index.html"; import { getUidScore } from "./services/uidScoreStore"; -const REQUIRED_ENVS = [ - process.env.KAIQIUCC_TOKEN, - process.env.REDIS, -]; -if (!REQUIRED_ENVS.every(Boolean)) { - console.error('Missing required environment variables. Please check your .env'); - process.exit(1); -} - - const server = serve({ port: process.env.PORT || 3000, routes: { diff --git a/src/utils/server.ts b/src/utils/server.ts index 472313b..fdee18f 100644 --- a/src/utils/server.ts +++ b/src/utils/server.ts @@ -4,6 +4,17 @@ import { XCXAPI } from "../services/xcxApi"; import { BASE_URL } from "./common"; import { RedisClient } from "bun"; +const REQUIRED_ENVS = [ + process.env.KAIQIUCC_TOKEN, + process.env.REDIS, +]; + +console.debug('ENVS: \n%s', REQUIRED_ENVS.join('\n')); +if (!REQUIRED_ENVS.every(v => !!v)) { + console.error('Missing required environment variables. Please check your .env'); + process.exit(1); +} + export const xcxApi = new XCXAPI(process.env.KAIQIUCC_TOKEN ?? ''); export const redis = new RedisClient(process.env.REDIS ?? '');