Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/middleware/acl.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ const SPECIAL_CASES = [
PUT: [{name: 'admin'}, {name: 'manager'}, {name: 'appendix edit access'}],
DELETE: [{name: 'admin'}, {name: 'manager'}, {name: 'appendix edit access'}],
},
{
path: pathToRegexp('/api/therapeutic-targets'),
GET: [{name: 'admin'}],
},
{
path: pathToRegexp('/api/project'),
POST: [{name: 'admin'}, {name: 'manager'}, {name: 'create project access'}],
Expand Down
4 changes: 4 additions & 0 deletions app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
const templateRoute = require('./template');
const appendixRoute = require('./appendix');
const legendRoute = require('./legend');
const therapeuticTargetsRoute = require('./therapeuticTargets');

// Get module route files
const RouterInterface = require('./routingInterface');
Expand Down Expand Up @@ -104,6 +105,9 @@

// Global legend routes
this.router.use('/legend', legendRoute);

Check failure on line 108 in app/routes/index.js

View workflow job for this annotation

GitHub Actions / eslint

Trailing spaces not allowed
// Get therapeutic targets routes (all reports)
this.router.use('/therapeutic-targets', therapeuticTargetsRoute);
Comment thread
Copilot marked this conversation as resolved.

return true;
}
Expand Down
30 changes: 30 additions & 0 deletions app/routes/therapeuticTargets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const HTTP_STATUS = require('http-status-codes');
const express = require('express');

const db = require('../models');
const logger = require('../log');

const router = express.Router({mergeParams: true});

// Get all therapeutic targets across all reports (admin only, enforced in ACL middleware)
router.route('/')
.get(async (req, res) => {
try {
const results = await db.models.therapeuticTarget.scope('public').findAll({
order: [['rank', 'ASC']],
include: [
Comment thread
Copilot marked this conversation as resolved.
{
model: db.models.report,
as: 'report',
attributes: ['ident'],
},
],
});
return res.json(results);
} catch (error) {
logger.error(`Unable to retrieve therapeutic targets ${error}`);
return res.status(HTTP_STATUS.INTERNAL_SERVER_ERROR).json({error: {message: 'Unable to retrieve therapeutic targets'}});
}
});

module.exports = router;
Loading