Open History to see the last commit
1const DEFAULT_DEMO_PORT = 4183
2const DEFAULT_API_PORT = 4184
3β
4function readPortFromEnv(name, fallback) {
5 const rawValue = process.env[name]
6 if (!rawValue) {
7 return fallback
8 }
9β
10 const parsed = Number.parseInt(rawValue, 10)
11 const valid = Number.isInteger(parsed) && parsed >= 1 && parsed <= 65535
12β
13 if (!valid) {
14 throw new Error(
15 `Invalid ${name}="${rawValue}". Expected integer in [1, 65535].`,
16 )
17 }
18β
19 return parsed
20}
21β
22export const DEMO_PORT = readPortFromEnv(
23 'PAGINATION_DEMO_PORT',
24 DEFAULT_DEMO_PORT,
25)
26export const API_PORT = readPortFromEnv('PAGINATION_API_PORT', DEFAULT_API_PORT)