1
0
Fork 0
peertube/server/controllers/api/requests.js

38 lines
1 KiB
JavaScript
Raw Normal View History

2016-09-19 15:33:46 -04:00
'use strict'
const express = require('express')
const constants = require('../../initializers/constants')
2016-12-11 15:50:51 -05:00
const db = require('../../initializers/database')
const middlewares = require('../../middlewares')
2016-09-19 15:33:46 -04:00
const admin = middlewares.admin
const oAuth = middlewares.oauth
const router = express.Router()
router.get('/stats',
oAuth.authenticate,
admin.ensureIsAdmin,
getStatsRequests
)
// ---------------------------------------------------------------------------
module.exports = router
// ---------------------------------------------------------------------------
function getStatsRequests (req, res, next) {
2016-12-11 15:50:51 -05:00
db.Request.countTotalRequests(function (err, totalRequests) {
2016-09-19 15:33:46 -04:00
if (err) return next(err)
return res.json({
2016-12-11 15:50:51 -05:00
totalRequests: totalRequests,
requestsLimitPods: constants.REQUESTS_LIMIT_PODS,
requestsLimitPerPod: constants.REQUESTS_LIMIT_PER_POD,
2016-12-11 15:50:51 -05:00
remainingMilliSeconds: db.Request.remainingMilliSeconds(),
2016-09-23 11:09:38 -04:00
milliSecondsInterval: constants.REQUESTS_INTERVAL
2016-09-19 15:33:46 -04:00
})
})
}