[PR #5671] [MERGED] chore: add sslmode support to PrismaService database URL parser #5309

Closed
opened 2026-03-17 02:46:05 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5671
Author: @mirarifhasan
Created: 12/7/2025
Status: Merged
Merged: 12/10/2025
Merged by: @mirarifhasan

Base: patchHead: fix/db-url-sslMode


📝 Commits (3)

  • 5a31786 chore: add sslmode support to PrismaService database URL parser
  • dec432c refactor: SSL configuration for database connections
  • 948a46d chore: add 'allow' to SSL mode check in PrismaService

📊 Changes

2 files changed (+88 additions, -28 deletions)

View changed files

📝 packages/hoppscotch-backend/src/mock-server/mock-server.service.spec.ts (+20 -15)
📝 packages/hoppscotch-backend/src/prisma/prisma.service.ts (+68 -13)

📄 Description

Closes BE-680

What's changed

This pull request primarily refactors the PrismaService to improve parsing and handling of the DATABASE_URL environment variable, with additional minor formatting improvements in the MockServerService test suite. The most significant change is enhanced support for connection options (like sslmode) in the database connection logic.

Database connection improvements:

  • Refactored PrismaService constructor and parseDatabaseUrl to more robustly extract and handle options from the DATABASE_URL, including schema, connection_limit, connect_timeout, and sslmode. Now, SSL is configured based on sslmode and all relevant options are parsed with safer type handling. [1] [2]

Notes to reviewers

Ass sslmode in the DATABASE_URL and see, if the backend server able to connect with DB or not

DATABASE_URL='postgresql://user:password@localhost:5432/hoppscotch?sslmode=require'

Summary by cubic

Add sslmode support to PrismaService’s DATABASE_URL parsing and connection setup. SSL is now configured per sslmode, addressing BE-680.

  • New Features

    • Parse sslmode, connection_limit, connect_timeout, and schema from DATABASE_URL (connect_timeout default is now 10s).
    • Configure pg Pool SSL per sslmode (require/prefer/allow -> rejectUnauthorized: false; verify-ca/verify-full -> true; disable/absent -> false).
    • Remove sslmode from the connection string and apply SSL via pg Pool options.
  • Refactors

    • Safer number parsing and minor formatting cleanups in mock-server tests.

Written for commit 948a46d97f. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5671 **Author:** [@mirarifhasan](https://github.com/mirarifhasan) **Created:** 12/7/2025 **Status:** ✅ Merged **Merged:** 12/10/2025 **Merged by:** [@mirarifhasan](https://github.com/mirarifhasan) **Base:** `patch` ← **Head:** `fix/db-url-sslMode` --- ### 📝 Commits (3) - [`5a31786`](https://github.com/hoppscotch/hoppscotch/commit/5a317860e830424498b5c9fd84ecb974701cd84f) chore: add sslmode support to PrismaService database URL parser - [`dec432c`](https://github.com/hoppscotch/hoppscotch/commit/dec432c84f40367e87b04e9caf309b7cbe4bf2fe) refactor: SSL configuration for database connections - [`948a46d`](https://github.com/hoppscotch/hoppscotch/commit/948a46d97f2cb9b956887c560a8c77bc851769bc) chore: add 'allow' to SSL mode check in PrismaService ### 📊 Changes **2 files changed** (+88 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-backend/src/mock-server/mock-server.service.spec.ts` (+20 -15) 📝 `packages/hoppscotch-backend/src/prisma/prisma.service.ts` (+68 -13) </details> ### 📄 Description <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> <!-- Issue # here --> Closes BE-680 <!-- Add an introduction into what this PR tries to solve in a couple of sentences --> ### What's changed <!-- Describe point by point the different things you have changed in this PR --> This pull request primarily refactors the `PrismaService` to improve parsing and handling of the `DATABASE_URL` environment variable, with additional minor formatting improvements in the `MockServerService` test suite. The most significant change is enhanced support for connection options (like `sslmode`) in the database connection logic. **Database connection improvements:** * Refactored `PrismaService` constructor and `parseDatabaseUrl` to more robustly extract and handle options from the `DATABASE_URL`, including `schema`, `connection_limit`, `connect_timeout`, and `sslmode`. Now, SSL is configured based on `sslmode` and all relevant options are parsed with safer type handling. [[1]](diffhunk://#diff-ccbdbf98ee64a256fef89bb52ac57b5d38f1907477754b69af0e51b13aff0410L16-R34) [[2]](diffhunk://#diff-ccbdbf98ee64a256fef89bb52ac57b5d38f1907477754b69af0e51b13aff0410R48-R84) <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Notes to reviewers <!-- Any information you feel the reviewer should know about when reviewing your PR --> Ass sslmode in the DATABASE_URL and see, if the backend server able to connect with DB or not ``` DATABASE_URL='postgresql://user:password@localhost:5432/hoppscotch?sslmode=require' ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add sslmode support to PrismaService’s DATABASE_URL parsing and connection setup. SSL is now configured per sslmode, addressing BE-680. - **New Features** - Parse sslmode, connection_limit, connect_timeout, and schema from DATABASE_URL (connect_timeout default is now 10s). - Configure pg Pool SSL per sslmode (require/prefer/allow -> rejectUnauthorized: false; verify-ca/verify-full -> true; disable/absent -> false). - Remove sslmode from the connection string and apply SSL via pg Pool options. - **Refactors** - Safer number parsing and minor formatting cleanups in mock-server tests. <sup>Written for commit 948a46d97f2cb9b956887c560a8c77bc851769bc. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:46:05 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5309
No description provided.