perf(backend): make some features optionable
Resolve #11064 Resolve #11065
This commit is contained in:
parent
734c41aba5
commit
af3258dc79
13 changed files with 105 additions and 8 deletions
|
|
@ -2,9 +2,12 @@ import * as os from 'node:os';
|
|||
import si from 'systeminformation';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
|
||||
export const meta = {
|
||||
requireCredential: false,
|
||||
allowGet: true,
|
||||
cacheSec: 60 * 1,
|
||||
|
||||
tags: ['meta'],
|
||||
} as const;
|
||||
|
|
@ -19,8 +22,24 @@ export const paramDef = {
|
|||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
constructor(
|
||||
private metaService: MetaService,
|
||||
) {
|
||||
super(meta, paramDef, async () => {
|
||||
if (!(await this.metaService.fetch()).enableServerMachineStats) return {
|
||||
machine: '?',
|
||||
cpu: {
|
||||
model: '?',
|
||||
cores: 0,
|
||||
},
|
||||
mem: {
|
||||
total: 0,
|
||||
},
|
||||
fs: {
|
||||
total: 0,
|
||||
used: 0,
|
||||
},
|
||||
};
|
||||
|
||||
const memStats = await si.mem();
|
||||
const fsStats = await si.fsSize();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue