From 2bd1d2fae8ebb694235a23bf05b38edac611fdb2 Mon Sep 17 00:00:00 2001 From: "anatoly.shipitz" Date: Tue, 3 Jun 2025 16:41:17 +0200 Subject: [PATCH 1/2] feat: Add MongoDB and Slack configuration schemas for validation - Introduced `mongoDatabase.ts` and `slack.ts` files containing configuration schemas for MongoDB and Slack integration. - Updated `index.ts` to include the new schemas in the validation process. These changes enhance the environment validation by incorporating MongoDB and Slack configurations, ensuring proper setup for integration. --- workers/main/src/configs/index.ts | 4 ++++ workers/main/src/configs/mongoDatabase.ts | 15 +++++++++++++++ workers/main/src/configs/slack.ts | 11 +++++++++++ 3 files changed, 30 insertions(+) create mode 100644 workers/main/src/configs/mongoDatabase.ts create mode 100644 workers/main/src/configs/slack.ts diff --git a/workers/main/src/configs/index.ts b/workers/main/src/configs/index.ts index b3179e4..4ffe476 100644 --- a/workers/main/src/configs/index.ts +++ b/workers/main/src/configs/index.ts @@ -1,8 +1,12 @@ +import { mongoDatabaseSchema } from './mongoDatabase'; import { redmineDatabaseSchema } from './redmineDatabase'; +import { slackSchema } from './slack'; import { temporalSchema } from './temporal'; import { workerSchema } from './worker'; export const validationResult = temporalSchema .merge(workerSchema) + .merge(slackSchema) .merge(redmineDatabaseSchema) + .merge(mongoDatabaseSchema) .safeParse(process.env); diff --git a/workers/main/src/configs/mongoDatabase.ts b/workers/main/src/configs/mongoDatabase.ts new file mode 100644 index 0000000..fb1ab22 --- /dev/null +++ b/workers/main/src/configs/mongoDatabase.ts @@ -0,0 +1,15 @@ +import { z } from 'zod'; + +export const mongoDatabaseConfig = { + host: process.env.MONGO_DB_HOST, + user: process.env.MONGO_DB_USER, + password: process.env.MONGO_DB_PASSWORD, + database: process.env.MONGO_DB_NAME, +}; + +export const mongoDatabaseSchema = z.object({ + MONGO_DB_HOST: z.string(), + MONGO_DB_USER: z.string(), + MONGO_DB_PASSWORD: z.string(), + MONGO_DB_NAME: z.string(), +}); diff --git a/workers/main/src/configs/slack.ts b/workers/main/src/configs/slack.ts new file mode 100644 index 0000000..3a00c94 --- /dev/null +++ b/workers/main/src/configs/slack.ts @@ -0,0 +1,11 @@ +import { z } from 'zod'; + +export const slackConfig = { + token: String(process.env.SLACK_TOKEN), + channelId: String(process.env.SLACK_FIN_REPORT_CHANNEL_ID), +}; + +export const slackSchema = z.object({ + SLACK_TOKEN: z.string(), + SLACK_FIN_REPORT_CHANNEL_ID: z.string(), +}); From 6d90d684deb0996d46dd31dba33871a00ffa6d75 Mon Sep 17 00:00:00 2001 From: "anatoly.shipitz" Date: Tue, 3 Jun 2025 16:49:09 +0200 Subject: [PATCH 2/2] fix: Update Slack configuration to directly use environment variables - Modified the Slack configuration to directly assign environment variables for `token` and `channelId` without converting them to strings. This change simplifies the configuration setup for Slack integration, ensuring that the environment variables are used as intended. --- workers/main/src/configs/slack.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workers/main/src/configs/slack.ts b/workers/main/src/configs/slack.ts index 3a00c94..80eba59 100644 --- a/workers/main/src/configs/slack.ts +++ b/workers/main/src/configs/slack.ts @@ -1,8 +1,8 @@ import { z } from 'zod'; export const slackConfig = { - token: String(process.env.SLACK_TOKEN), - channelId: String(process.env.SLACK_FIN_REPORT_CHANNEL_ID), + token: process.env.SLACK_TOKEN, + channelId: process.env.SLACK_FIN_REPORT_CHANNEL_ID, }; export const slackSchema = z.object({