mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-15 11:33:09 +02:00
63df2c851e
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
43 lines
865 B
TypeScript
43 lines
865 B
TypeScript
import * as os from 'node:os';
|
|
import si from 'systeminformation';
|
|
import { Injectable } from '@nestjs/common';
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
|
|
export const meta = {
|
|
requireCredential: false,
|
|
|
|
tags: ['meta'],
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {},
|
|
required: [],
|
|
} as const;
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
@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,
|
|
},
|
|
};
|
|
});
|
|
}
|
|
}
|