radius-read
Version:
Realtime Dashboard
33 lines • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebAppService = void 0;
const tslib_1 = require("tslib");
const express_1 = tslib_1.__importDefault(require("express"));
const path_1 = tslib_1.__importDefault(require("path"));
/**
* WebAppService is a service class that serves static files for a web application.
*/
class WebAppService {
/**
* Creates an instance of WebAppService.
* @param config
*/
constructor(config) {
this.config = config;
}
/**
* Initializes the WebAppService with the provided Express application.
* @param app
*/
init(app, logger) {
logger === null || logger === void 0 ? void 0 : logger.debug(`WebAppService >>> Initializing web application service with config: ${JSON.stringify(this.config)}`);
logger === null || logger === void 0 ? void 0 : logger.debug(`WebAppService >>> Serving static files from directory: ${this.config.defaultDir}`);
logger === null || logger === void 0 ? void 0 : logger.debug(`WebAppService >>> Serving static files from directory: ${path_1.default.join(this.config.defaultDir, this.config.defaultFile)}`);
app.use(this.config.defaultContext, express_1.default.static(this.config.defaultDir));
app.get(`*`, (req, res) => {
res.sendFile(path_1.default.join(this.config.defaultDir, this.config.defaultFile));
});
}
}
exports.WebAppService = WebAppService;
//# sourceMappingURL=webapp.service.js.map