From 2b01bb75dc493fbb84b218a89991663f31fa48dd Mon Sep 17 00:00:00 2001 From: Peter deHaan Date: Fri, 23 Jun 2017 11:29:45 -0700 Subject: [PATCH] Add /__version__ route --- package-lock.json | 36 ++++++++++++++++++++++++++++++------ package.json | 2 ++ server/portal_server.js | 11 +++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6c2025ca..2050aba6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1336,8 +1336,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { "version": "1.1.2", @@ -2025,6 +2024,11 @@ "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", "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": { "version": "6.0.4", "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", "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": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.3.0.tgz", @@ -3197,8 +3206,7 @@ "path-parse": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", - "dev": true + "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=" }, "path-platform": { "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": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", @@ -3663,8 +3676,7 @@ "resolve": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.3.tgz", - "integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=", - "dev": true + "integrity": "sha1-ZVkHw0aahoDcLeOidaj91paR8OU=" }, "resolve-from": { "version": "1.0.1", @@ -3805,6 +3817,18 @@ "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", "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": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", diff --git a/package.json b/package.json index cab3eba7..f9fc70a2 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "cross-env": "^5.0.1", "express": "^4.15.3", "express-handlebars": "^3.0.0", + "git-rev-sync": "1.9.1", "helmet": "^3.6.1", "jquery": "^3.2.1", "mozlog": "^2.1.1", @@ -37,6 +38,7 @@ "engines": { "node": ">=8.0.0" }, + "homepage": "https://github.com/mozilla/something-awesome/", "license": "MPL-2.0", "repository": "mozilla/something-awesome", "scripts": { diff --git a/server/portal_server.js b/server/portal_server.js index acf47b82..764892c1 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -7,6 +7,9 @@ const helmet = require('helmet'); const bytes = require('bytes'); const conf = require('./config.js'); const storage = require('./storage.js'); +const pkg = require('../package.json'); + +const gitSHA = require('git-rev-sync').short(); const notLocalHost = conf.notLocalHost; @@ -150,6 +153,14 @@ app.get('/__lbheartbeat__', (req, res) => { res.sendStatus(200); }); +app.get('/__version__', (req, res) => { + res.json({ + commit: gitSHA, + source: pkg.homepage, + version: pkg.version + }); +}); + app.listen(conf.listen_port, () => { log.info('startServer:', `Portal app listening on port ${conf.listen_port}!`); });