Elysia
Your Elysia routes query the pool directly. If you also want CRUD routes for many entities without writing them, mount the HTTP handler. Elysia is fetch-native, so nothing else is needed.
Your own routes
Section titled “Your own routes”import { Elysia } from 'elysia';import { Post } from './shared/models/index.js';import { pool } from './uql.config.js';
new Elysia() .get('/posts', () => pool.findMany(Post, { $where: { published: true }, $limit: 20 }), ) .listen(3000); // Bun; on Node, `new Elysia({ adapter: node() })` from @elysiajs/nodeThe pool shows the uql.config.ts it comes from. Run several writes together in pool.transaction.
Auto-generated CRUD
Section titled “Auto-generated CRUD”import { cors } from '@elysiajs/cors';import { Elysia } from 'elysia';import { createFetchHandler } from 'uql-orm/http';import { Post, User } from './shared/models/index.js';import { pool } from './uql.config.js';
const handler = createFetchHandler({ pool, include: [User, Post] });
new Elysia().use(cors()).mount('/api', handler).listen(3000);.mount() strips the prefix, forwards every method and leaves the body unparsed, so this serves the wire protocol, QUERY included. An unknown route under /api is a 404 from the handler.
Hooks and tenant scoping are the handler’s: see hooks and getContext. Their context is the web Request.
Eden Treaty cannot see mounted routes, so it keeps covering your own routes only. Use the browser client for the CRUD routes.