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 client and referrals route for tiberbu #136

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 8 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ const getCHTValuesFromEnv =(instance)=>{
};

const CLIENT_REGISTRY = {
url: process.env.CLIENT_REGISTRY_URL,
url: process.env.CLIENT_REGISTRY_URL
};

const HIE = {
url: process.env.HIE_URL,
user: process.env.HIE_USER,
pass: process.env.HIE_PASS,
};

const NHDD = {
Expand All @@ -70,6 +76,7 @@ const CRON_SCHEDULE = process.env.CRON_SCHEDULE;
module.exports = {
CHANNEL_CONFIG_ENDPOINTS_URL,
CLIENT_REGISTRY,
HIE,
CONFIG,
FHIR,
KHIS,
Expand Down
24 changes: 13 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const bodyParser = require("body-parser");
const morgan = require("morgan");
const express = require("express");
const promBundle = require("express-prom-bundle");
const path = require("path");

const app = express();

const { registerMediator } = require('openhim-mediator-utils');
const {OPENHIM, CONFIG, CHANNEL_CONFIG_ENDPOINTS_URL, CRON_SCHEDULE, MEDIATOR} = require('./config');
const clientRoutes = require('./src/routes/client');
const clientv2Routes = require('./src/routes/v2/client');
const referralRoutes = require('./src/routes/referral');
const referralv2Routes = require('./src/routes/v2/referral');
const aggregateRoutes = require('./src/routes/aggregate');
const { scheduleTask } = require('./src/cron/cron');
const { logger } = require('./src/utils/logger');
Expand All @@ -24,20 +25,19 @@ const {
LOAD_ROOT,
} = messages;

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

logger.information(ROUTES_SETUP);
const app = express();
app.use(morgan());
app.use(promBundle({ includeMethod: true, includePath: true }));
app.use(express.json());

app.use("/client", clientRoutes);
app.use("/v2/client", clientv2Routes);
app.use("/referral", referralRoutes);
app.use("/v2/referral", referralv2Routes);
app.use("/aggregate", aggregateRoutes);

logger.information(ROUTES_SETUP_COMPLETE);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

logger.information(CRON_SETUP);
scheduleTask(CRON_SCHEDULE, MEDIATOR);
logger.information(CRON_SETUP_COMPLETE);
Expand Down Expand Up @@ -90,7 +90,9 @@ const mediatorConfig = {
],
};

registerMediator(OPENHIM, mediatorConfig, registerMediatorCallback);
if (process.env.ENV !== "dev") {
registerMediator(OPENHIM, mediatorConfig, registerMediatorCallback);
}

app.get("/", (req, res) => {
logger.information(LOAD_ROOT);
Expand Down
Loading