Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
res.status(500).end(error.stack + epilogue);
});
}
});
if (config.port) {
http.createServer(app).listen(config.port, (err) => {
if (err) {
console.error(err);
} else {
console.log(`Express server listening on port ${config.port}`);
}
});
// Cache thumbnail responses from YouTube in memory.
const woden = new Woden({});
woden.when(/i.ytimg.com/, {
cacheTimeout: function(cacheEntry, req, proxyRes) {
if (cacheEntry.body.length > (30 * 1024)) {
return -1; // don't cache large responses
}
if (proxyRes.statusCode !== 200) {
return -1; // only cache successful responses
}
const minutesToCache = 10;
return minutesToCache * 60 * 1000;
}
});
woden.listen(config.youtubeProxyPort, (err) => {
if (err) {