UNPKG

@nova-ts/core

Version:

A serverside framework used to build scalable application

34 lines (33 loc) 1.2 kB
// src/Resolver/NovaControllerInvoker.ts var NovaControllerInvoker = class { constructor(instance, route, handler, resolver) { this.instance = instance; this.route = route; this.handler = handler; this.resolver = resolver; } /** * Invokes the target controller method, resolving its arguments dynamically. * * This method handles: * - Parameter injection via decorators (e.g., `@Request`, `@RequestBody`, etc.) * - Async controller method support * - Error propagation using `next()` * * If the controller method returns a result and the response hasn't been sent yet, * the result is automatically sent using `res.send(result)`. * * @param {any} req - The Express request object. * @param {any} res - The Express response object. * @param {any} next - The Express next function for error propagation. * @returns {Promise<any>} A promise that resolves once the controller method is invoked. */ async invoke(req, res, next) { const args = this.resolver.resolveArgument(this.instance, this.route, req, res, next); return await this.handler(...args); } }; export { NovaControllerInvoker }; //# sourceMappingURL=chunk-CUJD4MC2.js.map