diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-06 14:07:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:17 +0200 |
commit | 480d6ea6791fe4100f1905af1e1e3a08173594ea (patch) | |
tree | e0752890d611decc3db5d54dc3203860d8140e24 /shared/extra-utils/plugins | |
parent | 0c1a77e9ccf915184c431145a8b326d4ce271b46 (diff) | |
download | PeerTube-480d6ea6791fe4100f1905af1e1e3a08173594ea.tar.gz PeerTube-480d6ea6791fe4100f1905af1e1e3a08173594ea.tar.zst PeerTube-480d6ea6791fe4100f1905af1e1e3a08173594ea.zip |
Move plugin blocklist mock
Diffstat (limited to 'shared/extra-utils/plugins')
-rw-r--r-- | shared/extra-utils/plugins/mock-blocklist.ts | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/shared/extra-utils/plugins/mock-blocklist.ts b/shared/extra-utils/plugins/mock-blocklist.ts deleted file mode 100644 index d18f8224f..000000000 --- a/shared/extra-utils/plugins/mock-blocklist.ts +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | import * as express from 'express' | ||
2 | import { Server } from 'http' | ||
3 | import { randomInt } from '@shared/core-utils' | ||
4 | |||
5 | type BlocklistResponse = { | ||
6 | data: { | ||
7 | value: string | ||
8 | action?: 'add' | 'remove' | ||
9 | updatedAt?: string | ||
10 | }[] | ||
11 | } | ||
12 | |||
13 | export class MockBlocklist { | ||
14 | private body: BlocklistResponse | ||
15 | private server: Server | ||
16 | |||
17 | initialize () { | ||
18 | return new Promise<number>(res => { | ||
19 | const app = express() | ||
20 | |||
21 | app.get('/blocklist', (req: express.Request, res: express.Response) => { | ||
22 | return res.json(this.body) | ||
23 | }) | ||
24 | |||
25 | const port = 42201 + randomInt(1, 100) | ||
26 | this.server = app.listen(port, () => res(port)) | ||
27 | }) | ||
28 | } | ||
29 | |||
30 | replace (body: BlocklistResponse) { | ||
31 | this.body = body | ||
32 | } | ||
33 | |||
34 | terminate () { | ||
35 | if (this.server) this.server.close() | ||
36 | } | ||
37 | } | ||