2019-10-02 22:02:13 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-04 01:35:18 +08:00
|
|
|
const bodyParser = require('./middlewares/body-parser');
|
|
|
|
const error = require('./middlewares/error');
|
2019-10-02 22:02:13 +08:00
|
|
|
|
|
|
|
module.exports = class JobsWipController {
|
|
|
|
constructor ({ jobService }) {
|
|
|
|
this.jobService = jobService;
|
|
|
|
}
|
|
|
|
|
|
|
|
route (apiRouter) {
|
|
|
|
apiRouter.get('/jobs-wip', [
|
2019-10-04 01:35:18 +08:00
|
|
|
bodyParser(),
|
2019-10-02 22:02:13 +08:00
|
|
|
listWorkInProgressJobs(this.jobService),
|
|
|
|
sendResponse(),
|
2019-10-04 01:35:18 +08:00
|
|
|
error()
|
2019-10-02 22:02:13 +08:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function listWorkInProgressJobs (jobService) {
|
|
|
|
return function listWorkInProgressJobsMiddleware (req, res, next) {
|
|
|
|
jobService.listWorkInProgressJobs((err, list) => {
|
|
|
|
if (err) {
|
|
|
|
return next(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
res.body = list;
|
|
|
|
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendResponse () {
|
|
|
|
return function sendResponseMiddleware (req, res) {
|
|
|
|
res.status(res.statusCode || 200).send(res.body);
|
|
|
|
};
|
|
|
|
}
|