UNPKG

webserv

Version:

a quick, flexible, fully typed development server

36 lines 1.84 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "path", "../../core/log", "../../core/services/file.service"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = require("path"); const log_1 = require("../../core/log"); const file_service_1 = require("../../core/services/file.service"); exports.bootFileService = (config, { configPath }) => { const { routes = {}, basePath } = config, extraConfig = __rest(config, ["routes", "basePath"]); const absolutePath = basePath ? path_1.resolve(configPath, basePath) : path_1.resolve(configPath); return Object.entries(routes).map(([key, path]) => { const mappingBasePath = path_1.join(absolutePath, path); log_1.log.debug(`Serving mapping ${key} to ${mappingBasePath}`); return file_service_1.fileService(Object.assign(Object.assign({}, extraConfig), { route: key, basePath: mappingBasePath })); }); }; }); //# sourceMappingURL=file.js.map