Skip to content

fix: remove hardcoded db url in prisma config - #59

Merged
JahnaviVeera merged 1 commit into
spotmies:masterfrom
JahnaviVeera:Jahnavi_Dev
Mar 21, 2026
Merged

JahnaviVeera merged 1 commit into
spotmies:masterfrom
JahnaviVeera:Jahnavi_Dev

Conversation

@JahnaviVeera

Copy link
Copy Markdown
Collaborator

No description provided.

@JahnaviVeera
JahnaviVeera merged commit f6b903c into spotmies:master Mar 21, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

🤖 AI Code Review

🤖 AI Code Review

📌 Summary

  • Improved security by replacing a hardcoded database URL with environment variables.
  • No major issues, but there are a couple of areas for improvement to ensure robustness and maintainability.

💬 Inline Comments (File-wise)

prisma.config.ts

  • Line 6: The new url value uses process.env.DATABASE_PUBLIC_URL || process.env.DATABASE_URL. While this is a good improvement over hardcoding, it lacks validation to ensure that one of these environment variables is set and valid.

    • ✅ Suggestion: Add a validation step to throw an error or log a warning if neither DATABASE_PUBLIC_URL nor DATABASE_URL is defined. For example:
      const databaseUrl = process.env.DATABASE_PUBLIC_URL || process.env.DATABASE_URL;
      if (!databaseUrl) {
          throw new Error("Database URL is not defined. Please set DATABASE_PUBLIC_URL or DATABASE_URL in the environment.");
      }
  • Line 6: Using process.env directly in the configuration file can make testing and debugging harder, as it tightly couples the configuration to the runtime environment.

    • ✅ Suggestion: Consider abstracting environment variable access into a separate configuration utility module. This makes it easier to mock or override values during testing.

⚠️ High-Risk Issues

  • Potential Misconfiguration: If neither DATABASE_PUBLIC_URL nor DATABASE_URL is set, the application may fail silently or behave unpredictably. This could lead to runtime errors or connection issues.
    • ✅ Mitigation: Add validation logic as suggested above to ensure at least one of the environment variables is defined.

No other high-risk issues found.


By addressing the above suggestions, you can improve the robustness and maintainability of your configuration file. Let me know if you need further assistance!


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants