mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-04 12:58:11 +03:00
Make FormatVersion() a constant
This commit is contained in:
@@ -34,6 +34,4 @@ export const VERSION_INFO = {
|
||||
|
||||
export const VERSION_STR = `${MAJOR}.${MINOR}.${PATCH}`;
|
||||
|
||||
export function FormatVersion() {
|
||||
return `v${VERSION_STR} (${VERSION_INFO.name})`;
|
||||
}
|
||||
export const VERSION_PRETTY = `v${VERSION_STR} (${VERSION_INFO.name})`;
|
||||
|
||||
+2
-2
@@ -10,6 +10,7 @@ import fs from "fs";
|
||||
import http from "http";
|
||||
import https from "https";
|
||||
import { LoadDefaultClients } from "lib/builtin-clients/builtin-clients";
|
||||
import { VERSION_PRETTY } from "lib/constants/version";
|
||||
import { HandleSIGTERMGracefully } from "lib/handlers/sigterm";
|
||||
import CreateLogCtx from "lib/logger/logger";
|
||||
import { Environment, ServerConfig, TachiConfig } from "lib/setup/config";
|
||||
@@ -17,11 +18,10 @@ import path from "path";
|
||||
import server from "server/server";
|
||||
import fetch from "utils/fetch";
|
||||
import { InitaliseFolderChartLookup } from "utils/folder";
|
||||
import { FormatVersion } from "./lib/constants/version";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
logger.info(`Booting ${TachiConfig.NAME} - ${FormatVersion()} [ENV: ${Environment.nodeEnv}]`, {
|
||||
logger.info(`Booting ${TachiConfig.NAME} - ${VERSION_PRETTY} [ENV: ${Environment.nodeEnv}]`, {
|
||||
bootInfo: true,
|
||||
});
|
||||
logger.info(`Log level is set to ${ServerConfig.LOGGER_CONFIG.LOG_LEVEL}.`, { bootInfo: true });
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FormatVersion } from "lib/constants/version";
|
||||
import { VERSION_PRETTY } from "lib/constants/version";
|
||||
import { CreateFakeAuthCookie } from "test-utils/fake-auth";
|
||||
import mockApi from "test-utils/mock-api";
|
||||
import t from "tap";
|
||||
@@ -16,7 +16,7 @@ t.test("GET /api/v1/status", async (t) => {
|
||||
"Should be roughly the current time (5 seconds lenience)"
|
||||
);
|
||||
t.type(res.body.body.startTime, "number", "Should return a number for startTime.");
|
||||
t.equal(res.body.body.version, FormatVersion());
|
||||
t.equal(res.body.body.version, VERSION_PRETTY);
|
||||
t.equal(res.body.body.whoami, 1);
|
||||
|
||||
t.end();
|
||||
@@ -33,7 +33,7 @@ t.test("GET /api/v1/status", async (t) => {
|
||||
"Should be roughly the current time (5 seconds lenience)"
|
||||
);
|
||||
t.type(res.body.body.startTime, "number", "Should return a number for startTime.");
|
||||
t.equal(res.body.body.version, FormatVersion());
|
||||
t.equal(res.body.body.version, VERSION_PRETTY);
|
||||
t.equal(res.body.body.whoami, 1);
|
||||
|
||||
t.end();
|
||||
@@ -54,7 +54,7 @@ t.test("POST /api/v1/status", async (t) => {
|
||||
Math.abs(Date.now() - res.body.body.serverTime) < 5_000,
|
||||
"Should be roughly the current time (5 seconds lenience)"
|
||||
);
|
||||
t.equal(res.body.body.version, FormatVersion());
|
||||
t.equal(res.body.body.version, VERSION_PRETTY);
|
||||
t.equal(res.body.body.whoami, 1);
|
||||
t.type(res.body.body.startTime, "number", "Should return a number for startTime.");
|
||||
|
||||
@@ -73,7 +73,7 @@ t.test("POST /api/v1/status", async (t) => {
|
||||
Math.abs(Date.now() - res.body.body.serverTime) < 5_000,
|
||||
"Should be roughly the current time (5 seconds lenience)"
|
||||
);
|
||||
t.equal(res.body.body.version, FormatVersion());
|
||||
t.equal(res.body.body.version, VERSION_PRETTY);
|
||||
t.equal(res.body.body.whoami, 1);
|
||||
t.type(res.body.body.startTime, "number", "Should return a number for startTime.");
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Router } from "express";
|
||||
import { SYMBOL_TachiAPIAuth } from "lib/constants/tachi";
|
||||
import { FormatVersion } from "lib/constants/version";
|
||||
import { VERSION_PRETTY } from "lib/constants/version";
|
||||
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
|
||||
@@ -23,7 +23,7 @@ router.get("/", (req, res) => {
|
||||
body: {
|
||||
serverTime: Date.now(),
|
||||
startTime,
|
||||
version: FormatVersion(),
|
||||
version: VERSION_PRETTY,
|
||||
whoami: req[SYMBOL_TachiAPIAuth].userID,
|
||||
// converts {foo: true, bar: false, baz: true} into [foo, baz]
|
||||
permissions: Object.entries(req[SYMBOL_TachiAPIAuth].permissions)
|
||||
@@ -52,7 +52,7 @@ router.post("/", (req, res) => {
|
||||
body: {
|
||||
serverTime: Date.now(),
|
||||
startTime,
|
||||
version: FormatVersion(),
|
||||
version: VERSION_PRETTY,
|
||||
whoami: req[SYMBOL_TachiAPIAuth].userID,
|
||||
// converts {foo: true, bar: false, baz: true} into [foo, baz]
|
||||
permissions: Object.entries(req[SYMBOL_TachiAPIAuth].permissions)
|
||||
|
||||
Reference in New Issue
Block a user