aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/search/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-06 15:22:51 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commitaf971e06c620bd46a5aa64c8833364e7022b5e3d (patch)
tree4288b66b79fe4dd1ab9496e85a3abf7d747ad03a /shared/extra-utils/search/videos.ts
parent23a3a8827cb8b862f5cc7ee2819f39918303beca (diff)
downloadPeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.tar.gz
PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.tar.zst
PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.zip
Introduce search command
Diffstat (limited to 'shared/extra-utils/search/videos.ts')
-rw-r--r--shared/extra-utils/search/videos.ts64
1 files changed, 0 insertions, 64 deletions
diff --git a/shared/extra-utils/search/videos.ts b/shared/extra-utils/search/videos.ts
deleted file mode 100644
index db6edbd58..000000000
--- a/shared/extra-utils/search/videos.ts
+++ /dev/null
@@ -1,64 +0,0 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import * as request from 'supertest'
4import { VideosSearchQuery } from '../../models/search'
5import { immutableAssign } from '../miscs/miscs'
6import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
7
8function searchVideo (url: string, search: string, sort = '-publishedAt') {
9 const path = '/api/v1/search/videos'
10
11 const query = { sort, search: search }
12 const req = request(url)
13 .get(path)
14 .query(query)
15 .set('Accept', 'application/json')
16
17 return req.expect(HttpStatusCode.OK_200)
18 .expect('Content-Type', /json/)
19}
20
21function searchVideoWithToken (url: string, search: string, token: string, query: { nsfw?: boolean } = {}) {
22 const path = '/api/v1/search/videos'
23 const req = request(url)
24 .get(path)
25 .set('Authorization', 'Bearer ' + token)
26 .query(immutableAssign(query, { sort: '-publishedAt', search }))
27 .set('Accept', 'application/json')
28
29 return req.expect(HttpStatusCode.OK_200)
30 .expect('Content-Type', /json/)
31}
32
33function searchVideoWithSort (url: string, search: string, sort: string) {
34 const path = '/api/v1/search/videos'
35
36 const query = { search, sort }
37
38 return request(url)
39 .get(path)
40 .query(query)
41 .set('Accept', 'application/json')
42 .expect(HttpStatusCode.OK_200)
43 .expect('Content-Type', /json/)
44}
45
46function advancedVideosSearch (url: string, options: VideosSearchQuery) {
47 const path = '/api/v1/search/videos'
48
49 return request(url)
50 .get(path)
51 .query(options)
52 .set('Accept', 'application/json')
53 .expect(HttpStatusCode.OK_200)
54 .expect('Content-Type', /json/)
55}
56
57// ---------------------------------------------------------------------------
58
59export {
60 searchVideo,
61 advancedVideosSearch,
62 searchVideoWithToken,
63 searchVideoWithSort
64}