33 lines
3.7 KiB
JavaScript
33 lines
3.7 KiB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
import ApplicationComponent from "../ApplicationComponent";
|
|
import express from "express";
|
|
export default class ServeStaticDirectoryComponent extends ApplicationComponent {
|
|
constructor(root, routePath) {
|
|
super();
|
|
this.root = root;
|
|
this.path = routePath;
|
|
}
|
|
start(app, router) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (typeof this.path !== 'undefined') {
|
|
router.use(this.path, express.static(this.root, { maxAge: 1000 * 3600 * 72 }));
|
|
}
|
|
else {
|
|
router.use(express.static(this.root, { maxAge: 1000 * 3600 * 72 }));
|
|
}
|
|
});
|
|
}
|
|
stop() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
});
|
|
}
|
|
}
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2VydmVTdGF0aWNEaXJlY3RvcnlDb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvU2VydmVTdGF0aWNEaXJlY3RvcnlDb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsT0FBTyxvQkFBb0IsTUFBTSx5QkFBeUIsQ0FBQztBQUMzRCxPQUFPLE9BQTBCLE1BQU0sU0FBUyxDQUFDO0FBR2pELE1BQU0sQ0FBQyxPQUFPLE9BQU8sNkJBQ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