1
0
Fork 0
peertube/server/controllers/api/pods.ts

29 lines
890 B
TypeScript
Raw Normal View History

2017-06-05 15:53:49 -04:00
import * as express from 'express'
2017-11-10 11:27:49 -05:00
import { getFormattedObjects } from '../../helpers'
2017-05-22 14:58:25 -04:00
import { database as db } from '../../initializers/database'
2017-11-10 11:27:49 -05:00
import { asyncMiddleware, paginationValidator, podsSortValidator, setPagination, setPodsSort } from '../../middlewares'
2017-05-15 16:22:03 -04:00
const podsRouter = express.Router()
podsRouter.get('/',
paginationValidator,
podsSortValidator,
setPodsSort,
setPagination,
2017-10-25 05:55:06 -04:00
asyncMiddleware(listPods)
2017-05-15 16:22:03 -04:00
)
// ---------------------------------------------------------------------------
export {
podsRouter
}
// ---------------------------------------------------------------------------
2017-10-25 05:55:06 -04:00
async function listPods (req: express.Request, res: express.Response, next: express.NextFunction) {
const resultList = await db.Pod.listForApi(req.query.start, req.query.count, req.query.sort)
return res.json(getFormattedObjects(resultList.data, resultList.total))
2017-05-15 16:22:03 -04:00
}