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

Function parsePort

apps/desktop/src/main.ts:84–90  ·  view source on GitHub ↗
(raw: unknown, origin: string)

Source from the content-addressed store, hash-verified

82// or in-use explicit config fails loud.
83
84function parsePort(raw: unknown, origin: string): number {
85 const n = typeof raw === 'number' ? raw : Number(raw)
86 if (!Number.isInteger(n) || n < 1 || n > 65535) {
87 throw new Error(`[guardian] invalid port ${JSON.stringify(raw)} from ${origin} — expected an integer in 1..65535`)
88 }
89 return n
90}
91
92async function readPortsFile(userDataHome: string): Promise<Partial<Record<'web' | 'mcp' | 'uta', number>>> {
93 const filePath = resolve(userDataHome, 'data', 'config', 'ports.json')

Callers 3

readPortsFileFunction · 0.70
readMcpConfigFileFunction · 0.70
claimPortFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected