From 465fbf96c9dbd893faaee04e5a96dbf3d4ea6f18 Mon Sep 17 00:00:00 2001 From: Lucid Date: Sat, 6 Dec 2025 23:45:46 -0500 Subject: [PATCH] fixed env variable not working. --- src/bot/features/botInfoCommand.ts | 2 +- src/bot/features/embedCheck.ts | 2 +- src/bot/features/helpCommand.ts | 2 +- src/bot/features/metaBlacklist.ts | 2 +- src/bot/features/twitterBlacklist.ts | 2 +- src/bot/features/welcome.ts | 2 +- src/lib/urql.ts | 13 ------------- src/main.ts | 11 +++++++++++ 8 files changed, 17 insertions(+), 19 deletions(-) delete mode 100644 src/lib/urql.ts diff --git a/src/bot/features/botInfoCommand.ts b/src/bot/features/botInfoCommand.ts index 8ba1ce5..2d867bf 100644 --- a/src/bot/features/botInfoCommand.ts +++ b/src/bot/features/botInfoCommand.ts @@ -1,7 +1,7 @@ import { Composer } from "grammy"; import type { Context } from "#root/bot/context.js"; import { logHandle } from "#root/bot/helpers/logging.js"; -import urql from "#root/lib/urql.js"; +import { urql } from "#root/main.js"; import increment from "#root/lib/graphql/mutations/incrimentMutation.js"; const composer = new Composer(); diff --git a/src/bot/features/embedCheck.ts b/src/bot/features/embedCheck.ts index e89f400..4177fc2 100644 --- a/src/bot/features/embedCheck.ts +++ b/src/bot/features/embedCheck.ts @@ -3,7 +3,7 @@ import type { Context } from "#root/bot/context.js"; import { logHandle } from "#root/bot/helpers/logging.js"; import metaLinkCheck from "#root/lib/metaLinkCheck.js"; import twitterLinkCheck from "#root/lib/twitterLinkCheck.js"; -import urql from "#root/lib/urql.js"; +import { urql } from "#root/main.js"; import increment from "#root/lib/graphql/mutations/incrimentMutation.js"; import addGroup from "#root/lib/graphql/mutations/addGroupMutation.js"; import incrementGroup from "#root/lib/graphql/mutations/incrementGroupMutation.js"; diff --git a/src/bot/features/helpCommand.ts b/src/bot/features/helpCommand.ts index b706a01..23295a7 100644 --- a/src/bot/features/helpCommand.ts +++ b/src/bot/features/helpCommand.ts @@ -1,7 +1,7 @@ import { Composer } from "grammy"; import type { Context } from "#root/bot/context.js"; import { logHandle } from "#root/bot/helpers/logging.js"; -import urql from "#root/lib/urql.js"; +import { urql } from "#root/main.js"; import increment from "#root/lib/graphql/mutations/incrimentMutation.js"; const composer = new Composer(); diff --git a/src/bot/features/metaBlacklist.ts b/src/bot/features/metaBlacklist.ts index f38a5da..8eaadc8 100644 --- a/src/bot/features/metaBlacklist.ts +++ b/src/bot/features/metaBlacklist.ts @@ -2,7 +2,7 @@ import { Composer } from "grammy"; import type { Context } from "#root/bot/context.js"; import { logHandle } from "#root/bot/helpers/logging.js"; import { metaRegex } from "#root/lib/metaLinkCheck.js"; -import urql from "#root/lib/urql.js"; +import { urql } from "#root/main.js"; import increment from "#root/lib/graphql/mutations/incrimentMutation.js"; import addGroup from "#root/lib/graphql/mutations/addGroupMutation.js"; import incrementGroup from "#root/lib/graphql/mutations/incrementGroupMutation.js"; diff --git a/src/bot/features/twitterBlacklist.ts b/src/bot/features/twitterBlacklist.ts index 038e690..8e04bfe 100644 --- a/src/bot/features/twitterBlacklist.ts +++ b/src/bot/features/twitterBlacklist.ts @@ -2,7 +2,7 @@ import { Composer } from "grammy"; import type { Context } from "#root/bot/context.js"; import { logHandle } from "#root/bot/helpers/logging.js"; import { twitterRegex } from "#root/lib/twitterLinkCheck.js"; -import urql from "#root/lib/urql.js"; +import { urql } from "#root/main.js"; import increment from "#root/lib/graphql/mutations/incrimentMutation.js"; import addGroup from "#root/lib/graphql/mutations/addGroupMutation.js"; import incrementGroup from "#root/lib/graphql/mutations/incrementGroupMutation.js"; diff --git a/src/bot/features/welcome.ts b/src/bot/features/welcome.ts index 4d2c730..d491291 100644 --- a/src/bot/features/welcome.ts +++ b/src/bot/features/welcome.ts @@ -1,7 +1,7 @@ import { Composer } from "grammy"; import type { Context } from "#root/bot/context.js"; import { logHandle } from "#root/bot/helpers/logging.js"; -import urql from "#root/lib/urql.js"; +import { urql } from "#root/main.js"; import increment from "#root/lib/graphql/mutations/incrimentMutation.js"; const composer = new Composer(); diff --git a/src/lib/urql.ts b/src/lib/urql.ts deleted file mode 100644 index 82ba9bb..0000000 --- a/src/lib/urql.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Client, cacheExchange, fetchExchange } from "@urql/core"; - -const urql = new Client({ - url: process.env.GRAPHQL_URL || "", - exchanges: [cacheExchange, fetchExchange], - fetchOptions: { - headers: { - "x-api-key": process.env?.GRAPHQL_API_TOKEN || "" - } - } -}); - -export default urql; diff --git a/src/main.ts b/src/main.ts index 20e147d..2057c41 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,6 +8,7 @@ import { config } from "#root/config.js"; import { logger } from "#root/logger.js"; import { createServer, createServerManager } from "#root/server/index.js"; import { run } from "@grammyjs/runner"; +import { Client, cacheExchange, fetchExchange } from "@urql/core"; async function startPolling(config: PollingConfig) { const bot = createBot(config.botToken, { @@ -112,3 +113,13 @@ function onShutdown(cleanUp: () => Promise) { process.on("SIGINT", handleShutdown); process.on("SIGTERM", handleShutdown); } + +export const urql = new Client({ + url: process.env.GRAPHQL_URL || "", + exchanges: [cacheExchange, fetchExchange], + fetchOptions: { + headers: { + "x-api-key": process.env?.GRAPHQL_API_TOKEN || "" + } + } +});