| 19 | // real port. Fixed ports must stay below 32768: the Linux ephemeral range |
| 20 | // (32768-60999) is contested by every concurrent suite's outbound sockets. |
| 21 | const parsePort = (input: string | undefined): number => { |
| 22 | if (input === undefined) return 5434; |
| 23 | if (!/^\d+$/.test(input)) throw new Error("CLOUD_TEST_DB_PORT must be an integer"); |
| 24 | const port = Number(input); |
| 25 | if (!Number.isSafeInteger(port) || port > 65_535) { |
| 26 | throw new Error("CLOUD_TEST_DB_PORT must be between 0 and 65535"); |
| 27 | } |
| 28 | return port; |
| 29 | }; |
| 30 | |
| 31 | const PORT = parsePort(process.env.CLOUD_TEST_DB_PORT); |
| 32 | const MIGRATIONS_FOLDER = resolve(__dirname, "../drizzle"); |