Skip to content

Commit

Permalink
Merge pull request #54 from Inist-CNRS/dynamic-config
Browse files Browse the repository at this point in the history
Simplify the modification of the default config
  • Loading branch information
AlasDiablo authored Aug 21, 2024
2 parents 6794b52 + 50fe862 commit 4b380f0
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 46 deletions.
1 change: 1 addition & 0 deletions tdm-be/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ The project structure is organized as follows:
- `src/`: Contains the source code of the Express application.
- `controller/`: Contains route definitions for different endpoints.
- `model/`: Defines data models or interacts with the database.
- `json/DefaultDynamicConfig.json`: Default value for the dynamic config system
- `lib/`: Contains utility fonction.
- `templates/`: Contains email template.
- `worker/`: Contains processing fonction.
Expand Down
49 changes: 3 additions & 46 deletions tdm-be/src/model/DynamicConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logger from '~/lib/logger';
import defaultConfig from '~/model/json/DefaultDynamicConfig.json';

import { readFileSync } from 'node:fs';
import { writeFile } from 'node:fs/promises';
Expand Down Expand Up @@ -35,52 +36,8 @@ export class DynamicConfig {
}

this.config = {
wrappers: localConfig.wrappers ?? [
{
url: 'https://data-wrapper.services.istex.fr',
tags: [
{
name: 'data-wrapper',
excluded: ['/v1/fields/csv'],
},
],
},
],
enrichments: localConfig.enrichments ?? [
{
url: 'https://data-computer.services.istex.fr',
retrieveUrl: {
url: '/v1/retrieve-csv',
fileExtension: 'csv',
},
tags: [
{
name: 'data-computer',
excluded: [
'/v1/collect',
'/v1/retrieve',
'/v1/retrieve-csv',
'/v1/retrieve-json',
'/v1/mock-error-async',
'/v1/mock-error-sync',
],
},
],
},
{
url: 'https://data-termsuite.services.istex.fr',
retrieveUrl: {
url: '/v1/retrieve-csv',
fileExtension: 'csv',
},
tags: [
{
name: 'data-termsuite',
excluded: ['/v1/retrieve', '/v1/retrieve-csv', '/v1/retrieve-json'],
},
],
},
],
wrappers: localConfig.wrappers ?? defaultConfig.wrappers,
enrichments: localConfig.enrichments ?? defaultConfig.enrichments,
};
logger.info('Dynamic config loaded');
this.saveConfig();
Expand Down
118 changes: 118 additions & 0 deletions tdm-be/src/model/json/DefaultDynamicConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"wrappers": [
{
"url": "https://data-wrapper.services.istex.fr",
"tags": [
{
"name": "data-wrapper",
"excluded": [
"/v1/fields/csv"
]
}
]
}
],
"enrichments": [
{
"url": "https://data-computer.services.istex.fr",
"retrieveUrl": {
"url": "/v1/retrieve-csv",
"fileExtension": "csv"
},
"tags": [
{
"name": "data-computer",
"excluded": [
"/v1/collect",
"/v1/retrieve",
"/v1/retrieve-csv",
"/v1/retrieve-json",
"/v1/mock-error-async",
"/v1/mock-error-sync",
"/v1/base-line",
"/v1/graph-segment",
"/v1/statistics",
"/v1/tree-segment",
"/v1/lda-segment"
]
}
]
},
{
"url": "https://data-termsuite.services.istex.fr",
"retrieveUrl": {
"url": "/v1/retrieve-csv",
"fileExtension": "csv"
},
"tags": [
{
"name": "data-termsuite",
"excluded": [
"/v1/retrieve",
"/v1/retrieve-csv",
"/v1/retrieve-json"
]
}
]
},
{
"url": "https://data-workflow.services.istex.fr",
"retrieveUrl": {
"url": "/v1/retrieve-csv",
"fileExtension": "csv"
},
"tags": [
{
"name": "data-workflow",
"excluded": [
"/v1/base-line",
"/v1/retrieve",
"/v1/retrieve-csv",
"/v1/retrieve-json",
"/v1/conditormetrie",
"/v1/tag-cloud-en",
"/v1/tag-cloud-fr"
]
}
]
},
{
"url": "https://text-clustering.services.istex.fr",
"retrieveUrl": {
"url": "/v1/retrieve-json",
"fileExtension": "json"
},
"tags": [
{
"name": "clustering",
"excluded": [
"/v1/retrieve",
"/v1/retrieve-csv",
"/v1/retrieve-json",
"/v1/noise-lodex",
"/v1/clustering"
]
}
]
},
{
"url": "https://text-clustering.services.istex.fr",
"retrieveUrl": {
"url": "/v1/retrieve-csv",
"fileExtension": "csv"
},
"tags": [
{
"name": "clustering",
"excluded": [
"/v1/retrieve",
"/v1/retrieve-csv",
"/v1/retrieve-json",
"/v1/noise-lodex",
"/v1/noise"
]
}
]
}
]
}

0 comments on commit 4b380f0

Please sign in to comment.