import * as express from 'express'
-import { asyncMiddleware, jobsSortValidator, setJobsSort, setPagination } from '../../middlewares'
-import { paginationValidator } from '../../middlewares/validators/pagination'
-import { database as db } from '../../initializers'
-import { getFormattedObjects } from '../../helpers/utils'
-import { authenticate } from '../../middlewares/oauth'
-import { ensureUserHasRight } from '../../middlewares/user-right'
-import { UserRight } from '../../../shared/models/users/user-right.enum'
+import { UserRight } from '../../../shared/models/users'
+import { getFormattedObjects } from '../../helpers'
+import { asyncMiddleware, authenticate, ensureUserHasRight, jobsSortValidator, setJobsSort, setPagination } from '../../middlewares'
+import { paginationValidator } from '../../middlewares/validators'
+import { JobModel } from '../../models/job/job'
const jobsRouter = express.Router()
// ---------------------------------------------------------------------------
async function listJobs (req: express.Request, res: express.Response, next: express.NextFunction) {
- const resultList = await db.Job.listForApi(req.query.start, req.query.count, req.query.sort)
+ const resultList = await JobModel.listForApi(req.query.start, req.query.count, req.query.sort)
return res.json(getFormattedObjects(resultList.data, resultList.total))
}