all repos — stealth-developers @ 43e8c7358a2056b6ab989ef6fe8c91cf6ad58923

refac: use isProd global var
vi did:web:vt3e.cat
Sat, 09 May 2026 02:04:21 +0100
commit

43e8c7358a2056b6ab989ef6fe8c91cf6ad58923

parent

b30621f89da1d2cbca3735c0662931f8f0608758

4 files changed, 12 insertions(+), 15 deletions(-)

jump to
M src/automod/index.tssrc/automod/index.ts

@@ -16,9 +16,8 @@ import { loggers } from "@/utils/logging";

import { db } from "@/database"; import { automodHashes } from "@/database/schema/automod"; import { eq } from "drizzle-orm"; +import { isProd } from "@/config"; const logger = loggers.automod; - -const IS_PROD = Bun.env.NODE_ENV === "PROD"; type Pending = { channels: Set<Snowflake>;

@@ -30,7 +29,7 @@ const pendingReports = new Map<Snowflake, Pending>();

const cooldowns = new Map<Snowflake, NodeJS.Timeout>(); async function getLogChannel(client: Client) { - return client.channels.fetch(IS_PROD ? "1493015326554587146" : "1493015912234881205"); + return client.channels.fetch(isProd ? "1493015326554587146" : "1493015912234881205"); } type AutomodResult = { delete: true } | null;

@@ -76,7 +75,7 @@ if (message.channel.type == ChannelType.GuildText && message.channel.name.includes("ticket"))

return; if (message.channel.isThread()) return null; if (message.content.includes("!bypass")) return null; - if ((await hasManagerPermissions(message.member)) && IS_PROD) return null; + if ((await hasManagerPermissions(message.member)) && isProd) return null; for (const func of automodFunctions) { const result = await func(client, message);
M src/config.tssrc/config.ts

@@ -4,6 +4,8 @@

import { loggers } from "@/utils/logging"; const logger = loggers.config; +export const isProd = Bun.env.NODE_ENV === "production"; + const robloxSchema = z.object({ cookie: z.string(), apiKey: z.string(),
M src/server/index.tssrc/server/index.ts

@@ -2,7 +2,7 @@ import { desc, eq, asc, and, isNotNull, ne, gte, inArray, or } from "drizzle-orm";

import type { BunRequest } from "bun"; import _logger from "@/utils/logging"; -import config from "@/config"; +import config, { isProd } from "@/config"; import { db, tickets, ticketMessages, moderators, sessions, attachments } from "@/database"; import { getUser, getUsers, hydrateTickets } from "./discord";

@@ -10,11 +10,10 @@ const logger = _logger.child({ name: "server" });

const CLIENT_ID = config.discord.app_id; const CLIENT_SECRET = config.discord.client_secret; -const HOST = - Bun.env.NODE_ENV === "production" ? "https://tickets.vt3e.cat" : "http://127.0.0.1:3000"; + +const HOST = isProd ? "https://tickets.vt3e.cat" : "http://127.0.0.1:3000"; const REDIRECT_URI = `${HOST}/auth/callback`; - -const FRONTEND_URL = process.env.FRONTEND_URL || "http://127.0.0.1:5173"; +const FRONTEND_URL = isProd ? HOST : "http://127.0.0.1:5173"; async function getSessionUser(req: BunRequest) { const cookieHeader = req.headers.get("Cookie");

@@ -43,7 +42,7 @@ Location: redirectUri,

}, }); }, - "/api/auth/callback": { + "/auth/callback": { GET: async (req) => { const url = new URL(req.url); const code = url.searchParams.get("code");
M src/utils/logging.tssrc/utils/logging.ts

@@ -1,10 +1,7 @@

+import { isProd } from "@/config"; import { pino } from "pino"; -const logLevel = process.env.LOG_LEVEL - ? process.env.LOG_LEVEL - : process.env.NODE_ENV === "production" - ? "info" - : "debug"; +const logLevel = process.env.LOG_LEVEL ? process.env.LOG_LEVEL : isProd ? "info" : "debug"; const logger = pino({ transport: {