Open History to see the last commit
1const DEFAULT_DEMO_PORT = 4173
2const envPort = process.env.DEMO_PORT
3β
4function resolvePort() {
5 if (!envPort) {
6 return DEFAULT_DEMO_PORT
7 }
8β
9 const parsedPort = Number.parseInt(envPort, 10)
10 const isValidPort =
11 Number.isInteger(parsedPort) && parsedPort > 0 && parsedPort <= 65535
12β
13 if (!isValidPort) {
14 throw new Error(
15 `Invalid DEMO_PORT "${envPort}". Expected an integer between 1 and 65535.`,
16 )
17 }
18β
19 return parsedPort
20}
21β
22export const DEMO_PORT = resolvePort()