refactor(db): update environment configuration, enhance TypeScript su… - #37
Conversation
…pport, and improve seed data structure - Removed the .env.docker file to streamline environment variable management. - Updated package.json to export the main index file. - Enhanced seed.ts by importing AuthType and using it for type safety in merchantsData. - Modified the database connection to include SSL configuration based on the environment. - Adjusted tsconfig.json to specify root directory and include additional TypeScript files for better compilation.
There was a problem hiding this comment.
Pull request overview
This PR refactors the database configuration and enhances TypeScript support across the monorepo. The changes streamline environment variable management by removing Docker-specific configurations, improve type safety in seed data, add SSL support for database connections, and remove the Razorpay payment provider dependency in favor of a custom implementation.
Key Changes:
- Enhanced TypeScript configuration for the database package with improved include patterns and compilation settings
- Improved type safety in seed data by importing and using the AuthType enum
- Added SSL configuration for database connections based on environment
- Removed Razorpay dependency and replaced with custom payment verification logic
- Cleaned up unused routes, files, and removed emoji characters from user-facing messages
Reviewed changes
Copilot reviewed 43 out of 46 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
packages/db/tsconfig.json |
Updated TypeScript configuration with rootDir and expanded include patterns |
packages/db/prisma/seed.ts |
Added AuthType import for type safety and SSL configuration for database connection |
packages/db/package.json |
Added export for main index file |
packages/db/.env.docker |
Removed Docker-specific environment configuration |
apps/user-app/tsconfig.json |
Removed deprecated ignoreDeprecations option |
apps/user-app/package.json |
Removed Razorpay dependency |
apps/user-app/next.config.js |
Added database package to transpilePackages and configured webpack externals for PostgreSQL |
apps/user-app/lib/redis.ts |
Added console logging for Redis connection errors |
apps/user-app/components/*.tsx |
Removed emoji characters from user-facing messages |
apps/user-app/app/api/verify-payment/route.ts |
Replaced Razorpay verification with custom implementation |
apps/user-app/app/api/rewards/*.ts |
Updated reward amounts and scratch card values |
apps/user-app/app/api/health/route.ts |
Updated health check response message |
apps/user-app/app/(dashboard)/*.tsx |
Cleaned up unused variables and removed empty pages |
apps/user-app/app/home/page.tsx |
Refactored HoverBorderGradient component usage |
apps/merchant-app/package.json |
Updated React version and removed Razorpay dependency |
apps/merchant-app/next.config.js |
Enhanced webpack configuration for database support |
apps/merchant-app/build.log |
Added build log file (should not be in version control) |
apps/merchant-app/app/*.tsx |
Added error handling pages and cleaned up component code |
apps/merchant-app/app/api/bills/*.ts |
Updated to use shared Prisma client instance |
apps/bank-webhook/src/*.ts |
Updated imports and adjusted reward calculation logic |
apps/bank-webhook/package.json |
Added dotenv dependency |
Comments suppressed due to low confidence (1)
packages/db/.env.docker:1
- The removed
.env.dockerfile contained a hardcoded database connection string with an inline password inDATABASE_URL, which exposes credentials directly in source control and to anyone with repository access. Even though this change is removing the secret, this pattern is dangerous because it allows easy credential theft and reuse across environments. Ensure all credentials are stored only in secure secret management systems or environment variables outside of version control, and rotate this database password since it was previously committed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <HoverBorderGradient onClick={() => router.push("/dashboard")}> | ||
| Go to Dashboard | ||
| </HoverBorderGradient> | ||
| )} | ||
| {status === "unauthenticated" && ( | ||
| <HoverBorderGradient onClick={() => router.push("/auth/signup")}> | ||
| Get Started |
There was a problem hiding this comment.
The HoverBorderGradient component is being used with an onClick prop, but it should wrap interactive content (like a button element) instead. This approach may cause accessibility issues as the component might not have proper button semantics (role, keyboard handling, etc.). The component should either wrap a button element or be properly configured to handle interactive behavior accessibly.
| <HoverBorderGradient onClick={() => router.push("/dashboard")}> | |
| Go to Dashboard | |
| </HoverBorderGradient> | |
| )} | |
| {status === "unauthenticated" && ( | |
| <HoverBorderGradient onClick={() => router.push("/auth/signup")}> | |
| Get Started | |
| <HoverBorderGradient> | |
| <button type="button" onClick={() => router.push("/dashboard")}> | |
| Go to Dashboard | |
| </button> | |
| </HoverBorderGradient> | |
| )} | |
| {status === "unauthenticated" && ( | |
| <HoverBorderGradient> | |
| <button type="button" onClick={() => router.push("/auth/signup")}> | |
| Get Started | |
| </button> |
| import { authOptions } from '@/app/lib/auth'; | ||
|
|
||
| const SCRATCH_AMOUNTS = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]; | ||
| const SCRATCH_AMOUNTS = [1, 2, 3, 4, 5, 6, 7,8, 9, 10]; |
There was a problem hiding this comment.
Missing space after comma in the array definition. This creates inconsistent formatting and reduces code readability.
| const SCRATCH_AMOUNTS = [1, 2, 3, 4, 5, 6, 7,8, 9, 10]; | |
| const SCRATCH_AMOUNTS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; |
|
|
||
| import db from "@repo/db/client"; | ||
| import { RewardType, RewardStatus } from "@prisma/client"; | ||
| import prisma from "@repo/db"; |
There was a problem hiding this comment.
The import statement uses '@repo/db' instead of '@repo/db/client'. This is inconsistent with the rest of the codebase and may cause runtime errors if the package.json exports are not properly configured. The standard import pattern used elsewhere is 'import prisma from "@repo/db/client"'.
| import prisma from "@repo/db"; | |
| import prisma from "@repo/db/client"; |
| <HoverBorderGradient | ||
| as="button" | ||
| className={`${!isFormValid ? "opacity-50 cursor-not-allowed pointer-events-none" : ""}`} | ||
| > | ||
| Add via {paymentMethod.label} | ||
| </HoverBorderGradient> |
There was a problem hiding this comment.
The as prop is being used on HoverBorderGradient component along with a className for disabled state. However, the disabled functionality has been removed from the DialogTrigger. This approach may not properly prevent interaction when the form is invalid, as CSS pointer-events-none doesn't prevent keyboard navigation or programmatic clicks. Consider re-implementing proper disabled state handling or using a proper button element with the disabled attribute.
| <HoverBorderGradient onClick={() => router.push("/dashboard")}> | ||
| Go to Dashboard | ||
| </HoverBorderGradient> | ||
| )} | ||
| {status === "unauthenticated" && ( | ||
| <HoverBorderGradient onClick={() => router.push("/auth/signup")}> | ||
| Get Started |
There was a problem hiding this comment.
The HoverBorderGradient component is being used with an onClick prop, but it should wrap interactive content (like a button element) instead. This approach may cause accessibility issues as the component might not have proper button semantics (role, keyboard handling, etc.). The component should either wrap a button element or be properly configured to handle interactive behavior accessibly.
| <HoverBorderGradient onClick={() => router.push("/dashboard")}> | |
| Go to Dashboard | |
| </HoverBorderGradient> | |
| )} | |
| {status === "unauthenticated" && ( | |
| <HoverBorderGradient onClick={() => router.push("/auth/signup")}> | |
| Get Started | |
| <HoverBorderGradient> | |
| <button | |
| type="button" | |
| onClick={() => router.push("/dashboard")} | |
| > | |
| Go to Dashboard | |
| </button> | |
| </HoverBorderGradient> | |
| )} | |
| {status === "unauthenticated" && ( | |
| <HoverBorderGradient> | |
| <button | |
| type="button" | |
| onClick={() => router.push("/auth/signup")} | |
| > | |
| Get Started | |
| </button> |
| <HoverBorderGradient onClick={() => router.push("/dashboard")}> | ||
| Go to Dashboard | ||
| </HoverBorderGradient> | ||
| )} | ||
| {status === "unauthenticated" && ( | ||
| <HoverBorderGradient onClick={() => router.push("/auth/signup")}> | ||
| Get Started |
There was a problem hiding this comment.
The HoverBorderGradient component is being used with an onClick prop, but it should wrap interactive content (like a button element) instead. This approach may cause accessibility issues as the component might not have proper button semantics (role, keyboard handling, etc.). The component should either wrap a button element or be properly configured to handle interactive behavior accessibly.
| <HoverBorderGradient onClick={() => router.push("/dashboard")}> | |
| Go to Dashboard | |
| </HoverBorderGradient> | |
| )} | |
| {status === "unauthenticated" && ( | |
| <HoverBorderGradient onClick={() => router.push("/auth/signup")}> | |
| Get Started | |
| <HoverBorderGradient> | |
| <button type="button" onClick={() => router.push("/dashboard")}> | |
| Go to Dashboard | |
| </button> | |
| </HoverBorderGradient> | |
| )} | |
| {status === "unauthenticated" && ( | |
| <HoverBorderGradient> | |
| <button type="button" onClick={() => router.push("/auth/signup")}> | |
| Get Started | |
| </button> |
| const expectedSignature = crypto | ||
| .createHmac("sha256", process.env.RAZORPAY_KEY_SECRET!) | ||
| .update(`${razorpay_order_id}|${razorpay_payment_id}`) | ||
| .createHmac("sha256", "test-secret") |
There was a problem hiding this comment.
Hardcoded secret "test-secret" is a critical security vulnerability. This should be replaced with an environment variable (e.g., process.env.PAYMENT_WEBHOOK_SECRET). Hardcoded secrets can be easily compromised and make it impossible to rotate credentials without code changes.
| eslint: { | ||
| ignoreDuringBuilds: false, |
There was a problem hiding this comment.
Setting eslint.ignoreDuringBuilds to false means builds will fail on ESLint errors. While this enforces code quality, it should be coordinated with the team as it represents a breaking change to the build process. Consider starting with warnings or fixing existing ESLint errors before enforcing this.
| <HoverBorderGradient onClick={() => router.push("/dashboard")}> | ||
| Go to Dashboard | ||
| </HoverBorderGradient> | ||
| )} | ||
| {status === "unauthenticated" && ( | ||
| <HoverBorderGradient onClick={() => router.push("/auth/signup")}> | ||
| Get Started |
There was a problem hiding this comment.
The HoverBorderGradient component is being used with an onClick prop, but it should wrap interactive content (like a button element) instead. This approach may cause accessibility issues as the component might not have proper button semantics (role, keyboard handling, etc.). The component should either wrap a button element or be properly configured to handle interactive behavior accessibly.
| <HoverBorderGradient onClick={() => router.push("/dashboard")}> | |
| Go to Dashboard | |
| </HoverBorderGradient> | |
| )} | |
| {status === "unauthenticated" && ( | |
| <HoverBorderGradient onClick={() => router.push("/auth/signup")}> | |
| Get Started | |
| <HoverBorderGradient> | |
| <button | |
| type="button" | |
| onClick={() => router.push("/dashboard")} | |
| > | |
| Go to Dashboard | |
| </button> | |
| </HoverBorderGradient> | |
| )} | |
| {status === "unauthenticated" && ( | |
| <HoverBorderGradient> | |
| <button | |
| type="button" | |
| onClick={() => router.push("/auth/signup")} | |
| > | |
| Get Started | |
| </button> |
| @@ -1,4 +1,34 @@ | |||
| /** @type {import('next').NextConfig} */ | |||
| const path = require('path'); | |||
There was a problem hiding this comment.
Unused variable path.
| const path = require('path'); |
…pport, and improve seed data structure