kopia lustrzana https://github.com/badgen/badgen.net
chore: more stats info
rodzic
02b9a0dd9f
commit
e65c0acd2a
|
@ -33,7 +33,10 @@ const apiHandlers = Object.entries(liveFunctions).map(([name, fn]) => {
|
|||
})
|
||||
|
||||
const indexContent = fs.readFileSync(path.join(__dirname, 'index-api.md'), 'utf8')
|
||||
const serveIndex = (req, res) => send(res, 200, indexContent)
|
||||
const serveIndex = (req, res) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=60, s-maxage=86400')
|
||||
send(res, 200, indexContent)
|
||||
}
|
||||
|
||||
module.exports = router()(
|
||||
get('/', serveIndex),
|
||||
|
|
|
@ -5,8 +5,14 @@ const livePool = require('./live-pool.js')
|
|||
module.exports = async (req, res) => {
|
||||
const [githubRateLimit] = await Promise.all([getGithubRateLimit()])
|
||||
const fetching = Object.values(livePool.list()).filter(Boolean).length
|
||||
const cpuUsage = process.cpuUsage()
|
||||
const memUsage = process.memoryUsage()
|
||||
|
||||
send(res, 200, { githubRateLimit, fetching })
|
||||
const stats = { githubRateLimit, fetching, cpuUsage, memUsage }
|
||||
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8')
|
||||
res.setHeader('Cache-Control', 'public, max-age=1, s-maxage=1')
|
||||
send(res, 200, JSON.stringify(stats, null, 2))
|
||||
}
|
||||
|
||||
const getGithubRateLimit = () => {
|
||||
|
|
Ładowanie…
Reference in New Issue