Skip to content

Commit

Permalink
convert to async/await (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellp authored Jun 2, 2021
1 parent b132269 commit 6c72660
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
14 changes: 6 additions & 8 deletions src/api/routes/gem2s.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ const { expressAuthorizationMiddleware } = require('../../utils/authMiddlewares'
module.exports = {
'gem2s#create': [
expressAuthorizationMiddleware,
(req, res, next) => {
createGem2SPipeline(req.params.experimentId)
.then((data) => {
const experimentService = new ExperimentService();
experimentService.saveGem2sHandle(req.params.experimentId, data)
.then(() => res.json(data));
})
.catch(next);
async (req, res) => {
const data = await createGem2SPipeline(req.params.experimentId);

const experimentService = new ExperimentService();
await experimentService.saveGem2sHandle(req.params.experimentId, data);
res.json(data);
},
],

Expand Down
20 changes: 8 additions & 12 deletions src/api/routes/pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,20 @@ const { expressAuthorizationMiddleware } = require('../../utils/authMiddlewares'
module.exports = {
'pipelines#get': [
expressAuthorizationMiddleware,
(req, res, next) => {
async (req, res) => {
// The changes to add gem2s status will be obsoleted once agi's PR is merged in
getBackendStatus(req.params.experimentId)
.then((data) => res.json(data))
.catch(next);
const data = await getBackendStatus(req.params.experimentId);
res.json(data);
},
],
'pipelines#create': [
(req, res, next) => {
async (req, res) => {
const { processingConfig } = req.body;

createQCPipeline(req.params.experimentId, processingConfig || [])
.then((data) => {
const experimentService = new ExperimentService();
experimentService.saveQCHandle(req.params.experimentId, data)
.then(() => res.json(data));
})
.catch(next);
const data = await createQCPipeline(req.params.experimentId, processingConfig || []);
const experimentService = new ExperimentService();
await experimentService.saveQCHandle(req.params.experimentId, data);
res.json(data);
},
],
'pipelines#response': async (req, res) => {
Expand Down

0 comments on commit 6c72660

Please sign in to comment.