"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const cli_core_1 = require("@bluebase/cli-core");
// tslint:disable-next-line:no-submodule-imports
const server_1 = require("react-dom/server");
const react_1 = __importDefault(require("react"));
const ServerHTML_1 = __importDefault(require("./ServerHTML"));
const logger = cli_core_1.Utils.logger;
exports.default = (request, response, configs) => {
    const ServerHTML = ServerHTML_1.default(configs);
    // Ensure a nonce has been provided to us.
    // See the server/middleware/security.js for more info.
    if (typeof response.locals.nonce !== 'string') {
        throw new Error('A "nonce" value has not been attached to the response');
    }
    const nonce = response.locals.nonce;
    if (process.env.BUILD_FLAG_IS_DEV === 'true') {
        logger.log({
            label: `@bluebase/cli/server`,
            level: 'info',
            message: `Handling react route without SSR: ${request.url}`,
        });
    }
    // SSR is disabled so we will return an "empty" html page and
    // rely on the client to initialize and render the react application.
    const simpleHtml = server_1.renderToStaticMarkup(react_1.default.createElement(ServerHTML, { nonce: nonce }));
    response.status(200).send(`<!DOCTYPE html>${simpleHtml}`);
    return;
};
//# sourceMappingURL=withoutSSR.js.map