Skip to content

Commit

Permalink
Merge pull request #1 from Ferlab-Ste-Justine/feat/cqdg-825
Browse files Browse the repository at this point in the history
feat: CQDG-825 create extendedMapping endpoint
  • Loading branch information
atoulous authored Aug 15, 2024
2 parents f2fb80f + c1b5af6 commit 7e06965
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 29 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cqdg-wrapper-next",
"version": "2.0.15",
"version": "2.0.16",
"description": ":factory: a data-model aware GraphQL API that sits above an Elasticsearch cluster",
"main": "src/index.js",
"type": "module",
Expand Down
7 changes: 6 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { Keycloak } from 'keycloak-connect';
import NodeCache from 'node-cache';

import packageJson from '../package.json' assert { type: 'json' };
import { cacheTTL, esHost, keycloakURL, maxSetContentSize, usersApiURL } from './config/env';
import { cacheTTL, esHost, isDev, keycloakURL, maxSetContentSize, usersApiURL } from './config/env';
import { getExtendedMapping } from './endpoints/extendedMapping';
import genomicFeatureSuggestions, { SUGGESTIONS_TYPES } from './endpoints/genomicFeatureSuggestions';
import { getPhenotypesNodes } from './endpoints/phenotypes';
import { getStatistics } from './endpoints/statistics';
Expand Down Expand Up @@ -143,6 +144,10 @@ const buildApp = (keycloak: Keycloak): Express => {
return res.send({ data });
});

app.get('/extendedMapping/:index', keycloak.protect(), async (req, res) => {
return getExtendedMapping(req, res);
});

app.use(globalErrorLogger, globalErrorHandler);

return app;
Expand Down
13 changes: 13 additions & 0 deletions src/endpoints/extendedMapping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Request, Response } from 'express';
import { StatusCodes } from 'http-status-codes';

import { getExtendedMappingByIndex } from '#src/utils';

export const getExtendedMapping = async (req: Request, res: Response) => {
const graphqlIndex = req.params.index;
const extendedMapping = getExtendedMappingByIndex(graphqlIndex);

return res.status(StatusCodes.OK).send({
extendedMapping,
});
};
25 changes: 0 additions & 25 deletions src/graphql/README.md

This file was deleted.

6 changes: 6 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ import studyExtendedMapping from '#src/graphql/study/extendedMapping';
export const getExtendedMappingByIndex = (graphqlIndex = '') => {
switch (graphqlIndex) {
case 'Participant':
case 'participant':
return participantExtendedMapping;
case 'Biospecimen':
case 'biospecimen':
return sampleExtendedMapping;
case 'File':
case 'file':
return fileExtendedMapping;
case 'Variant':
case 'variant':
return variantExtendedMapping;
case 'Gene':
case 'gene':
return geneExtendedMapping;
case 'Study':
case 'study':
return studyExtendedMapping;
}
};
Expand Down

0 comments on commit 7e06965

Please sign in to comment.