function ngExpressEngine(setupOptions) {
    const engine = new CommonEngine(setupOptions.bootstrap, setupOptions.providers);
    return function (filePath, options, callback) {
        var _a, _b, _c, _d;
        try {
            const renderOptions = Object.assign({}, options);
            if (!setupOptions.bootstrap && !renderOptions.bootstrap) {
                throw new Error('You must pass in a NgModule or NgModuleFactory to be bootstrapped');
            }
            const req = renderOptions.req;
            const res = renderOptions.res || req.res;
            renderOptions.url =
                renderOptions.url || `${req.protocol}://${req.get('host') || ''}${req.originalUrl}`;
            renderOptions.documentFilePath = renderOptions.documentFilePath || filePath;
            renderOptions.providers = [...(renderOptions.providers || []), getReqResProviders(req, res)];
            (renderOptions.publicPath =
                (_b = (_a = renderOptions.publicPath) !== null && _a !== void 0 ? _a : setupOptions.publicPath) !== null && _b !== void 0 ? _b : (_c = options.settings) === null || _c === void 0 ? void 0 : _c.views),
                (renderOptions.inlineCriticalCss =
                    (_d = renderOptions.inlineCriticalCss) !== null && _d !== void 0 ? _d : setupOptions.inlineCriticalCss);
            engine
                .render(renderOptions)
                .then((html) => callback(null, html))
                .catch(callback);
        }
        catch (err) {
            callback(err);
        }
    };
}
/**
 * This is an express engine for handling Angular Applications
 */
This is an express engine for handling Angular Applications
This is an express engine for handling Angular Applications
function ngExpressEngine(setupOptions) {
    const engine = new CommonEngine(setupOptions.bootstrap, setupOptions.providers);
    return function (filePath, options, callback) {
        var _a, _b, _c, _d;
        try {
            const renderOptions = Object.assign({}, options);
            if (!setupOptions.bootstrap && !renderOptions.bootstrap) {
                throw new Error('You must pass in a NgModule or NgModuleFactory to be bootstrapped');
            }
            const req = renderOptions.req;
            const res = renderOptions.res || req.res;
            renderOptions.url =
                renderOptions.url || `${req.protocol}://${req.get('host') || ''}${req.originalUrl}`;
            renderOptions.documentFilePath = renderOptions.documentFilePath || filePath;
            renderOptions.providers = [...(renderOptions.providers || []), getReqResProviders(req, res)];
            (renderOptions.publicPath =
                (_b = (_a = renderOptions.publicPath) !== null && _a !== void 0 ? _a : setupOptions.publicPath) !== null && _b !== void 0 ? _b : (_c = options.settings) === null || _c === void 0 ? void 0 : _c.views),
                (renderOptions.inlineCriticalCss =
                    (_d = renderOptions.inlineCriticalCss) !== null && _d !== void 0 ? _d : setupOptions.inlineCriticalCss);
            engine
                .render(renderOptions)
                .then((html) => callback(null, html))
                .catch(callback);
        }
        catch (err) {
            callback(err);
        }
    };
}
function ngExpressEngine ( setupOptions ) { const engine = new CommonEngine ( setupOptions . bootstrap , setupOptions . providers ) ; return function ( filePath , options , callback ) { var _a , _b , _c , _d ; try { const renderOptions = Object . assign ( { } , options ) ; if ( ! setupOptions . bootstrap && ! renderOptions . bootstrap ) { throw new Error ( 'You must pass in a NgModule or NgModuleFactory to be bootstrapped' ) ; } const req = renderOptions . req ; const res = renderOptions . res || req . res ; renderOptions . url = renderOptions . url || ` ${ req . protocol } ${ req . get ( 'host' ) || '' } ${ req . originalUrl } ` ; renderOptions . documentFilePath = renderOptions . documentFilePath || filePath ; renderOptions . providers = [ ... ( renderOptions . providers || [ ] ) , getReqResProviders ( req , res ) ] ; ( renderOptions . publicPath = ( _b = ( _a = renderOptions . publicPath ) !== null && _a !== void 0 ? _a : setupOptions . publicPath ) !== null && _b !== void 0 ? _b : ( _c = options . settings ) === null || _c === void 0 ? void 0 : _c . views ) , ( renderOptions . inlineCriticalCss = ( _d = renderOptions . inlineCriticalCss ) !== null && _d !== void 0 ? _d : setupOptions . inlineCriticalCss ) ; engine . render ( renderOptions ) . then ( ( html ) => callback ( null , html ) ) . catch ( callback ) ; } catch ( err ) { callback ( err ) ; } } ; }
This is an express engine for handling Angular Applications
This is an express engine for handling Angular Applications