From a003868b47d70a7eb2af9b3bb383c5ecb5f138f1 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Fri, 14 Mar 2025 15:18:48 +0700 Subject: [PATCH 1/2] fixing error redis --- src/interfaces/permission.ts | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/interfaces/permission.ts b/src/interfaces/permission.ts index b55d8e7..cfe76e6 100644 --- a/src/interfaces/permission.ts +++ b/src/interfaces/permission.ts @@ -184,12 +184,34 @@ class CheckAuth { }); } public async checkOrg(token: any, keycloakId: string) { - const redisClient = await this.redis.createClient({ - host: process.env.REDIS_HOST, - port: process.env.REDIS_PORT, - }); - const getAsync = promisify(redisClient.get).bind(redisClient); try { + // Validate required environment variables + const REDIS_HOST = process.env.REDIS_HOST; + const REDIS_PORT = process.env.REDIS_PORT ? Number(process.env.REDIS_PORT) : 6379; + + if (!REDIS_HOST) { + throw new Error("REDIS_HOST is not set in environment variables"); + } + + console.log(`[REDIS] Connecting to Redis at ${REDIS_HOST}:${REDIS_PORT}`); + + // Create Redis client + const redisClient = this.redis.createClient({ + socket: { + host: REDIS_HOST, + port: REDIS_PORT, + }, + }); + + redisClient.on("error", (err: any) => { + console.error("[REDIS] Connection error:", err.message); + }); + + await redisClient.connect(); + console.log("[REDIS] Connected successfully!"); + + const getAsync = promisify(redisClient.get).bind(redisClient); + let reply = await getAsync("org_" + keycloakId); if (reply != null) { reply = JSON.parse(reply); From a4ebb83184929b37ffe8147dd964b2728bddba09 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 14 Mar 2025 15:32:17 +0700 Subject: [PATCH 2/2] add pos exe --- src/controllers/DevelopmentController.ts | 1 + src/entities/PlannedGoalPosition.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index b2b7aaf..2cd5f30 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -2188,6 +2188,7 @@ export class DevelopmentController extends Controller { position: x.plannedGoalPositions.map((y) => ({ id: y.id, position: y.position, + posExecutive: y.posExecutive, posTypeId: y.posTypePlannedId, posType: y.posTypePlanned == null ? null : y.posTypePlanned.posTypeName, posLevelId: y.posLevelPlannedId, diff --git a/src/entities/PlannedGoalPosition.ts b/src/entities/PlannedGoalPosition.ts index 01a088c..990c977 100644 --- a/src/entities/PlannedGoalPosition.ts +++ b/src/entities/PlannedGoalPosition.ts @@ -13,6 +13,13 @@ export class PlannedGoalPosition extends EntityBase { }) position: string; + @Column({ + nullable: true, + comment: "ตำแหน่งทางการบริหาร", + default: null, + }) + posExecutive: string; + @Column({ nullable: true, comment: "ประเภทตำแหน่ง", @@ -51,6 +58,8 @@ export class CreatePlannedGoalPosition { @Column() position: string | null; @Column() + posExecutive: string | null; + @Column() posTypePlannedId: string | null; @Column() posLevelPlannedId: string | null;