mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-27 12:08:02 -05:00
Refactor server version object into own interface
This makes the type of getServerVersionFromPackageJson() way easier to read. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
fc1008e773
commit
609b1cf3a3
2 changed files with 13 additions and 22 deletions
|
@ -5,24 +5,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { ServerStatusDto } from './server-status.dto';
|
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import { join as joinPath } from 'path';
|
import { join as joinPath } from 'path';
|
||||||
|
import { ServerStatusDto, ServerVersion } from './server-status.dto';
|
||||||
|
|
||||||
let versionCache: null | {
|
let versionCache: ServerVersion;
|
||||||
major: number;
|
|
||||||
minor: number;
|
async function getServerVersionFromPackageJson(): Promise<ServerVersion> {
|
||||||
patch: number;
|
|
||||||
preRelease?: string;
|
|
||||||
commit?: string;
|
|
||||||
} = null;
|
|
||||||
async function getServerVersionFromPackageJson(): Promise<{
|
|
||||||
major: number;
|
|
||||||
minor: number;
|
|
||||||
patch: number;
|
|
||||||
preRelease?: string;
|
|
||||||
commit?: string;
|
|
||||||
}> {
|
|
||||||
if (versionCache === null) {
|
if (versionCache === null) {
|
||||||
const rawFileContent: string = await fs.readFile(
|
const rawFileContent: string = await fs.readFile(
|
||||||
joinPath(__dirname, '../../package.json'),
|
joinPath(__dirname, '../../package.json'),
|
||||||
|
|
|
@ -4,14 +4,16 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export class ServerStatusDto {
|
export interface ServerVersion {
|
||||||
serverVersion: {
|
|
||||||
major: number;
|
major: number;
|
||||||
minor: number;
|
minor: number;
|
||||||
patch: number;
|
patch: number;
|
||||||
preRelease?: string;
|
preRelease?: string;
|
||||||
commit?: string;
|
commit?: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export class ServerStatusDto {
|
||||||
|
serverVersion: ServerVersion;
|
||||||
onlineNotes: number;
|
onlineNotes: number;
|
||||||
onlineUsers: number;
|
onlineUsers: number;
|
||||||
destictOnlineUsers: number;
|
destictOnlineUsers: number;
|
||||||
|
|
Loading…
Reference in a new issue