aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/overviews
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-06 14:30:20 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commit23a3a8827cb8b862f5cc7ee2819f39918303beca (patch)
tree93a3bdbd02787d32094d6d50aa209f2c079038a5 /shared/extra-utils/overviews
parent480d6ea6791fe4100f1905af1e1e3a08173594ea (diff)
downloadPeerTube-23a3a8827cb8b862f5cc7ee2819f39918303beca.tar.gz
PeerTube-23a3a8827cb8b862f5cc7ee2819f39918303beca.tar.zst
PeerTube-23a3a8827cb8b862f5cc7ee2819f39918303beca.zip
Introduce overviews command
Diffstat (limited to 'shared/extra-utils/overviews')
-rw-r--r--shared/extra-utils/overviews/index.ts1
-rw-r--r--shared/extra-utils/overviews/overviews-command.ts25
-rw-r--r--shared/extra-utils/overviews/overviews.ts34
3 files changed, 26 insertions, 34 deletions
diff --git a/shared/extra-utils/overviews/index.ts b/shared/extra-utils/overviews/index.ts
new file mode 100644
index 000000000..e19551907
--- /dev/null
+++ b/shared/extra-utils/overviews/index.ts
@@ -0,0 +1 @@
export * from './overviews-command'
diff --git a/shared/extra-utils/overviews/overviews-command.ts b/shared/extra-utils/overviews/overviews-command.ts
new file mode 100644
index 000000000..0ac3cbd33
--- /dev/null
+++ b/shared/extra-utils/overviews/overviews-command.ts
@@ -0,0 +1,25 @@
1import { HttpStatusCode } from '@shared/core-utils'
2import { VideosOverview } from '@shared/models'
3import { AbstractCommand, OverrideCommandOptions } from '../shared'
4
5export class OverviewsCommand extends AbstractCommand {
6
7 getVideos (options: OverrideCommandOptions & {
8 page: number
9 token?: string
10 }) {
11 const { token, page } = options
12 const path = '/api/v1/overviews/videos'
13
14 const query = { page }
15
16 return this.getRequestBody<VideosOverview>({
17 ...options,
18
19 token: token || null,
20 path,
21 query,
22 defaultExpectedStatus: HttpStatusCode.OK_200
23 })
24 }
25}
diff --git a/shared/extra-utils/overviews/overviews.ts b/shared/extra-utils/overviews/overviews.ts
deleted file mode 100644
index 5e1a13e5e..000000000
--- a/shared/extra-utils/overviews/overviews.ts
+++ /dev/null
@@ -1,34 +0,0 @@
1import { makeGetRequest } from '../requests/requests'
2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3
4function getVideosOverview (url: string, page: number, statusCodeExpected = HttpStatusCode.OK_200) {
5 const path = '/api/v1/overviews/videos'
6
7 const query = { page }
8
9 return makeGetRequest({
10 url,
11 path,
12 query,
13 statusCodeExpected
14 })
15}
16
17function getVideosOverviewWithToken (url: string, page: number, token: string, statusCodeExpected = HttpStatusCode.OK_200) {
18 const path = '/api/v1/overviews/videos'
19
20 const query = { page }
21
22 return makeGetRequest({
23 url,
24 path,
25 query,
26 token,
27 statusCodeExpected
28 })
29}
30
31export {
32 getVideosOverview,
33 getVideosOverviewWithToken
34}