Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies, add cache config from env #8

Merged
merged 2 commits into from
Feb 16, 2024
Merged
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
5 changes: 4 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@

MATCHING_SERVICE_ENDPOINT=https://trialsapi.compositeapps.net/v1/trials/search
MATCHING_SERVICE_AUTH_TOKEN=""
MATCHING_SERVICE_PORT=3003
MATCHING_SERVICE_PORT=3003

# The cache file to use for clinical trial data cached from clinicaltrials.gov
CTGOV_CACHE_FILE=ctgov-cache.db
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
# System Files
.DS_Store
Thumbs.db

# Cache file
/ctgov-cache.db
2,636 changes: 2,005 additions & 631 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
"clinical-trial-matching-service": "^0.0.12",
"clinical-trial-matching-service": "^0.1.1",
"dotenv-flow": "^4.0.0"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/express": "^4.17.17",
"@types/fhir": "^0.0.37",
"@types/fhir": "^0.0.40",
"@types/jasmine": "^5.1.0",
"@types/node": "^20.8.6",
"@types/supertest": "^2.0.9",
"@types/supertest": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.0",
"eslint": "^8.30.0",
Expand Down
4 changes: 4 additions & 0 deletions spec/server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { Server } from "http";
import ClinicalTrialMatchingService from "clinical-trial-matching-service";

describe("startServer()", () => {
beforeAll(() => {
// Set the CTGov backup service to use a memory DB, overriding the .env config
process.env.CTGOV_CACHE_FILE = ':memory:';
});
beforeEach(() => {
// Don't actually want to start the server listening, so spy on the
// prototype to prevent that from happening
Expand Down
9 changes: 3 additions & 6 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export class APIQuery {
* update the returned trials with additional information pulled from
* ClinicalTrials.gov
*/
export function convertResponseToSearchSet(
export async function convertResponseToSearchSet(
response: QueryResponse,
ctgService?: ClinicalTrialsGovService
): Promise<SearchSet> {
Expand All @@ -340,12 +340,9 @@ export function convertResponseToSearchSet(
}
if (ctgService) {
// If given a backup service, use it
return ctgService.updateResearchStudies(studies).then(() => {
return new SearchSet(studies);
});
return new SearchSet(await ctgService.updateResearchStudies(studies));
} else {
// Otherwise, resolve immediately
return Promise.resolve(new SearchSet(studies));
return new SearchSet(studies);
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ export default async function startServer(
configuration = configFromEnv("MATCHING_SERVICE_");
}

// Create a ClinicalTrialGovService. It takes a path to a temporary directory
// that is used to store its cache.
const ctgService = await createClinicalTrialsGovService(
path.resolve(__dirname, "../ctgov-cache")
);
// Create a ClinicalTrialsGovService. It takes a path to a SQLite database to
// store its cache.
const ctgService = await createClinicalTrialsGovService(process.env.CTGOV_CACHE_FILE);
const getMatchingClinicalTrials = createClinicalTrialLookup(
configuration,
ctgService
Expand Down
Loading