Including gitCommit and version in frontend build. Backend now sending a backendInfo object containing commit, version and hostname. All printed on About page.

This commit is contained in:
softsimon
2021-04-12 22:17:13 +04:00
parent f61e3d8cec
commit 7a4ad0ee2f
12 changed files with 74 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "mempool-backend",
"version": "2.0.0",
"version": "2.2-dev",
"description": "Bitcoin mempool visualizer and blockchain explorer backend",
"license": "GNU Affero General Public License v3.0",
"homepage": "https://mempool.space",

View File

@@ -1,20 +1,24 @@
import * as fs from 'fs';
import * as os from 'os';
import logger from '../logger';
import { IBackendInfo } from '../mempool.interfaces';
class BackendInfo {
gitCommitHash = '';
hostname = '';
private gitCommitHash = '';
private hostname = '';
private version = '';
constructor() {
this.setLatestCommitHash();
this.setVersion();
this.hostname = os.hostname();
}
public getBackendInfo() {
public getBackendInfo(): IBackendInfo {
return {
'hostname': this.hostname,
'git-commit': this.gitCommitHash,
hostname: this.hostname,
gitCommit: this.gitCommitHash,
version: this.version,
};
}
@@ -29,6 +33,15 @@ class BackendInfo {
logger.err('Could not load git commit info: ' + e.message || e);
}
}
private setVersion(): void {
try {
const packageJson = fs.readFileSync('package.json').toString();
this.version = JSON.parse(packageJson).version;
} catch (e) {
throw new Error(e);
}
}
}
export default new BackendInfo();

View File

@@ -159,8 +159,7 @@ class WebsocketHandler {
'conversions': fiatConversion.getConversionRates(),
'mempool-blocks': mempoolBlocks.getMempoolBlocks(),
'transactions': memPool.getLatestTransactions(),
'git-commit': backendInfo.gitCommitHash,
'hostname': backendInfo.hostname,
'backendInfo': backendInfo.getBackendInfo(),
'loadingIndicators': loadingIndicators.getLoadingIndicators(),
...this.extraInitProperties
};

View File

@@ -160,3 +160,9 @@ interface RequiredParams {
export interface ILoadingIndicators { [name: string]: number; }
export interface IConversionRates { [currency: string]: number; }
export interface IBackendInfo {
hostname: string;
gitCommit: string;
version: string;
}