fix: stream errors -> 500, guard non-object body picks, test @query e2e

This commit is contained in:
chrnx committed 2026-06-26 01:51:02 -05:00
1 parent 7114bf685e
commit ccaacb9a02
3 files changed
+42 -14

No files matched your search

+18 -1
View File
@@ -4,7 +4,7 @@ import { Provider, Step, Route, Get, Module, Transformer } from '../src/metadata
import { JsonTransformer } from '../src/transformers';
import { Unauthorized } from '../src/signals';
import { createApp } from '../src/app';
import { needs, param } from '../src/params';
import { needs, param, query } from '../src/params';
@Provider({ provides: 'db' })
class Db { provide() { return { db: { find: (t: string) => (t === 'good' ? { id: 'u1' } : null) } }; } }
@@ -78,6 +78,23 @@ test('optional provider failure warns but does not abort boot', async () => {
warn.mockRestore();
});
test('handler receives @query value through a live request', async () => {
@Route('/search')
class SearchCtl {
@Get('/')
run(@query('q') q: string) { return { q }; }
}
@Module({ mountpoint: '/s', providers: [], steps: [], controllers: [SearchCtl] })
class SearchModule {}
const app = createApp({ modules: [SearchModule] });
const server = await app.listen(0);
const port = (server.address() as any).port;
const res = await fetch(`http://127.0.0.1:${port}/s/search/?q=hello`);
expect(await res.json()).toEqual({ q: 'hello' });
server.close();
});
test('boot fails when a handler needs something nothing provides', () => {
@Route('/things')
class ThingCtl {