Add /__version__ route

This commit is contained in:
Peter deHaan 2017-06-23 11:29:45 -07:00
parent 2691dfcf2f
commit 2b01bb75dc
No known key found for this signature in database
GPG Key ID: F0FC6C01C6305097
3 changed files with 43 additions and 6 deletions

36
package-lock.json generated
View File

@ -1336,8 +1336,7 @@
"fs.realpath": { "fs.realpath": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
"dev": true
}, },
"fsevents": { "fsevents": {
"version": "1.1.2", "version": "1.1.2",
@ -2025,6 +2024,11 @@
"integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=",
"dev": true "dev": true
}, },
"git-rev-sync": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/git-rev-sync/-/git-rev-sync-1.9.1.tgz",
"integrity": "sha1-oMLj3TkqvPa3aWLif8dfsyI0Sc4="
},
"glob": { "glob": {
"version": "6.0.4", "version": "6.0.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz",
@ -2280,6 +2284,11 @@
"resolved": "https://registry.npmjs.org/intel/-/intel-1.2.0.tgz", "resolved": "https://registry.npmjs.org/intel/-/intel-1.2.0.tgz",
"integrity": "sha1-EdEUfraz9Fgr31M3s31UFYTp5B4=" "integrity": "sha1-EdEUfraz9Fgr31M3s31UFYTp5B4="
}, },
"interpret": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.3.tgz",
"integrity": "sha1-y8NcYu7uc/Gat7EKgBURQBr8D5A="
},
"ipaddr.js": { "ipaddr.js": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.3.0.tgz", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.3.0.tgz",
@ -3197,8 +3206,7 @@
"path-parse": { "path-parse": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz",
"integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME="
"dev": true
}, },
"path-platform": { "path-platform": {
"version": "0.11.15", "version": "0.11.15",
@ -3593,6 +3601,11 @@
} }
} }
}, },
"rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q="
},
"redent": { "redent": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz",
@ -3663,8 +3676,7 @@
"resolve": { "resolve": {
"version": "1.3.3", "version": "1.3.3",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz",
"integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=", "integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU="
"dev": true
}, },
"resolve-from": { "resolve-from": {
"version": "1.0.1", "version": "1.0.1",
@ -3805,6 +3817,18 @@
"integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=",
"dev": true "dev": true
}, },
"shelljs": {
"version": "0.7.7",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz",
"integrity": "sha1-svXHfvlxSPS09uImguELuoZnz/E=",
"dependencies": {
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ=="
}
}
},
"signal-exit": { "signal-exit": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",

View File

@ -12,6 +12,7 @@
"cross-env": "^5.0.1", "cross-env": "^5.0.1",
"express": "^4.15.3", "express": "^4.15.3",
"express-handlebars": "^3.0.0", "express-handlebars": "^3.0.0",
"git-rev-sync": "1.9.1",
"helmet": "^3.6.1", "helmet": "^3.6.1",
"jquery": "^3.2.1", "jquery": "^3.2.1",
"mozlog": "^2.1.1", "mozlog": "^2.1.1",
@ -37,6 +38,7 @@
"engines": { "engines": {
"node": ">=8.0.0" "node": ">=8.0.0"
}, },
"homepage": "https://github.com/mozilla/something-awesome/",
"license": "MPL-2.0", "license": "MPL-2.0",
"repository": "mozilla/something-awesome", "repository": "mozilla/something-awesome",
"scripts": { "scripts": {

View File

@ -7,6 +7,9 @@ const helmet = require('helmet');
const bytes = require('bytes'); const bytes = require('bytes');
const conf = require('./config.js'); const conf = require('./config.js');
const storage = require('./storage.js'); const storage = require('./storage.js');
const pkg = require('../package.json');
const gitSHA = require('git-rev-sync').short();
const notLocalHost = conf.notLocalHost; const notLocalHost = conf.notLocalHost;
@ -150,6 +153,14 @@ app.get('/__lbheartbeat__', (req, res) => {
res.sendStatus(200); res.sendStatus(200);
}); });
app.get('/__version__', (req, res) => {
res.json({
commit: gitSHA,
source: pkg.homepage,
version: pkg.version
});
});
app.listen(conf.listen_port, () => { app.listen(conf.listen_port, () => {
log.info('startServer:', `Portal app listening on port ${conf.listen_port}!`); log.info('startServer:', `Portal app listening on port ${conf.listen_port}!`);
}); });