diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-06 09:55:05 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:16 +0200 |
commit | e8bd7ce7ccafe3e064b03978e9b512c1a4cc99e6 (patch) | |
tree | c888e13aca3fc239f46d44045df6bf8e2a2ef0d3 /shared/extra-utils/custom-pages | |
parent | 329619b3453479f76c049816b7403b86e9d45cb5 (diff) | |
download | PeerTube-e8bd7ce7ccafe3e064b03978e9b512c1a4cc99e6.tar.gz PeerTube-e8bd7ce7ccafe3e064b03978e9b512c1a4cc99e6.tar.zst PeerTube-e8bd7ce7ccafe3e064b03978e9b512c1a4cc99e6.zip |
Introduce CustomPage command
Diffstat (limited to 'shared/extra-utils/custom-pages')
-rw-r--r-- | shared/extra-utils/custom-pages/custom-pages.ts | 47 | ||||
-rw-r--r-- | shared/extra-utils/custom-pages/index.ts | 1 |
2 files changed, 24 insertions, 24 deletions
diff --git a/shared/extra-utils/custom-pages/custom-pages.ts b/shared/extra-utils/custom-pages/custom-pages.ts index bf2d16c70..56dabdc0f 100644 --- a/shared/extra-utils/custom-pages/custom-pages.ts +++ b/shared/extra-utils/custom-pages/custom-pages.ts | |||
@@ -1,31 +1,30 @@ | |||
1 | import { CustomPage } from '@shared/models' | ||
1 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
2 | import { makeGetRequest, makePutBodyRequest } from '../requests/requests' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
3 | 4 | ||
4 | function getInstanceHomepage (url: string, statusCodeExpected = HttpStatusCode.OK_200) { | 5 | export class CustomPagesCommand extends AbstractCommand { |
5 | const path = '/api/v1/custom-pages/homepage/instance' | ||
6 | 6 | ||
7 | return makeGetRequest({ | 7 | getInstanceHomepage (options: OverrideCommandOptions = {}) { |
8 | url, | 8 | const path = '/api/v1/custom-pages/homepage/instance' |
9 | path, | ||
10 | statusCodeExpected | ||
11 | }) | ||
12 | } | ||
13 | |||
14 | function updateInstanceHomepage (url: string, token: string, content: string) { | ||
15 | const path = '/api/v1/custom-pages/homepage/instance' | ||
16 | 9 | ||
17 | return makePutBodyRequest({ | 10 | return this.getRequestBody<CustomPage>({ |
18 | url, | 11 | ...options, |
19 | path, | 12 | path, |
20 | token, | 13 | defaultExpectedStatus: HttpStatusCode.OK_200 |
21 | fields: { content }, | 14 | }) |
22 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 15 | } |
23 | }) | ||
24 | } | ||
25 | 16 | ||
26 | // --------------------------------------------------------------------------- | 17 | updateInstanceHomepage (options: OverrideCommandOptions & { |
18 | content: string | ||
19 | }) { | ||
20 | const { content } = options | ||
21 | const path = '/api/v1/custom-pages/homepage/instance' | ||
27 | 22 | ||
28 | export { | 23 | return this.putBodyRequest({ |
29 | getInstanceHomepage, | 24 | ...options, |
30 | updateInstanceHomepage | 25 | path, |
26 | fields: { content }, | ||
27 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
28 | }) | ||
29 | } | ||
31 | } | 30 | } |
diff --git a/shared/extra-utils/custom-pages/index.ts b/shared/extra-utils/custom-pages/index.ts new file mode 100644 index 000000000..5e70778f8 --- /dev/null +++ b/shared/extra-utils/custom-pages/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './custom-pages' | |||