Open PandaWorker opened 3 months ago
I don't want to use a lot of nesting add returning new instance in group & guard if not callback run param
I want it to work like this
import { Elysia, t } from 'elysia'; import { swagger } from '@elysiajs/swagger'; // default scope (guard return new instance) const router = new Elysia().guard({ type: 'application/json', detail: { tags: ['Public'], }, headers: t.Object({ 'x-device-id': t.String(), }), cookie: t.Cookie({ at: t.String() }), response: { 401: t.Object({ code: t.String(), }), }, }); // links scope (group return new instance ) const links = router .group('/links', { beforeHandle: [ (r) => { console.log(r); }, ], }) .get('/', () => ''); const catalog = router .group('/catalog') .get('/', () => []) .get('/:productId', () => ({})); const publicApi = new Elysia() .use(links) .use(catalog) const app = new Elysia({ prefix: '/api' }).use(setup).use(publicApi);
This solution helps to use a more flexible composition
No response
This feature is very useful. Any Update on this?
What is the problem this feature would solve?
I don't want to use a lot of nesting add returning new instance in group & guard if not callback run param
I want it to work like this
What is the feature you are proposing to solve the problem?
This solution helps to use a more flexible composition
What alternatives have you considered?
No response