Function controllerCreator

  • Generates a configurable routes controller for the application to mount. It's configurable because the creator, instead of just being sent to the container to mount, it can also be called as a function with custom parameters the controller can receive.

    Type Parameters

    Parameters

    • creator: CreatorFn

      A function that will generate a controller.

    Returns ResourceCreator<"controller", "connect", CreatorFn, ControllerConnectFn>

    Example: Basic usage

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

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

    Example: Custom parameters

      container.mount('/pili', myController({ foo: 'bar' }));
    

Generated using TypeDoc