UNPKG

@o3r/configuration

Version:

This module contains configuration-related features such as CMS compatibility, Configuration override, store and debugging. It enables your application runtime configuration and comes with an integrated ng builder to help you generate configurations suppo

20 lines 943 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.bootstrapConfigMiddleware = void 0; const cheerio = require("cheerio"); // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- no type are provided for express-interceptor // @ts-ignore const expressInterceptor = require("express-interceptor"); /** * Injects bootstrapconfig inside the body dataset to get all debug/override capabilities on a local development server */ const bootstrapConfigMiddleware = () => expressInterceptor((_req, res) => ({ isInterceptable: () => /text\/html/.test(res.get('Content-Type')), intercept: (body, send) => { const file = cheerio.load(body); file('body').attr('data-bootstrapconfig', JSON.stringify({ allowParamOverride: true })); send(file.html()); } })); exports.bootstrapConfigMiddleware = bootstrapConfigMiddleware; //# sourceMappingURL=bootstrap-config.middleware.js.map