Skip to content

Commit

Permalink
Merge pull request #134 from dadi/feature/output-web-version
Browse files Browse the repository at this point in the history
Feature/output web version
  • Loading branch information
jimlambie authored Mar 14, 2017
2 parents 2e44826 + e40d5cb commit f5092ea
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ var conf = convict({
enabled: {
doc: 'Determines whether this web instance requires access to the API',
format: Boolean,
default: true
default: false
}
},
auth: {
Expand Down
1 change: 1 addition & 0 deletions config/config.development.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"cluster": false,
"api": {
"enabled": false,
"host": "127.0.0.1",
"port": 3000
},
Expand Down
1 change: 1 addition & 0 deletions config/config.https.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"sslCertificatePath": "ssl/cert.pem"
},
"api": {
"enabled": false,
"host": "127.0.0.1",
"port": 3000
},
Expand Down
1 change: 1 addition & 0 deletions config/config.production.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"port": 3001
},
"api": {
"enabled": false,
"host": "127.0.0.1",
"port": 3000
},
Expand Down
1 change: 1 addition & 0 deletions config/config.qa.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"cluster": false,
"api": {
"enabled": false,
"host": "127.0.0.1",
"port": 3000
},
Expand Down
1 change: 1 addition & 0 deletions config/config.test.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
},
"cluster": false,
"api": {
"enabled": false,
"host": "127.0.0.1",
"port": 3000
},
Expand Down
2 changes: 2 additions & 0 deletions dadi/lib/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ Controller.prototype.process = function process (req, res, next) {
help.timer.stop(req.method.toLowerCase())
if (data) data.stats = help.timer.getStats()

if (data) data.version = help.getVersion()

if (data.json) {
return done(null, data)
}
Expand Down
5 changes: 5 additions & 0 deletions dadi/lib/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ var https = require('https')
var path = require('path')
var perfy = require('perfy')

var version = require('../../package.json').version
var cache = require(path.join(__dirname, '/cache'))
var config = require(path.join(__dirname, '/../../config.js'))
var Passport = require('@dadi/passport')

var self = this

module.exports.getVersion = function () {
if (config.get('debug')) return version
}

module.exports.htmlEncode = function (input) {
var encodedStr = input.replace(/[\u00A0-\u9999<>&]/gim, function (i) {
return '&#' + i.charCodeAt(0) + ';'
Expand Down
2 changes: 1 addition & 1 deletion dadi/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ function onListening (e) {
if (config.get('api.enabled') === true) {
startText += ' API: '.green + extraPadding + config.get('api.host') + ':' + config.get('api.port') + '\n'
} else {
startText += ' API: '.green + extraPadding + 'Not found'.red + '\n'
startText += ' API: '.green + extraPadding + 'Disabled'.red + '\n'
startText += ' ----------------------------\n'
}

Expand Down
1 change: 1 addition & 0 deletions test/acceptance/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('Routing', function (done) {
//scope = nock(apiHost).post('/token').reply(200, { accessToken: 'xx' })
var configUpdate = {
server: {
enabled: true,
host: '127.0.0.1',
port: 5000
}
Expand Down

0 comments on commit f5092ea

Please sign in to comment.