-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #294 from jembi/CU-86bynyk8j_Register-Platform-Def…
…ault-Portal-applications-During-init CU-86bynyk8j - Register Platform Default Portal applications During init
- Loading branch information
Showing
11 changed files
with
219 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "FHIR IG Importer", | ||
"description": "FHIR IG microfrontend app", | ||
"category": "HIE Configuration", | ||
"type": "esmodule", | ||
"url": "http://localhost:3000/jembi-fhir-ig-importer.js", | ||
"showInPortal": true, | ||
"showInSideBar": true, | ||
"access_roles": ["admin"], | ||
"icon": "https://fonts.gstatic.com/s/i/materialicons/medical_information/v1/24px.svg" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,90 @@ | ||
"use strict"; | ||
|
||
const fs = require("fs"); | ||
const https = require("https"); | ||
const path = require("path"); | ||
|
||
("use strict"); | ||
|
||
const OPENHIM_CORE_SERVICE_NAME = "openhim-core"; | ||
const OPENHIM_MEDIATOR_API_PORT = 8080; | ||
const OPENHIM_API_PASSWORD = process.env.OPENHIM_API_PASSWORD || "instant101"; | ||
const OPENHIM_API_USERNAME = | ||
process.env.OPENHIM_API_USERNAME || "[email protected]"; | ||
|
||
const authHeader = new Buffer.from( | ||
const authHeader = Buffer.from( | ||
`${OPENHIM_API_USERNAME}:${OPENHIM_API_PASSWORD}` | ||
).toString("base64"); | ||
|
||
function makeRequest(options, data) { | ||
const req = https.request(options, (res) => { | ||
if (res.statusCode == 401) { | ||
throw new Error(`Incorrect OpenHIM API credentials`); | ||
} | ||
|
||
if (![201, 200].includes(res.statusCode)) { | ||
throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`); | ||
} | ||
|
||
console.log("Successfully Imported OpenHIM Config"); | ||
}); | ||
|
||
req.on("error", (error) => { | ||
throw new Error(`Failed to import OpenHIM config: ${error}`); | ||
}); | ||
|
||
req.write(data); | ||
req.end(); | ||
} | ||
|
||
const jsonData = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, "openhim-import.json")) | ||
); | ||
|
||
const appJsonData = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, "ig-importer-app.json")) | ||
); | ||
|
||
const data = JSON.stringify(jsonData); | ||
const appData = JSON.stringify(appJsonData); | ||
|
||
const options = { | ||
protocol: "https:", | ||
hostname: OPENHIM_CORE_SERVICE_NAME, | ||
port: OPENHIM_MEDIATOR_API_PORT, | ||
path: "/metadata", | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Length": data.length, | ||
Authorization: `Basic ${authHeader}`, | ||
}, | ||
}; | ||
|
||
const req = https.request(options, (res) => { | ||
if (res.statusCode == 401) { | ||
throw new Error(`Incorrect OpenHIM API credentials`); | ||
} | ||
|
||
if (res.statusCode != 201) { | ||
throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`); | ||
} | ||
const reqOptions = { | ||
...options, | ||
path: "/metadata", | ||
method: "POST", | ||
headers: { | ||
...options.headers, | ||
"Content-Length": data.length, | ||
}, | ||
}; | ||
|
||
console.log("Successfully Imported OpenHIM Config"); | ||
}); | ||
const appReqOptions = { | ||
...options, | ||
path: "/apps", | ||
method: "POST", | ||
headers: { | ||
...options.headers, | ||
"Content-Length": appData.length, | ||
}, | ||
}; | ||
|
||
req.on("error", (error) => { | ||
throw new Error(`Failed to import OpenHIM config: ${error}`); | ||
}); | ||
const importMapRebuildOptions = { | ||
...options, | ||
path: "/apps", | ||
method: "GET", | ||
headers: { | ||
...options.headers, | ||
}, | ||
}; | ||
|
||
req.write(data); | ||
req.end(); | ||
makeRequest(reqOptions, data); | ||
makeRequest(appReqOptions, appData); | ||
makeRequest(importMapRebuildOptions, ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "Kafka Mapper Consumer", | ||
"description": "Kafka mapper consumer microfrontends app", | ||
"category": "HIE Configuration", | ||
"type": "esmodule", | ||
"url": "http://localhost:8091/jembi-kafka-mapper-consumer-ui.js", | ||
"showInPortal": true, | ||
"showInSideBar": false, | ||
"access_roles": ["admin"], | ||
"icon": "https://fonts.gstatic.com/s/i/materialicons/apps/v12/24px.svg" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
version: '3.9' | ||
|
||
services: | ||
# container for executing config import scripts for creating the OpenHIM channels used by the Mediator | ||
kafka-mapper-consumer-config-importer: | ||
image: node:erbium-alpine | ||
networks: | ||
openhim: | ||
default: | ||
environment: | ||
OPENHIM_API_USERNAME: ${OPENHIM_USERNAME} | ||
OPENHIM_API_PASSWORD: ${OPENHIM_PASSWORD} | ||
# Reject unauthorised is only needed if the OpenHIM's SSL is not setup | ||
NODE_TLS_REJECT_UNAUTHORIZED: 0 | ||
command: sh -c "node openhimConfig.js" | ||
configs: | ||
- source: kafka-mapper-consumer-openhimConfig.js | ||
target: /openhimConfig.js | ||
- source: kafka-mapper-consumer-consumer-ui-app.json | ||
target: /consumer-ui-app.json | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: none | ||
|
||
configs: | ||
kafka-mapper-consumer-openhimConfig.js: | ||
file: ./openhimConfig.js | ||
name: kafka-mapper-consumer-openhimConfig.js-${fhir_ig_importer_config_importer_openhimConfig_js_DIGEST:?err} | ||
labels: | ||
name: kafka-mapper-consumer | ||
kafka-mapper-consumer-consumer-ui-app.json: | ||
file: ./consumer-ui-app.json | ||
name: kafka-mapper-consumer-consumer-ui-app.json-${kafka_mapper_consumer_ui_json_DIGEST:?err} | ||
labels: | ||
name: kafka-mapper-consumer | ||
|
||
networks: | ||
openhim: | ||
name: openhim_public | ||
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const fs = require("fs"); | ||
const https = require("https"); | ||
const path = require("path"); | ||
|
||
("use strict"); | ||
|
||
const OPENHIM_CORE_SERVICE_NAME = "openhim-core"; | ||
const OPENHIM_MEDIATOR_API_PORT = 8080; | ||
const OPENHIM_API_PASSWORD = process.env.OPENHIM_API_PASSWORD || "instant101"; | ||
const OPENHIM_API_USERNAME = | ||
process.env.OPENHIM_API_USERNAME || "[email protected]"; | ||
|
||
const authHeader = Buffer.from( | ||
`${OPENHIM_API_USERNAME}:${OPENHIM_API_PASSWORD}` | ||
).toString("base64"); | ||
function makeRequest(options, data) { | ||
const req = https.request(options, (res) => { | ||
if (res.statusCode == 401) { | ||
throw new Error(`Incorrect OpenHIM API credentials`); | ||
} | ||
|
||
if (![201, 200].includes(res.statusCode)) { | ||
throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`); | ||
} | ||
|
||
console.log("Successfully Imported OpenHIM Config"); | ||
}); | ||
|
||
req.on("error", (error) => { | ||
throw new Error(`Failed to import OpenHIM config: ${error}`); | ||
}); | ||
|
||
req.write(data); | ||
req.end(); | ||
} | ||
|
||
const appJsonData = JSON.parse( | ||
fs.readFileSync(path.resolve(__dirname, "consumer-ui-app.json")) | ||
); | ||
const appData = JSON.stringify(appJsonData); | ||
|
||
const options = { | ||
protocol: "https:", | ||
hostname: OPENHIM_CORE_SERVICE_NAME, | ||
port: OPENHIM_MEDIATOR_API_PORT, | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Basic ${authHeader}`, | ||
}, | ||
}; | ||
|
||
const appReqOptions = { | ||
...options, | ||
path: "/apps", | ||
method: "POST", | ||
headers: { | ||
...options.headers, | ||
"Content-Length": appData.length, | ||
}, | ||
}; | ||
|
||
const importMapRebuildOptions = { | ||
...options, | ||
path: "/apps", | ||
method: "GET", | ||
headers: { | ||
...options.headers, | ||
}, | ||
}; | ||
|
||
makeRequest(appReqOptions, appData); | ||
makeRequest(importMapRebuildOptions, ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters