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

Using gulp to set the value of Rt106_SERVER_URL from environment vari… #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"csvtojson": "^1.1.4",
"date-format": "0.0.2",
"express": "^4.13.4",
"gulp": "^3.9.1",
"gulp-ng-constant": "^1.2.0",
"mysql": "~2.11.1",
"request": "^2.81.0",
"request-promise": "^3.0.0",
Expand Down
10 changes: 4 additions & 6 deletions public/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) General Electric Company, 2017. All rights reserved.
angular.module("rt106.config", [])

angular.module('rt106.config', [])
.constant("API_VERSION", "v1")

.constant('API_VERSION', 'v1')
.constant("Rt106_SERVER_URL", "http://localhost")

.constant('Rt106_SERVER_URL', 'http://localhost')

;
;
5 changes: 5 additions & 0 deletions public/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"API_VERSION": "v1",
"Rt106_SERVER_URL": "http://localhost"
}

10 changes: 4 additions & 6 deletions rt106-app/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) General Electric Company, 2017. All rights reserved.
angular.module("rt106.config", [])

angular.module('rt106.config', [])
.constant("API_VERSION", "v1")

.constant('API_VERSION', 'v1')
.constant("Rt106_SERVER_URL", "http://localhost")

.constant('Rt106_SERVER_URL', 'http://localhost')

;
;
4 changes: 4 additions & 0 deletions rt106-app/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"API_VERSION": "v1",
"Rt106_SERVER_URL": "http://localhost"
}
33 changes: 32 additions & 1 deletion rt106-server/rt106-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const request = require('request');
const csv = require('csvtojson');
//const cors = require('cors');


const winston = require('winston');

// Rt 106 modules
Expand All @@ -21,6 +20,38 @@ const healthMgr = require('./healthMgr'); // module for checking the health
var AMQPmgr = null; // optional module for managing RabbitMQ queues.
var SQSmgr = null; // optional module for managing SQS queues

/*
* Dynamically create the config.js file.
* If the environment variable Rt106_SERVER_HOST is defined, that is used in config.js. Otherwise localhost is used.
* If the environment variable Rt106_APP_DIR is defined, that is the location where config.js needs to be. Otherwise use rt106-app.
*/
var gulp = require('gulp');
var ngConstant = require('gulp-ng-constant');
var Rt106_SERVER_URL = 'http://localhost'; // Default value, may be changed below.
if (process.env.Rt106_SERVER_HOST !== undefined) {
Rt106_SERVER_URL = 'http://' + process.env.Rt106_SERVER_HOST;
}
console.log("gulp setting Rt106_SERVER_URL to " + Rt106_SERVER_URL);
var Rt106_APP_DIR = 'rt106-app';
if (process.env.Rt106_SERVE_APP !== undefined) {
Rt106_APP_DIR = process.env.Rt106_SERVE_APP;
}
gulp.task('default', function() {
gulp.src(Rt106_APP_DIR + '/config.json')
.pipe(ngConstant({
name: 'rt106.config',
constants:
{
Rt106_SERVER_URL: Rt106_SERVER_URL
}
}))
.pipe(gulp.dest(Rt106_APP_DIR));
});
gulp.start('default');
/*
* End of dynamic creation of config.js.
*/

// Constants
const PORT = 8106;
//const filepath = '/tests/demo_data/'; // for "local" (testing) DICOM store.
Expand Down