diff --git a/app-connector-client/package.json b/app-connector-client/package.json index 777b727a..536c6ff0 100644 --- a/app-connector-client/package.json +++ b/app-connector-client/package.json @@ -5,7 +5,7 @@ "main": "server/app.js", "scripts": { "start": "node server/server", - "start:dev": "export DEBUG=true && node server/server test/varkes_config.json", + "start:dev": "export DEBUG=true && node server/server ../test/varkes_config.json", "test": "nyc mocha --exit" }, "publishConfig": { diff --git a/app-connector-client/server/app.js b/app-connector-client/server/app.js index 900036c6..9c3f145d 100644 --- a/app-connector-client/server/app.js +++ b/app-connector-client/server/app.js @@ -17,7 +17,7 @@ const VARKES_LOGO = path.resolve(__dirname, 'views/static/logo.svg') function init(varkesConfigPath = null, currentPath = "", nodePortParam = null) { var app = express() app.use(bodyParser.json()); - var varkesConfig = config(varkesConfigPath, path.dirname(path.resolve(currentPath, varkesConfigPath))) + var varkesConfig = config(varkesConfigPath, currentPath) if (fs.existsSync(path.resolve(CONFIG.keyDir, CONFIG.apiFile))) { CONFIG.URLs = JSON.parse(fs.readFileSync(path.resolve(CONFIG.keyDir, CONFIG.apiFile))) } else { diff --git a/app-connector-client/server/config.js b/app-connector-client/server/config.js index 82f3f178..d8b09c8a 100644 --- a/app-connector-client/server/config.js +++ b/app-connector-client/server/config.js @@ -11,14 +11,14 @@ const pretty_yaml = require('json-to-pretty-yaml'); module.exports = function (varkesConfigPath, currentDirectory) { var varkesConfig if (varkesConfigPath) { - var endpointConfig = path.resolve(varkesConfigPath); + var endpointConfig = path.resolve(currentDirectory, varkesConfigPath) LOGGER.info("Using configuration %s", endpointConfig); - varkesConfig = JSON.parse(fs.readFileSync(endpointConfig)); + varkesConfig = JSON.parse(fs.readFileSync(endpointConfig, "utf-8")); varkesConfig.apis.map(element => { - element.specification = path.resolve(currentDirectory, element.specification) + element.specification = path.resolve(path.dirname(endpointConfig), element.specification) }) varkesConfig.events.map(element => { - element.specification = path.resolve(currentDirectory, element.specification) + element.specification = path.resolve(path.dirname(endpointConfig), element.specification) }) configValidation(varkesConfig) } else { diff --git a/app-connector-client/server/routes/services.js b/app-connector-client/server/routes/services.js index ef99b0a0..67be5228 100644 --- a/app-connector-client/server/routes/services.js +++ b/app-connector-client/server/routes/services.js @@ -120,7 +120,7 @@ function fillServiceMetadata(serviceMetadata, api, hostname) { if (api.baseurl) serviceMetadata.api.targetUrl = serviceMetadata.api.targetUrl + api.baseurl; - else if (api.auth && api.auth != "none") { + if (api.auth && api.auth != "none") { serviceMetadata.api.credentials[api.auth] = AUTH_ENDPOINTS[api.auth] } diff --git a/app-connector-client/server/server.js b/app-connector-client/server/server.js index eb6cc9f4..4baa5055 100755 --- a/app-connector-client/server/server.js +++ b/app-connector-client/server/server.js @@ -16,7 +16,7 @@ var runAsync = async () => { } try { - app.use(await connectorApp.init(configPath)) + app.use(await connectorApp.init(configPath, __dirname)) app.listen(10000, function () { LOGGER.info("Started application on port %d", 10000) }); diff --git a/app-connector-client/test/test_integration.js b/app-connector-client/test/test_integration.js index 25f15159..6f92e82a 100644 --- a/app-connector-client/test/test_integration.js +++ b/app-connector-client/test/test_integration.js @@ -20,7 +20,7 @@ describe("should work", () => { await kyma.then(app => { kymaServer = app.listen(port) }) - await mock.init("./test/varkes_config.json").then((mock) => { + await mock.init("varkes_config.json", __dirname).then((mock) => { server = express() server.use(mock) }) diff --git a/odata-mock/src/server/config.ts b/odata-mock/src/server/config.ts index 2b8ddb80..dd68b963 100644 --- a/odata-mock/src/server/config.ts +++ b/odata-mock/src/server/config.ts @@ -11,7 +11,10 @@ function config(varkesConfigPath: string, currentPath: string): VarkesConfigType if (varkesConfigPath) { var endpointConfig = path.resolve(currentPath, varkesConfigPath) LOGGER.info("Using configuration %s", endpointConfig) - varkesConfig = JSON.parse(fs.readFileSync(endpointConfig)) + varkesConfig = JSON.parse(fs.readFileSync(endpointConfig, "utf-8")) + varkesConfig.apis.map((api: any) => { + api.specification = path.resolve(path.dirname(endpointConfig), api.specification) + }) configValidation(varkesConfig) } else { LOGGER.info("Using default configuration") diff --git a/openapi-mock/server/config.js b/openapi-mock/server/config.js index 554b78da..bc732a41 100644 --- a/openapi-mock/server/config.js +++ b/openapi-mock/server/config.js @@ -13,7 +13,7 @@ module.exports = function (varkesConfigPath, currentDirectory) { if (varkesConfigPath) { var endpointConfig = path.resolve(currentDirectory, varkesConfigPath) LOGGER.info("Using configuration %s", endpointConfig) - varkesConfig = JSON.parse(fs.readFileSync(endpointConfig), "utf-8") + varkesConfig = JSON.parse(fs.readFileSync(endpointConfig, "utf-8")) varkesConfig.apis.map(api => { api.specification = path.resolve(path.dirname(endpointConfig), api.specification) if (api.added_endpoints) {