From 9065f6749077ff46500573e9e834e8ae9156fea4 Mon Sep 17 00:00:00 2001 From: aswin Date: Fri, 31 Jul 2026 00:43:40 +0530 Subject: [PATCH 1/4] feat(docker): Add Dockerfile and docker-compose for development environment --- .dockerignore | 5 +++++ Dockerfile.dev | 23 +++++++++++++++++++++++ docker-compose.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile.dev create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..480d85b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +dist +.env +.git +*.log \ No newline at end of file diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..f329d74 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,23 @@ +FROM node:24-alpine + +WORKDIR /app + +# Doppler CLI so we can run `doppler run --` inside the container +RUN apk add --no-cache curl gnupg \ + && curl -Ls https://cli.doppler.com/install.sh | sh + +# pnpm via corepack (ships with node 20, no separate install needed) +RUN corepack enable && corepack prepare pnpm@latest --activate + +COPY package.json pnpm-lock.yaml ./ +COPY prisma ./prisma + +RUN pnpm install + +COPY . . + +RUN npx prisma generate + +EXPOSE 3000 + +CMD ["pnpm", "dev"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fab684e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +services: + postgres: + image: postgres:16-alpine + environment: + POSTGRES_USER: guidway + POSTGRES_PASSWORD: guidway + POSTGRES_DB: guidway + volumes: + - pgdata:/var/lib/postgresql/data + + redis: + image: redis:7-alpine + + backend: + build: + context: . + dockerfile: Dockerfile.dev + environment: + DOPPLER_TOKEN: ${DOPPLER_TOKEN} + volumes: + - .:/app + - /app/node_modules + ports: + - "3000:3000" + depends_on: + - postgres + - redis + +volumes: + pgdata: + +# services: +# backend: +# build: +# context: . +# dockerfile: Dockerfile.dev +# environment: +# DOPPLER_TOKEN: ${DOPPLER_TOKEN} +# extra_hosts: +# - "host.docker.internal:host-gateway" +# volumes: +# - .:/app +# - /app/node_modules +# ports: +# - "3000:3000" From 918d34f0caa8fde6f6a790732223378fc506dfcf Mon Sep 17 00:00:00 2001 From: aswin Date: Fri, 31 Jul 2026 00:43:46 +0530 Subject: [PATCH 2/4] feat(redis): Integrate Redis URL configuration into redisClient setup --- src/config/env.ts | 5 +++++ src/infrastructure/database/redisClient.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config/env.ts b/src/config/env.ts index 30af4b6..8cc13f2 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -2,6 +2,8 @@ import { z } from "zod"; const envSchema = z.object({ DATABASE_URL: z.url("DATABASE_URL must be a valid connection string"), + REDIS_URL: z.url("Redis url must be a valid connection string"), + NODE_ENV: z .enum(["development", "production", "test"]) .default("development"), @@ -57,6 +59,9 @@ export class EnvConfig { static get NODE_ENV(): string { return parsedEnv.NODE_ENV; } + static get REDIS_URL(): string { + return parsedEnv.REDIS_URL; + } static get RAZORPAY_KEY_ID(): string { return parsedEnv.RAZORPAY_KEY_ID; } diff --git a/src/infrastructure/database/redisClient.ts b/src/infrastructure/database/redisClient.ts index c8be860..3e26a90 100644 --- a/src/infrastructure/database/redisClient.ts +++ b/src/infrastructure/database/redisClient.ts @@ -1,6 +1,7 @@ +import { EnvConfig } from "@config/env"; import { createClient } from "redis"; -export const redisClient = createClient(); +export const redisClient = createClient({ url: EnvConfig.REDIS_URL }); redisClient.on("error", (err) => console.error("Redis Client Error", err)); redisClient.on("connect", () => From bb755ff152ea9758bba068c267adac87709831b6 Mon Sep 17 00:00:00 2001 From: aswin Date: Fri, 31 Jul 2026 02:23:04 +0530 Subject: [PATCH 3/4] feat(docker): Expose ports for PostgreSQL and Redis services in docker-compose --- docker-compose.yml | 4 ++++ .../useCases/booking/CreateBookingIntent.usecase.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index fab684e..704b31b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,11 +5,15 @@ services: POSTGRES_USER: guidway POSTGRES_PASSWORD: guidway POSTGRES_DB: guidway + ports: + - "5434:5432" volumes: - pgdata:/var/lib/postgresql/data redis: image: redis:7-alpine + ports: + - "6380:6379" backend: build: diff --git a/src/application/useCases/booking/CreateBookingIntent.usecase.ts b/src/application/useCases/booking/CreateBookingIntent.usecase.ts index d20486e..40fd66c 100644 --- a/src/application/useCases/booking/CreateBookingIntent.usecase.ts +++ b/src/application/useCases/booking/CreateBookingIntent.usecase.ts @@ -30,7 +30,7 @@ export class CreateBookingIntentUsecase implements ICreateBookingIntentUsecase { data.startTime, data.endTime, ); - + console.log("mentor vailable", availability); if (!availability) { throw new ConflictError("Mentor is unavailable for the requested time"); } From f723430b4feff1f1922d73bedf7c15b4062db780 Mon Sep 17 00:00:00 2001 From: aswin Date: Sat, 1 Aug 2026 20:07:53 +0530 Subject: [PATCH 4/4] feat(booking): refactor booking repository and controller for improved readability and maintainability --- Dockerfile.dev | 4 ++-- src/presentation/controllers/booking/booking.controller.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index f329d74..4061d6c 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -6,7 +6,7 @@ WORKDIR /app RUN apk add --no-cache curl gnupg \ && curl -Ls https://cli.doppler.com/install.sh | sh -# pnpm via corepack (ships with node 20, no separate install needed) +# pnpm via corepack (ships with node 24, no separate install needed) RUN corepack enable && corepack prepare pnpm@latest --activate COPY package.json pnpm-lock.yaml ./ @@ -16,7 +16,7 @@ RUN pnpm install COPY . . -RUN npx prisma generate +RUN pnpm exec prisma generate EXPOSE 3000 diff --git a/src/presentation/controllers/booking/booking.controller.ts b/src/presentation/controllers/booking/booking.controller.ts index cd729a0..9ead236 100644 --- a/src/presentation/controllers/booking/booking.controller.ts +++ b/src/presentation/controllers/booking/booking.controller.ts @@ -78,7 +78,7 @@ export class BookingController implements IBookingController { const result = await this._createBookingIntentUsecase.execute(userId, data); res - .status(201) + .status(HTTPSTATUS.CREATED) .json(createSuccess("Booking intent created successfully", result)); };