Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const clusterWorkerSize = parseInt(process.env.CLUSTER_WORKERS, 10) || 1
const simultaneousWorkerRenders = parseInt(process.env.SIMULTANEOUS_RENDERS, 10) || 1
const renderProcessTimeout = parseInt(process.env.RENDER_PROCESS_TIMEOUT, 10) || 60
const renderJobTtl = (parseInt(process.env.RENDER_JOB_TTL, 10) || 30) * 1000
// Periodically clear stuck jobs
queue.watchStuckJobs()
// Report Kue stats to Librato
librato.configure({
email: process.env.LIBRATO_EMAIL,
token: process.env.LIBRATO_TOKEN,
source: process.env.DYNO,
})
librato.start()
librato.on('error', (err) => {
Honeybadger.notify(err)
console.error(err)
})
const libratoReporter = setInterval(() => {
queue.inactiveCount((err, total) => {
if (!err) {
librato.measure('kue.inactive.count', total)
}
})
queue.activeCount((err, total) => {
if (!err) {
librato.measure('kue.active.count', total)
}
})
queue.failedCount((err, total) => {
return data
}))
// Parse cookies (for determining to pre-render or not)
app.use(cookieParser())
// Send stats to Librato
librato.configure({
email: process.env.LIBRATO_EMAIL,
token: process.env.LIBRATO_TOKEN,
source: process.env.DYNO,
})
librato.start()
app.use(librato.middleware())
librato.on('error', (err) => {
console.log('[librato] ERROR', err)
})
// Use Helmet to lock things down
app.use(helmet())
const indexStr = fs.readFileSync(path.join(__dirname, './../../public/index.html'), 'utf-8')
const stats = JSON.parse(fs.readFileSync(path.join(__dirname, './../../webpack-stats/server.json'), 'utf-8'))
// Wire up OAuth route
addOauthRoute(app)
// Assets
app.use(express.static('public', { index: false, redirect: false }))
app.use('/static', express.static('public/static', { maxAge: '1y', index: false, redirect: false, fallthrough: false }))