Skip to content

Commit

Permalink
refactor: simplify the modification of the default config
Browse files Browse the repository at this point in the history
  • Loading branch information
AlasDiablo committed Aug 21, 2024
1 parent 6794b52 commit 6e845dd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 46 deletions.
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
54 changes: 54 additions & 0 deletions tdm-be/src/model/json/DefaultDynamicConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"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"
]
}
]
},
{
"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"
]
}
]
}
]
}

0 comments on commit 6e845dd

Please sign in to comment.