mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-23 10:16:32 -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 { ServerStatusDto } from './server-status.dto';
|
||||
import { promises as fs } from 'fs';
|
||||
import { join as joinPath } from 'path';
|
||||
import { ServerStatusDto, ServerVersion } from './server-status.dto';
|
||||
|
||||
let versionCache: null | {
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
preRelease?: string;
|
||||
commit?: string;
|
||||
} = null;
|
||||
async function getServerVersionFromPackageJson(): Promise<{
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
preRelease?: string;
|
||||
commit?: string;
|
||||
}> {
|
||||
let versionCache: ServerVersion;
|
||||
|
||||
async function getServerVersionFromPackageJson(): Promise<ServerVersion> {
|
||||
if (versionCache === null) {
|
||||
const rawFileContent: string = await fs.readFile(
|
||||
joinPath(__dirname, '../../package.json'),
|
||||
|
|
|
@ -4,14 +4,16 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export interface ServerVersion {
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
preRelease?: string;
|
||||
commit?: string;
|
||||
}
|
||||
|
||||
export class ServerStatusDto {
|
||||
serverVersion: {
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
preRelease?: string;
|
||||
commit?: string;
|
||||
};
|
||||
serverVersion: ServerVersion;
|
||||
onlineNotes: number;
|
||||
onlineUsers: number;
|
||||
destictOnlineUsers: number;
|
||||
|
|
Loading…
Reference in a new issue