Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
Fixes file pathes for config file (#167)
Browse files Browse the repository at this point in the history
* file path fixes
  • Loading branch information
a-thaler authored Mar 21, 2019
1 parent 1ac0f3c commit 1d61e80
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app-connector-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion app-connector-client/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions app-connector-client/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app-connector-client/server/routes/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down
2 changes: 1 addition & 1 deletion app-connector-client/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
Expand Down
2 changes: 1 addition & 1 deletion app-connector-client/test/test_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
5 changes: 4 additions & 1 deletion odata-mock/src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion openapi-mock/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1d61e80

Please sign in to comment.