Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions create-db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ dotenv.config();
const CLI_RUN_ID = randomUUID();

const CREATE_DB_WORKER_URL =
process.env.CREATE_DB_WORKER_URL.replace(/\/+$/, "") ||
"https://create-db-temp.prisma.io";
process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
const CLAIM_DB_WORKER_URL =
process.env.CLAIM_DB_WORKER_URL.replace(/\/+$/, "") ||
"https://create-db.prisma.io";
process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
Comment on lines 15 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Avoid double-slash endpoints after removing trailing-slash trim

Direct concat will produce URLs like ...//analytics if the env var ends with /. Many servers tolerate it, but some proxies/CDNs can 301/404 or log differently. Prefer URL-based joining to keep the “no replace” intent and be robust.

Apply this minimal change near the constants:

-const CREATE_DB_WORKER_URL =
-  process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
-const CLAIM_DB_WORKER_URL =
-  process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
+const CREATE_DB_WORKER_URL =
+  process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
+const CLAIM_DB_WORKER_URL =
+  process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
+const joinUrl = (base, pathOrQuery) => new URL(pathOrQuery, base).toString();

Then update call sites (examples):

  • fetch(joinUrl(CREATE_DB_WORKER_URL, "/analytics"), ...)
  • const healthUrl = joinUrl(CREATE_DB_WORKER_URL, "/health")
  • const url = joinUrl(CREATE_DB_WORKER_URL, "/regions")
  • fetch(joinUrl(CREATE_DB_WORKER_URL, "/create"), ...)
  • const claimUrl = joinUrl(CLAIM_DB_WORKER_URL, \?projectID=${projectId}&utm_source=${userAgent}&utm_medium=cli`)`

Quick check to run locally: set CREATE_DB_WORKER_URL with and without a trailing slash and verify no // appears in requests and no redirects occur.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const CREATE_DB_WORKER_URL =
process.env.CREATE_DB_WORKER_URL.replace(/\/+$/, "") ||
"https://create-db-temp.prisma.io";
process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
const CLAIM_DB_WORKER_URL =
process.env.CLAIM_DB_WORKER_URL.replace(/\/+$/, "") ||
"https://create-db.prisma.io";
process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
// src/create-db/index.js
const CREATE_DB_WORKER_URL =
process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
const CLAIM_DB_WORKER_URL =
process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
// Helper to robustly join a base URL and a path or query string without producing “//”
const joinUrl = (base, pathOrQuery) => new URL(pathOrQuery, base).toString();
🤖 Prompt for AI Agents
In create-db/index.js around lines 15-18 the constants are concatenated with
paths which can produce double-slash URLs if the env vars end with a trailing
slash; implement a small URL-joining helper (e.g., joinUrl(base, path) that
normalizes trailing/leading slashes or uses the URL API) and replace direct
concatenations at the listed call sites so calls become
fetch(joinUrl(CREATE_DB_WORKER_URL, "/analytics"), ...), const healthUrl =
joinUrl(CREATE_DB_WORKER_URL, "/health"), const url =
joinUrl(CREATE_DB_WORKER_URL, "/regions"), fetch(joinUrl(CREATE_DB_WORKER_URL,
"/create"), ...), and const claimUrl = joinUrl(CLAIM_DB_WORKER_URL,
`?projectID=${projectId}&utm_source=${userAgent}&utm_medium=cli`); verify
locally by setting the env vars with and without trailing slashes to ensure no
"//" appears and no redirects occur.


async function sendAnalyticsToWorker(eventName, properties) {
const controller = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion create-db/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-db",
"version": "1.0.5",
"version": "1.0.6",
"description": "Instantly create a temporary Prisma Postgres database with one command, then claim and persist it in your Prisma Data Platform project when ready.",
"main": "index.js",
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion create-pg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-pg",
"version": "1.0.5",
"version": "1.0.6",
"description": "Instantly create a temporary Prisma Postgres database with one command, then claim and persist it in your Prisma Data Platform project when ready.",
"main": "index.js",
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion create-postgres/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-postgres",
"version": "1.0.5",
"version": "1.0.6",
"description": "Instantly create a temporary Prisma Postgres database with one command, then claim and persist it in your Prisma Data Platform project when ready.",
"main": "index.js",
"author": "",
Expand Down