なんかもうめっちゃ変えた
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as os from 'node:os';
|
||||
import si from 'systeminformation';
|
||||
import define from '../define.js';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
|
||||
export const meta = {
|
||||
requireCredential: false,
|
||||
@@ -15,22 +16,28 @@ export const paramDef = {
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async () => {
|
||||
const memStats = await si.mem();
|
||||
const fsStats = await si.fsSize();
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
constructor(
|
||||
) {
|
||||
super(meta, paramDef, async () => {
|
||||
const memStats = await si.mem();
|
||||
const fsStats = await si.fsSize();
|
||||
|
||||
return {
|
||||
machine: os.hostname(),
|
||||
cpu: {
|
||||
model: os.cpus()[0].model,
|
||||
cores: os.cpus().length,
|
||||
},
|
||||
mem: {
|
||||
total: memStats.total,
|
||||
},
|
||||
fs: {
|
||||
total: fsStats[0].size,
|
||||
used: fsStats[0].used,
|
||||
},
|
||||
};
|
||||
});
|
||||
return {
|
||||
machine: os.hostname(),
|
||||
cpu: {
|
||||
model: os.cpus()[0].model,
|
||||
cores: os.cpus().length,
|
||||
},
|
||||
mem: {
|
||||
total: memStats.total,
|
||||
},
|
||||
fs: {
|
||||
total: fsStats[0].size,
|
||||
used: fsStats[0].used,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user