]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/controllers/api/server/stats.ts
Add new plugin/peertube version notifs
[github/Chocobozzz/PeerTube.git] / server / controllers / api / server / stats.ts
1 import * as express from 'express'
2 import { StatsManager } from '@server/lib/stat-manager'
3 import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
4 import { asyncMiddleware } from '../../../middlewares'
5 import { cacheRoute } from '../../../middlewares/cache'
6
7 const statsRouter = express.Router()
8
9 statsRouter.get('/stats',
10 asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.STATS)),
11 asyncMiddleware(getStats)
12 )
13
14 async function getStats (_req: express.Request, res: express.Response) {
15 const data = await StatsManager.Instance.getStats()
16
17 return res.json(data)
18 }
19
20 // ---------------------------------------------------------------------------
21
22 export {
23 statsRouter
24 }