PeerTube/server/controllers/api/server/stats.ts

25 lines
672 B
TypeScript
Raw Normal View History

2021-08-27 14:32:44 +02:00
import express from 'express'
2020-12-15 13:34:58 +01:00
import { StatsManager } from '@server/lib/stat-manager'
2019-04-11 11:33:44 +02:00
import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
2020-12-15 13:34:58 +01:00
import { asyncMiddleware } from '../../../middlewares'
import { cacheRoute } from '../../../middlewares/cache/cache'
2018-02-28 18:04:46 +01:00
const statsRouter = express.Router()
statsRouter.get('/stats',
cacheRoute(ROUTE_CACHE_LIFETIME.STATS),
2018-02-28 18:04:46 +01:00
asyncMiddleware(getStats)
)
2020-12-15 13:34:58 +01:00
async function getStats (_req: express.Request, res: express.Response) {
const data = await StatsManager.Instance.getStats()
2018-02-28 18:04:46 +01:00
2020-12-15 13:34:58 +01:00
return res.json(data)
2018-02-28 18:04:46 +01:00
}
// ---------------------------------------------------------------------------
export {
statsRouter
}