import { ControllerDefinition, Controller } from "../../types"; import { ApplicationManager } from "./index"; export declare class BackendController extends ApplicationManager { /** * Registers a new controller. * * Http routes will be auto-generated unless they are provided or an empty array * is provided. * * @param name - Controller name * @param definition - Controller definition * * @example * app.controller.register('greeting', { * actions: { * sayHello: { * handler: async request => `Hello, ${request.input.args.name}`, * http: [{ verb: 'post', path: 'greeting/hello/:name' }] * } * } * }) * */ register(name: string, definition: ControllerDefinition): void; /** * Uses a new controller class. * * The controller class must: * - call the super constructor with the application instance * - extend the "Controller" class * - define the "definition" property * - (optional) define the "name" property * * The controller name will be inferred from the class name. * e.g. "PaymentSolutionController" will become "payment-solution" * * @example * * class EmailController extends Controller { * constructor (app) { * super(app); * * this.definition = { * actions: { * send: { * handler: this.send * http: [{ * verb: 'post', * path: 'email/send/:object', * openapi: { * description: "Send an email", * parameters: [{ * in: "path", * name: "object", * schema: { * type: "string" * }, * required: true, * }], * responses: { * 200: { * description: "Acknowledgement", * content: { * "application/json": { * schema: { * type: "string", * } * } * } * } * } * } * }] * } * } * }; * } * * async send (request: Request) { * // ... * } * } * * app.controller.use(new EmailController(app)); * * @param controller Controller class */ use(controller: Controller): void; /** * Adds the controller definition to the list of application controllers. * * This method also check if the definition is valid to throw with a stacktrace * beginning on the user code adding the controller. */ private add; }