fix: returning 500 when getStatus failed

Signed-off-by: Raccoon <raccoon@hackmd.io>
This commit is contained in:
Raccoon 2020-05-17 03:25:57 +08:00
parent a3742e4564
commit ac6021a579
1 changed files with 8 additions and 3 deletions

View File

@ -4,14 +4,19 @@ const realtime = require('../realtime/realtime')
const config = require('../config')
exports.getStatus = async (req, res) => {
const data = await realtime.getStatus()
res.set({
'Cache-Control': 'private', // only cache by client
'X-Robots-Tag': 'noindex, nofollow', // prevent crawling
'Content-Type': 'application/json'
})
res.send(data)
try {
const data = await realtime.getStatus()
res.send(data)
} catch (e) {
console.error(e)
res.status(500).send(e.toString())
}
}
exports.getMetrics = async (req, res) => {