// Uses the generated Api the way a frontend would; compiled by the generator test. import { createClient } from '@avijs/client'; import type { Api } from './api.gen.js'; type Equal = (() => T extends A ? 1 : 2) extends () => T extends B ? 1 : 2 ? true : false; const expectType = (_: Equal) => undefined; const api = createClient({ baseUrl: 'http://localhost:3000' }); export async function use() { const list = await api.get('/users', { query: { page: '1' } }); expectType(true); const one = await api.get('/users/:id', { params: { id: 1 } }); expectType(true); const created = await api.post('/users', { body: { name: 'Shiela' } }); expectType(true); const item = await api.put('/api/items/:id', { params: { id: 'a' }, body: { name: 'b' } }); expectType(true); const removed = await api.delete('/api/items/:id', { params: { id: 'a' } }); expectType(true); // @ts-expect-error not part of the Api: the controller is not exported await api.get('/api/hidden'); }