"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
var _nodeModuleLoader = require("../helpers/module-loader/node-module-loader");
var _routeModuleLoader = require("../helpers/module-loader/route-module-loader");
class RouteHandlerManager {
    constructor(moduleLoader = new _nodeModuleLoader.NodeModuleLoader()){
        this.moduleLoader = moduleLoader;
    }
    async handle(match, req, context) {
        // The module supports minimal mode, load the minimal module.
        const module = _routeModuleLoader.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;
    }
}
exports.RouteHandlerManager = RouteHandlerManager;

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