From bc8090411ddaa8d742ce4de3c83f9dba7bc18e2a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 11:07:12 +0200 Subject: Introduce stats command --- shared/extra-utils/server/stats-command.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 shared/extra-utils/server/stats-command.ts (limited to 'shared/extra-utils/server/stats-command.ts') diff --git a/shared/extra-utils/server/stats-command.ts b/shared/extra-utils/server/stats-command.ts new file mode 100644 index 000000000..b51d9ceef --- /dev/null +++ b/shared/extra-utils/server/stats-command.ts @@ -0,0 +1,25 @@ +import { ServerStats } from '@shared/models' +import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' +import { AbstractCommand, OverrideCommandOptions } from '../shared' + +export class StatsCommand extends AbstractCommand { + + get (options: OverrideCommandOptions & { + useCache?: boolean // default false + } = {}) { + const { useCache = false } = options + const path = '/api/v1/server/stats' + + const query = { + t: useCache ? undefined : new Date().getTime() + } + + return this.getRequestBody({ + ...options, + + path, + query, + defaultExpectedStatus: HttpStatusCode.OK_200 + }) + } +} -- cgit v1.2.3