Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async function serveReactRoute(req: $Request, res: $Response, next: NextFunction): Promise {
try {
const serverHooks = ServerHooks.map(hookModule => {
const HookClass = getDefault(hookModule);
return new HookClass();
});
try {
const acceptedLanguages = Object.freeze(accept.languages(req.header('Accept-Language')));
const loadableResources = new Map();
const persistentValues = new Map();
let component = (
{/* custom prop injected by universal-cookies */}
{/* $FlowFixMe */}
{rootRoute}
);
function findAcceptTypes(headers: ResponseHeaders) {
const headerKey = Object.keys(headers).find(name =>
new RegExp('^accept$', 'i').test(name),
);
return 'undefined' === typeof headerKey
? []
: accept.mediaTypes(headers[headerKey]);
}
/**
internals.common.forEach((header) => {
this._common.set(header, Accept.encoding(header, this.encodings));
});
}
accept(request) {
const header = request.headers['accept-encoding'];
if (!header) {
return 'identity';
}
const common = this._common.get(header);
if (common) {
return common;
}
try {
return Accept.encoding(header, this.encodings);
}
catch (err) {
Bounce.rethrow(err, 'system');
err.header = header;
request._log(['accept-encoding', 'error'], err);
return 'identity';
}
}