UNPKG

node-web-mvc

Version:
44 lines (43 loc) 1.53 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const CacheControl_1 = __importDefault(require("../http/CacheControl")); const ResourceChainRegistration_1 = __importDefault(require("./ResourceChainRegistration")); class ResourceHandlerRegistration { /** * 构造一个静态资源注册信息。 * @param pathPatterns */ constructor(pathPatterns) { this.resourceLocations = []; this.pathPatterns = pathPatterns || []; } /** * 添加静态资源搜索目录 * 路径可以为:绝对路径,或者相对路径,当路径为相对路径时,相对于应用启动路径 * ```js * * // 路径: path.resolve('static/web') * addResourceLocations('static/web'); * * // 绝对路径: * addResourceLocations(path.resolve('static/web')); * * ``` */ addResourceLocations(...resourceLocations) { this.resourceLocations.push(...resourceLocations); return this; } setCacheControl(options) { this.cacheControl = new CacheControl_1.default(options); return this; } resourceChain(cacheResources, cache) { this.resourceChainRegistration = new ResourceChainRegistration_1.default(cacheResources, cache); return this.resourceChainRegistration; } } exports.default = ResourceHandlerRegistration;