import type { App, Auth } from 'tapimo' describe('App.Endpoint', () => { // Smoke-test that `App.Endpoint` narrows to the inferred route surface so // `Auth.middleware.Options.overrides` keys are typed against // actual mounted routes. test('includes mounted routes and rejects unknown ones', () => { expectTypeOf<'GET /v1/tokens'>().toExtend() expectTypeOf<'GET /v1/tokens/:token'>().toExtend() expectTypeOf<'GET /v1/tokens/:symbol'>().toExtend() expectTypeOf<'GET /v1/addresses/:address/balances'>().toExtend() expectTypeOf<'GET /v1/blocks'>().toExtend() expectTypeOf<'GET /v1/blocks/:block'>().toExtend() expectTypeOf<'GET /v1/exchange/pairs'>().toExtend() expectTypeOf<'GET /v1/indexer/query'>().toExtend() expectTypeOf<'POST /rpc/:chain'>().toExtend() expectTypeOf<'GET /v1/bogus'>().not.toExtend() // The mounted routes are GET-only; other verbs must not appear. expectTypeOf<'POST /v1/indexer/query'>().not.toExtend() expectTypeOf<'POST /v1/tokens'>().not.toExtend() expectTypeOf<'POST /v1/tokens/:token'>().not.toExtend() expectTypeOf<'DELETE /v1/tokens/:token'>().not.toExtend() }) test('flows through `Auth.middleware.Options.overrides` keys', () => { // `satisfies` gives a compile error if a route name is misspelled, // removed, or refers to an HTTP method the route doesn't declare. const _options = { overrides: { 'GET /v1/tokens': { public: false }, 'GET /v1/tokens/:symbol': { public: false }, 'GET /v1/tokens/:token': { public: false }, 'GET /v1/indexer/query': { apiKey: { scopes: ['indexer:query'] } }, 'POST /rpc/:chain': { apiKey: { scopes: ['data:read'] } }, }, } satisfies Auth.middleware.Options void _options }) })