Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const hasCustomFavicon = await list.reduce(async (acc, [route, location]) => {
const fullLocation = path.resolve(location);
if (!(await fs.pathExists(fullLocation))) {
logger.error(`Error: no such directory to load static files: "${fullLocation}"`);
} else {
// TODO should be part of server
progress.emit('server', {
message: `adding static files from: "${location}", routing at "${route}"`,
details: [location, route],
});
}
app.use(express.static(fullLocation, { index: false }));
// if route is root and we haven't found a favicon before and this one contains a favicon
if (route === '/' && !(await acc) && (await containsFavicon(fullLocation))) {
app.use(favicon(faviconLocation(fullLocation)));
return true;
}
return acc;
}, Promise.resolve(false));