Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 variantTextRoute = require('./variantText');
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 @@ -105,6 +106,9 @@ class Routing extends RouterInterface {
// Global legend routes
this.router.use('/legend', legendRoute);

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

return true;
}
}
Expand Down
35 changes: 35 additions & 0 deletions app/routes/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2187,6 +2187,41 @@
}
}
},
"/therapeutic-targets": {
"get": {
"summary": "Get All Therapeutic Targets",
"description": "Returns all therapeutic targets across all reports. Admin only.",
"tags": [
"Therapeutic Targets"
],
"security": [
{
"basicAuth": []
}
],
"responses": {
"200": {
"description": "Returns all therapeutic targets across all reports",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/therapeuticTargetAssociations"
}
}
}
}
},
"401": {
"$ref": "#/components/responses/UnauthorizedError"
},
"403": {
"description": "User does not have permission to access this endpoint (admin only)"
}
}
}
},
"/project/{project}/therapeutic-targets": {
"get": {
"summary": "Get All Therapeutic Targets For a Project",
Expand Down
32 changes: 32 additions & 0 deletions app/routes/therapeuticTargets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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: [['reportId', 'ASC'], ['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