aboutsummaryrefslogblamecommitdiffhomepage
path: root/shared/extra-utils/logs/logs-command.ts
blob: 5912e814f3fd4c91e683002b35352ac456b7b3a0 (plain) (tree)
1
                                               

















                                                                   
                          
















                                                   
                          




                                                  
import { HttpStatusCode } from '@shared/models'
import { LogLevel } from '../../models/server/log-level.type'
import { AbstractCommand, OverrideCommandOptions } from '../shared'

export class LogsCommand extends AbstractCommand {

  getLogs (options: OverrideCommandOptions & {
    startDate: Date
    endDate?: Date
    level?: LogLevel
  }) {
    const { startDate, endDate, level } = options
    const path = '/api/v1/server/logs'

    return this.getRequestBody({
      ...options,

      path,
      query: { startDate, endDate, level },
      implicitToken: true,
      defaultExpectedStatus: HttpStatusCode.OK_200
    })
  }

  getAuditLogs (options: OverrideCommandOptions & {
    startDate: Date
    endDate?: Date
  }) {
    const { startDate, endDate } = options

    const path = '/api/v1/server/audit-logs'

    return this.getRequestBody({
      ...options,

      path,
      query: { startDate, endDate },
      implicitToken: true,
      defaultExpectedStatus: HttpStatusCode.OK_200
    })
  }

}