]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/extra-utils/requests/check-api-params.ts
chore(refactor): remove shared folder dependencies to the server
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / requests / check-api-params.ts
CommitLineData
c0e8b12e 1import { HttpStatusCode } from '@shared/models'
eec63bbc
C
2import { makeGetRequest } from './requests'
3
d525fc39 4function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
eec63bbc
C
5 return makeGetRequest({
6 url,
7 path,
93e4a311 8 token,
6c5065a0 9 query: { ...query, start: 'hello' },
c0e8b12e 10 expectedStatus: HttpStatusCode.BAD_REQUEST_400
eec63bbc
C
11 })
12}
13
e0b56b74
C
14async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {
15 await makeGetRequest({
eec63bbc
C
16 url,
17 path,
93e4a311 18 token,
6c5065a0 19 query: { ...query, count: 'hello' },
c0e8b12e 20 expectedStatus: HttpStatusCode.BAD_REQUEST_400
eec63bbc 21 })
e0b56b74
C
22
23 await makeGetRequest({
24 url,
25 path,
26 token,
6c5065a0 27 query: { ...query, count: 2000 },
c0e8b12e 28 expectedStatus: HttpStatusCode.BAD_REQUEST_400
e0b56b74 29 })
eec63bbc
C
30}
31
d525fc39 32function checkBadSortPagination (url: string, path: string, token?: string, query = {}) {
eec63bbc
C
33 return makeGetRequest({
34 url,
35 path,
93e4a311 36 token,
6c5065a0 37 query: { ...query, sort: 'hello' },
c0e8b12e 38 expectedStatus: HttpStatusCode.BAD_REQUEST_400
eec63bbc
C
39 })
40}
41
42// ---------------------------------------------------------------------------
43
44export {
45 checkBadStartPagination,
46 checkBadCountPagination,
47 checkBadSortPagination
48}