fix(env): move validation to server.ts and add debug logging for missing
variables
This commit is contained in:
parent
e97444244a
commit
7b66b30309
@ -3,16 +3,6 @@ import { getMatchInfo, listEvent, xcxApi } from "./utils/server";
|
|||||||
import index from "./index.html";
|
import index from "./index.html";
|
||||||
import { getUidScore } from "./services/uidScoreStore";
|
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({
|
const server = serve({
|
||||||
port: process.env.PORT || 3000,
|
port: process.env.PORT || 3000,
|
||||||
routes: {
|
routes: {
|
||||||
|
|||||||
@ -4,6 +4,17 @@ import { XCXAPI } from "../services/xcxApi";
|
|||||||
import { BASE_URL } from "./common";
|
import { BASE_URL } from "./common";
|
||||||
import { RedisClient } from "bun";
|
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 xcxApi = new XCXAPI(process.env.KAIQIUCC_TOKEN ?? '');
|
||||||
|
|
||||||
export const redis = new RedisClient(process.env.REDIS ?? '');
|
export const redis = new RedisClient(process.env.REDIS ?? '');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user