Skip to content

Commit

Permalink
Merge pull request #10 from jembi/CU-86c13wh47_Utilize-OpenHIMs-Media…
Browse files Browse the repository at this point in the history
…tors-configuration-to-set-buckets

CU-86c13wh47_Utilize-OpenHIMs-Mediators-configuration-to-set-buckets
  • Loading branch information
drizzentic authored Dec 3, 2024
2 parents 71be014 + 356a69c commit 3159faa
Show file tree
Hide file tree
Showing 11 changed files with 420 additions and 85 deletions.
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
- 9000:9000
- 9001:9001
command: server /data --console-address ":9001"
network_mode: host

clickhouse:
image: clickhouse/clickhouse-server:23.8.14.6
Expand All @@ -13,6 +14,7 @@ services:
- 9002:9000
environment:
- CLICKHOUSE_PASSWORD=dev_password_only
network_mode: host

openhim-console:
image: jembi/openhim-console:v1.18.2
Expand All @@ -35,6 +37,8 @@ services:
mongo-db:
container_name: mongo-db
image: mongo:4.0
ports:
- 27017:27017
networks:
- openhim
restart: unless-stopped
Expand Down
56 changes: 56 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
},
"dependencies": {
"@clickhouse/client": "^1.8.0",
"axios": "^1.7.7",
"dotenv": "^16.4.5",
"express": "^4.18.2",
"express-async-handler": "^1.2.0",
Expand Down
23 changes: 14 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@ import path from 'path';
import { getConfig } from './config/config';
import logger from './logger';
import routes from './routes/index';
import { setupMediator } from './openhim/openhim';
import {
createMinioBucketListeners,
} from './utils/minioClient';
import { getRegisteredBuckets, setupMediator } from './openhim/openhim';
import { createMinioBucketListeners, ensureBucketExists } from './utils/minioClient';

const app = express();

app.use('/', routes);

createMinioBucketListeners();

app.listen(getConfig().port, () => {
app.listen(getConfig().port, async () => {
logger.info(`Server is running on port - ${getConfig().port}`);

if (getConfig().runningMode !== 'testing' && getConfig().registerMediator) {
setupMediator(path.resolve(__dirname, './openhim/mediatorConfig.json'));
await setupMediator();
}
});

const buckets = await getRegisteredBuckets();

buckets.length === 0 && logger.warn('No buckets specified in the configuration');

for await (const { bucket, region } of buckets) {
await ensureBucketExists(bucket, region);
}

createMinioBucketListeners(buckets.map((bucket) => bucket.bucket));
});
31 changes: 28 additions & 3 deletions src/openhim/mediatorConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"instant"
],
"methods": [
"POST", "GET"
"POST",
"GET"
],
"type": "http"
}
Expand All @@ -35,5 +36,29 @@
"type": "http"
}
],
"configDefs": []
}
"configDefs": [
{
"param": "minio_buckets_registry",
"displayName": "Minio Buckets Registry",
"description": "The available Minio buckets and their configurations",
"type": "struct",
"array": true,
"template": [
{
"param": "bucket",
"displayName": "Bucket",
"type": "string"
},
{
"param": "region",
"displayName": "Region (optional)",
"type": "string",
"optional": true
}
]
}
],
"config": {
"minio_buckets_registry": []
}
}
Loading

0 comments on commit 3159faa

Please sign in to comment.