snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
1
examples/lit/basic/config/port.d.ts
vendored
Normal file
1
examples/lit/basic/config/port.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const DEMO_PORT: number
|
||||
22
examples/lit/basic/config/port.js
Normal file
22
examples/lit/basic/config/port.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const DEFAULT_DEMO_PORT = 4173
|
||||
const envPort = process.env.DEMO_PORT
|
||||
|
||||
function resolvePort() {
|
||||
if (!envPort) {
|
||||
return DEFAULT_DEMO_PORT
|
||||
}
|
||||
|
||||
const parsedPort = Number.parseInt(envPort, 10)
|
||||
const isValidPort =
|
||||
Number.isInteger(parsedPort) && parsedPort > 0 && parsedPort <= 65535
|
||||
|
||||
if (!isValidPort) {
|
||||
throw new Error(
|
||||
`Invalid DEMO_PORT "${envPort}". Expected an integer between 1 and 65535.`,
|
||||
)
|
||||
}
|
||||
|
||||
return parsedPort
|
||||
}
|
||||
|
||||
export const DEMO_PORT = resolvePort()
|
||||
Reference in New Issue
Block a user