aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/logs/logs-command.ts
blob: f7594734daa57876f8c8e33cf2b5714b112e0a1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
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 },
      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 },
      defaultExpectedStatus: HttpStatusCode.OK_200
    })
  }

}