Add version to index page

This commit is contained in:
simojenki
2021-08-31 09:12:53 +10:00
parent c73f79532d
commit 00f6a9ff8f
6 changed files with 39 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
import path from "path";
import fs from "fs";
import server from "./server";
import logger from "./logger";
import { appendMimeTypeToClientFor, DEFAULT, Navidrome } from "./navidrome";
@@ -56,6 +58,10 @@ const featureFlagAwareMusicService: MusicService = {
}),
};
export const GIT_INFO = path.join(__dirname, "..", ".gitinfo");
const version = fs.existsSync(GIT_INFO) ? fs.readFileSync(GIT_INFO).toString().trim() : "v??"
const app = server(
sonosSystem,
bonob,
@@ -67,7 +73,8 @@ const app = server(
clock: SystemClock,
iconColors: config.icons,
applyContextPath: true,
logRequests: true
logRequests: true,
version
}
);

View File

@@ -79,6 +79,7 @@ export type ServerOpts = {
};
applyContextPath: boolean;
logRequests: boolean;
version: string
};
const DEFAULT_SERVER_OPTS: ServerOpts = {
@@ -88,6 +89,7 @@ const DEFAULT_SERVER_OPTS: ServerOpts = {
iconColors: { foregroundColor: undefined, backgroundColor: undefined },
applyContextPath: true,
logRequests: false,
version: "v?"
};
function server(
@@ -146,6 +148,7 @@ function server(
removeRegistrationRoute: bonobUrl
.append({ pathname: REMOVE_REGISTRATION_ROUTE })
.pathname(),
version: opts.version
});
}
);