diff --git a/nodejs/routes/index.js b/nodejs/routes/index.js
index 24af1a2..3aa03fd 100755
--- a/nodejs/routes/index.js
+++ b/nodejs/routes/index.js
@@ -2,26 +2,21 @@
const fs = require('fs');
const path = require('path');
-const { execSync } = require('child_process');
var express = require('express');
var router = express.Router();
const moment = require('moment');
const {marked} = require('marked');
const {InviteToken, PasswordResetToken} = require('./../models/token');
const conf = require('@simpleworkjs/conf');
+const buildInfo = require('../utils/build_info');
const tosHtml = marked(fs.readFileSync(path.join(__dirname, '../../tos.md'), 'utf8'));
-const { version: buildVersion } = require('../package.json');
-let buildHash = 'unknown';
-try { buildHash = execSync('git rev-parse --short HEAD', { cwd: __dirname }).toString().trim(); } catch(_) {}
const values ={
title: conf.environment !== 'production' ? `dev` : '',
titleIcon: conf.environment !== 'production' ? `` : '',
name: conf.name,
- buildVersion,
- buildHash,
- buildYear: new Date().getFullYear(),
+ ...buildInfo,
}
// List of front end node modules to be served
diff --git a/nodejs/routes/oauth.js b/nodejs/routes/oauth.js
index b9c06df..ec75cb3 100644
--- a/nodejs/routes/oauth.js
+++ b/nodejs/routes/oauth.js
@@ -1,7 +1,6 @@
'use strict';
const crypto = require('crypto');
-const { execSync } = require('child_process');
const jwt = require('jsonwebtoken');
const express = require('express');
const conf = require('@simpleworkjs/conf');
@@ -9,22 +8,17 @@ const { OAuthClient } = require('../models/oauth_client');
const { OAuthCode, OAuthAccessToken, OAuthRefreshToken } = require('../models/oauth_code');
const { User } = require('../models/user');
const { Group } = require('../models/group_ldap');
+const buildInfo = require('../utils/build_info');
const oauthConf = conf.oauth || {};
const issuer = oauthConf.issuer || `http://localhost:${conf.port || 3000}`;
const jwtSecret = oauthConf.jwtSecret || 'change-me-in-secrets';
-const { version: buildVersion } = require('../package.json');
-let buildHash = 'unknown';
-try { buildHash = execSync('git rev-parse --short HEAD', { cwd: __dirname }).toString().trim(); } catch(_) {}
-
const pageLocals = {
title: conf.environment !== 'production' ? 'dev' : '',
titleIcon: conf.environment !== 'production' ? '' : '',
name: conf.name,
- buildVersion,
- buildHash,
- buildYear: new Date().getFullYear(),
+ ...buildInfo,
};
// --- helpers ---
diff --git a/nodejs/utils/build_info.js b/nodejs/utils/build_info.js
new file mode 100644
index 0000000..933679b
--- /dev/null
+++ b/nodejs/utils/build_info.js
@@ -0,0 +1,15 @@
+'use strict';
+
+const { execSync } = require('child_process');
+const { version: buildVersion } = require('../package.json');
+
+let buildHash = 'unknown';
+try {
+ buildHash = execSync('git rev-parse --short HEAD', { cwd: __dirname }).toString().trim();
+} catch (_) {}
+
+module.exports = {
+ buildVersion,
+ buildHash,
+ buildYear: new Date().getFullYear(),
+};
diff --git a/nodejs/views/bottom.ejs b/nodejs/views/bottom.ejs
index 0541dee..920347c 100755
--- a/nodejs/views/bottom.ejs
+++ b/nodejs/views/bottom.ejs
@@ -1,15 +1,21 @@