Function controller

  • Generates a routes controller for the application container to mount.

    Parameters

    • connect: ControllerConnectFn

      A function that will be called the moment the application mounts the controller, and that is in charge of registering routes and middlewares.

    Returns Resource<"controller", "connect", ControllerConnectFn>

    Example

    const myController = controller((app) => {
    const router = app.getRouter();
    const ctrl = new MyController();
    return router.get('...', ctrl.doSomething()).post('...', ctrl.doSomethingElse());
    });

    // ...
    container.mount('/charo', myController);

Generated using TypeDoc