aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils')
-rw-r--r--shared/extra-utils/index.ts4
-rw-r--r--shared/extra-utils/server/index.ts3
-rw-r--r--shared/extra-utils/server/servers.ts3
-rw-r--r--shared/extra-utils/server/stats-command.ts25
-rw-r--r--shared/extra-utils/server/stats.ts23
5 files changed, 31 insertions, 27 deletions
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts
index cf6418249..f69d7241e 100644
--- a/shared/extra-utils/index.ts
+++ b/shared/extra-utils/index.ts
@@ -13,10 +13,6 @@ export * from './server'
13export * from './requests/check-api-params' 13export * from './requests/check-api-params'
14export * from './requests/requests' 14export * from './requests/requests'
15 15
16export * from './server/clients'
17export * from './server/config'
18export * from './server/servers'
19
20export * from './users/accounts' 16export * from './users/accounts'
21export * from './users/blocklist' 17export * from './users/blocklist'
22export * from './users/login' 18export * from './users/login'
diff --git a/shared/extra-utils/server/index.ts b/shared/extra-utils/server/index.ts
index 3ee70f0cf..d37f46321 100644
--- a/shared/extra-utils/server/index.ts
+++ b/shared/extra-utils/server/index.ts
@@ -1,3 +1,4 @@
1export * from './config'
1export * from './contact-form-command' 2export * from './contact-form-command'
2export * from './debug-command' 3export * from './debug-command'
3export * from './follows-command' 4export * from './follows-command'
@@ -7,3 +8,5 @@ export * from './jobs-command'
7export * from './plugins-command' 8export * from './plugins-command'
8export * from './plugins' 9export * from './plugins'
9export * from './redundancy-command' 10export * from './redundancy-command'
11export * from './servers'
12export * from './stats-command'
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index eaf39ecea..4603cf62e 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -22,6 +22,7 @@ import { FollowsCommand } from './follows-command'
22import { JobsCommand } from './jobs-command' 22import { JobsCommand } from './jobs-command'
23import { PluginsCommand } from './plugins-command' 23import { PluginsCommand } from './plugins-command'
24import { RedundancyCommand } from './redundancy-command' 24import { RedundancyCommand } from './redundancy-command'
25import { StatsCommand } from './stats-command'
25 26
26interface ServerInfo { 27interface ServerInfo {
27 app: ChildProcess 28 app: ChildProcess
@@ -89,6 +90,7 @@ interface ServerInfo {
89 jobsCommand?: JobsCommand 90 jobsCommand?: JobsCommand
90 pluginsCommand?: PluginsCommand 91 pluginsCommand?: PluginsCommand
91 redundancyCommand?: RedundancyCommand 92 redundancyCommand?: RedundancyCommand
93 statsCommand?: StatsCommand
92} 94}
93 95
94function parallelTests () { 96function parallelTests () {
@@ -308,6 +310,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
308 server.jobsCommand = new JobsCommand(server) 310 server.jobsCommand = new JobsCommand(server)
309 server.pluginsCommand = new PluginsCommand(server) 311 server.pluginsCommand = new PluginsCommand(server)
310 server.redundancyCommand = new RedundancyCommand(server) 312 server.redundancyCommand = new RedundancyCommand(server)
313 server.statsCommand = new StatsCommand(server)
311 314
312 res(server) 315 res(server)
313 }) 316 })
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 @@
1import { ServerStats } from '@shared/models'
2import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3import { AbstractCommand, OverrideCommandOptions } from '../shared'
4
5export class StatsCommand extends AbstractCommand {
6
7 get (options: OverrideCommandOptions & {
8 useCache?: boolean // default false
9 } = {}) {
10 const { useCache = false } = options
11 const path = '/api/v1/server/stats'
12
13 const query = {
14 t: useCache ? undefined : new Date().getTime()
15 }
16
17 return this.getRequestBody<ServerStats>({
18 ...options,
19
20 path,
21 query,
22 defaultExpectedStatus: HttpStatusCode.OK_200
23 })
24 }
25}
diff --git a/shared/extra-utils/server/stats.ts b/shared/extra-utils/server/stats.ts
deleted file mode 100644
index b9dae24e2..000000000
--- a/shared/extra-utils/server/stats.ts
+++ /dev/null
@@ -1,23 +0,0 @@
1import { makeGetRequest } from '../requests/requests'
2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3
4function getStats (url: string, useCache = false) {
5 const path = '/api/v1/server/stats'
6
7 const query = {
8 t: useCache ? undefined : new Date().getTime()
9 }
10
11 return makeGetRequest({
12 url,
13 path,
14 query,
15 statusCodeExpected: HttpStatusCode.OK_200
16 })
17}
18
19// ---------------------------------------------------------------------------
20
21export {
22 getStats
23}