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

Function resolveCtx

src/server/cli.ts:114–129  ·  view source on GitHub ↗
(
    wsIdParam: string,
    exportParam: string,
  )

Source from the content-addressed store, hash-verified

112
113 /** Shared workspace+export resolution for both routes. */
114 const resolveCtx = (
115 wsIdParam: string,
116 exportParam: string,
117 ):
118 | { ok: true; exp: CliExport; ws: WsMeta }
119 | { ok: false; status: 404 | 503; error: string } => {
120 const ws = resolveWs(wsIdParam)
121 if ('error' in ws) {
122 return ws.error === 'unavailable'
123 ? { ok: false, status: 503, error: 'workspace service unavailable' }
124 : { ok: false, status: 404, error: 'unknown workspace' }
125 }
126 const exp = getExport(exportParam)
127 if (!exp) return { ok: false, status: 404, error: `unknown CLI export: ${exportParam}` }
128 return { ok: true, exp, ws: ws.meta }
129 }
130
131 app.get('/cli/:wsId/:export/manifest', (c) => {
132 const r = resolveCtx(c.req.param('wsId'), c.req.param('export'))

Callers 1

registerCliRoutesFunction · 0.85

Calls 2

resolveWsFunction · 0.85
getExportFunction · 0.85

Tested by

no test coverage detected