diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-15 15:26:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:25:52 +0200 |
commit | 94565d52bb2883e09f16d1363170ac9c0dccb7a1 (patch) | |
tree | 3dcd20cd7b5a5cca80bce32b655cdbfaddf7aa59 /shared/extra-utils/feeds/feeds.ts | |
parent | 4ee7a4c9ac9280cda930a281c2d5a9a4c409cc14 (diff) | |
download | PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.tar.gz PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.tar.zst PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.zip |
Shared utils -> extra-utils
Because they need dev dependencies
Diffstat (limited to 'shared/extra-utils/feeds/feeds.ts')
-rw-r--r-- | shared/extra-utils/feeds/feeds.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/shared/extra-utils/feeds/feeds.ts b/shared/extra-utils/feeds/feeds.ts new file mode 100644 index 000000000..af6df2b20 --- /dev/null +++ b/shared/extra-utils/feeds/feeds.ts | |||
@@ -0,0 +1,32 @@ | |||
1 | import * as request from 'supertest' | ||
2 | |||
3 | type FeedType = 'videos' | 'video-comments' | ||
4 | |||
5 | function getXMLfeed (url: string, feed: FeedType, format?: string) { | ||
6 | const path = '/feeds/' + feed + '.xml' | ||
7 | |||
8 | return request(url) | ||
9 | .get(path) | ||
10 | .query((format) ? { format: format } : {}) | ||
11 | .set('Accept', 'application/xml') | ||
12 | .expect(200) | ||
13 | .expect('Content-Type', /xml/) | ||
14 | } | ||
15 | |||
16 | function getJSONfeed (url: string, feed: FeedType, query: any = {}) { | ||
17 | const path = '/feeds/' + feed + '.json' | ||
18 | |||
19 | return request(url) | ||
20 | .get(path) | ||
21 | .query(query) | ||
22 | .set('Accept', 'application/json') | ||
23 | .expect(200) | ||
24 | .expect('Content-Type', /json/) | ||
25 | } | ||
26 | |||
27 | // --------------------------------------------------------------------------- | ||
28 | |||
29 | export { | ||
30 | getXMLfeed, | ||
31 | getJSONfeed | ||
32 | } | ||