import { NodeModuleLoader } from "../helpers/module-loader/node-module-loader";
import { RouteModuleLoader } from "../helpers/module-loader/route-module-loader";
export class RouteHandlerManager {
    constructor(moduleLoader = new NodeModuleLoader()){
        this.moduleLoader = moduleLoader;
    }
    async handle(match, req, context) {
        // The module supports minimal mode, load the minimal module.
        const module = RouteModuleLoader.load(match.definition.filename, this.moduleLoader);
        // Setup the handler. It is the responsibility of the module to ensure that
        // this is only called once. If this is in development mode, the require
        // cache will be cleared and the module will be re-created.
        module.setup();
        // Get the response from the handler.
        const response = await module.handle(req, context);
        // Send the response back.
        return response;
    }
}

//# sourceMappingURL=route-handler-manager.js.map