aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/feeds/feeds-command.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-06 10:22:37 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:16 +0200
commitf59545d97a80bf06025bf6343a80d834c7eb237f (patch)
tree7ed34f26b94964e8e707504da5fb90ff9d7486ad /shared/extra-utils/feeds/feeds-command.ts
parentc1bc8ee4783d6ce3102524e6c2a02b2f0f6aab6d (diff)
downloadPeerTube-f59545d97a80bf06025bf6343a80d834c7eb237f.tar.gz
PeerTube-f59545d97a80bf06025bf6343a80d834c7eb237f.tar.zst
PeerTube-f59545d97a80bf06025bf6343a80d834c7eb237f.zip
Rename command files
Diffstat (limited to 'shared/extra-utils/feeds/feeds-command.ts')
-rw-r--r--shared/extra-utils/feeds/feeds-command.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/shared/extra-utils/feeds/feeds-command.ts b/shared/extra-utils/feeds/feeds-command.ts
new file mode 100644
index 000000000..8031adf92
--- /dev/null
+++ b/shared/extra-utils/feeds/feeds-command.ts
@@ -0,0 +1,42 @@
1
2import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3import { AbstractCommand, OverrideCommandOptions } from '../shared'
4
5type FeedType = 'videos' | 'video-comments' | 'subscriptions'
6
7export class FeedCommand extends AbstractCommand {
8
9 getXML (options: OverrideCommandOptions & {
10 feed: FeedType
11 format?: string
12 }) {
13 const { feed, format } = options
14 const path = '/feeds/' + feed + '.xml'
15
16 return this.getRequestText({
17 ...options,
18
19 path,
20 query: format ? { format } : undefined,
21 accept: 'application/xml',
22 defaultExpectedStatus: HttpStatusCode.OK_200
23 })
24 }
25
26 getJSON (options: OverrideCommandOptions & {
27 feed: FeedType
28 query?: { [ id: string ]: any }
29 }) {
30 const { feed, query } = options
31 const path = '/feeds/' + feed + '.json'
32
33 return this.getRequestText({
34 ...options,
35
36 path,
37 query,
38 accept: 'application/json',
39 defaultExpectedStatus: HttpStatusCode.OK_200
40 })
41 }
42}