aboutsummaryrefslogblamecommitdiffhomepage
path: root/shared/extra-utils/server/stats-command.ts
blob: b51d9ceefbb0f4e382dbe8479b013b292c975ea1 (plain) (tree)
























                                                                        
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<ServerStats>({
      ...options,

      path,
      query,
      defaultExpectedStatus: HttpStatusCode.OK_200
    })
  }
}