refactor: migrate from Rollup to Bun for build configuration
feat: update adapter to use globalThis for origin resolution fix: remove unused ClientQuery export from query.ts chore: update tsconfig to include test files and set rootDir feat: add create-query functionality for dynamic API generation feat: implement QueryApi with enhanced type inference from JSON Schema test: add comprehensive API tests for QueryApi functionality test: create demo routes and schemas for testing purposes docs: add type inference demo for QueryApi usage
This commit is contained in:
26
test/common.ts
Normal file
26
test/common.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { app } from './router.ts';
|
||||
import util from 'node:util';
|
||||
import fs from 'node:fs'
|
||||
import { createQueryByRoutes } from '../src/create-query/index.ts';
|
||||
export const showMore = (data: any) => {
|
||||
return util.inspect(data, { depth: null, colors: true });
|
||||
}
|
||||
const routes = await app.run({ path: 'router', key: 'list' })
|
||||
// console.log('rourtes', showMore(routes.data.list));
|
||||
const list = routes.data.list
|
||||
|
||||
const obj: any = {}
|
||||
|
||||
for (const route of list) {
|
||||
if (!obj[route.path]) {
|
||||
obj[route.path] = {};
|
||||
}
|
||||
obj[route.path][route.key] = route;
|
||||
}
|
||||
|
||||
// console.log('obj', showMore(obj));
|
||||
|
||||
const code = createQueryByRoutes(list);
|
||||
|
||||
fs.writeFileSync('test/query.ts', code, 'utf-8');
|
||||
|
||||
Reference in New Issue
Block a user