Open
Description
What is the problem this feature would solve?
If you do not wait in the router.modules.then controller, even if you put the wait on the main router, these routers will still not be loaded
If you use a controller that registers using use(import()), then if you do not wait for instance.modules, then these routers are loaded and will not be installed. I would like to add a .ready() method that would return a promise returning the current instance after instance.modules.then()
What is the feature you are proposing to solve the problem?
// get-by-id.command.ts
import { Elysia, t } from 'elysia';
export default new Elysia().get(
'/:id',
() => {
return { id: 1 };
},
{
params: t.Object({
id: t.Integer({ example: 1 }),
}),
}
);
// controller.ts
import { Elysia } from 'elysia';
export const controller = new Elysia({ prefix: '/bug' }).use(
import('./get-by-id.command.ts')
);
// may be .ready(): Promise<Elysia> ?
// work
// await controller.modules;
// work But it cannot be used in .use without additional wrapping
export const asyncController = controller.modules.then(() => controller)
// not work
// export default controller;
// work
export default asyncController
// main.ts
import { swagger } from '@elysiajs/swagger';
import { Elysia } from 'elysia';
const app = new Elysia()
.use(swagger({provider: 'swagger-ui', path: '/docs'}))
.use(import('./controller.ts'))
.listen(3000)
What alternatives have you considered?
import { Elysia } from 'elysia';
export const controller = new Elysia({ prefix: '/bug' }).use(
import('./get-by-id.command.ts')
).ready();
export default controller;