MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / parsePort

Function parsePort

scripts/guardian/shared.ts:73–79  ·  view source on GitHub ↗
(raw: unknown, origin: string)

Source from the content-addressed store, hash-verified

71}
72
73function parsePort(raw: unknown, origin: string): number {
74 const n = typeof raw === 'number' ? raw : Number(raw)
75 if (!Number.isInteger(n) || n < 1 || n > 65535) {
76 throw new Error(`[guardian] invalid port ${JSON.stringify(raw)} from ${origin} — expected an integer in 1..65535`)
77 }
78 return n
79}
80
81/**
82 * Read `data/config/ports.json` under `userDataHome`. Missing file → {}.

Callers 2

readPortsFileFunction · 0.70
pickFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected