]>
Commit | Line | Data |
---|---|---|
4d4e5cd4 | 1 | import * as express from 'express' |
571389d4 | 2 | import { getFormattedObjects } from '../../helpers' |
e02643f3 | 3 | import { database as db } from '../../initializers/database' |
571389d4 | 4 | import { asyncMiddleware, paginationValidator, podsSortValidator, setPagination, setPodsSort } from '../../middlewares' |
65fcc311 C |
5 | |
6 | const podsRouter = express.Router() | |
7 | ||
8a02bd04 C |
8 | podsRouter.get('/', |
9 | paginationValidator, | |
10 | podsSortValidator, | |
11 | setPodsSort, | |
12 | setPagination, | |
eb080476 | 13 | asyncMiddleware(listPods) |
65fcc311 | 14 | ) |
65fcc311 C |
15 | |
16 | // --------------------------------------------------------------------------- | |
17 | ||
18 | export { | |
19 | podsRouter | |
20 | } | |
21 | ||
22 | // --------------------------------------------------------------------------- | |
23 | ||
eb080476 C |
24 | async function listPods (req: express.Request, res: express.Response, next: express.NextFunction) { |
25 | const resultList = await db.Pod.listForApi(req.query.start, req.query.count, req.query.sort) | |
26 | ||
27 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | |
65fcc311 | 28 | } |