fix: resolve apiProxy via ctx.get for /model (v0.3.2)
Cordis throws on ctx.apiProxy without inject; use ctx.get and declare apiProxy inject so catalog and model APIs work under dsh web. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { resolveApiProxy } from '../src/apiproxy.ts'
|
||||
|
||||
test('resolveApiProxy uses ctx.get and avoids bare ctx.apiProxy', () => {
|
||||
const api = { sessions: {} }
|
||||
let touchedBare = false
|
||||
const ctx = {
|
||||
get(name: string) {
|
||||
return name === 'apiProxy' ? api : undefined
|
||||
},
|
||||
get apiProxy() {
|
||||
touchedBare = true
|
||||
throw new Error('cannot get property "apiProxy" without inject')
|
||||
},
|
||||
}
|
||||
assert.equal(resolveApiProxy(ctx as any), api)
|
||||
assert.equal(touchedBare, false)
|
||||
})
|
||||
|
||||
test('resolveApiProxy falls back to own-property mock', () => {
|
||||
const api = { sessions: {} }
|
||||
const ctx = { apiProxy: api }
|
||||
assert.equal(resolveApiProxy(ctx as any), api)
|
||||
})
|
||||
Reference in New Issue
Block a user