"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("./common");
exports.editorServer = function () {
    common_1.log.info.gray("Initializing " + common_1.log.magenta('editor.code') + " routes:\n");
    var router = common_1.express.router();
    var route = function (url, dir) {
        common_1.log.info.gray(" - route: " + common_1.log.cyan(url));
        common_1.log.info.gray(" - dir:   " + common_1.log.cyan(dir));
        common_1.log.info();
        router.get(url, function (req, res) {
            var path = req.params[0];
            if (path.indexOf('..') > -1) {
                return res.status(404).send('Not Found');
            }
            var file = common_1.fsPath.join(dir, path);
            if (common_1.constants.IS_DEV) {
                common_1.log.info(common_1.log.magenta('GET'), common_1.log.cyan(req.url));
                common_1.log.info.gray("    " + file);
                common_1.log.info();
            }
            return res.sendFile(file);
        });
    };
    route(common_1.constants.URL.BASE + "/*", common_1.constants.EDITOR_RESOURCES.LOCAL);
    route("/vs/*", common_1.constants.VS.SOURCE);
    return router;
};
//# sourceMappingURL=middleware.js.map