Merge branch 'release/2.2.0' into develop
[oweals/peertube.git] / shared / extra-utils / plugins / mock-blocklist.ts
1 import * as express from 'express'
2
3 type BlocklistResponse = {
4   data: {
5     value: string
6     action?: 'add' | 'remove'
7     updatedAt?: string
8   }[]
9 }
10
11 export class MockBlocklist {
12   private body: BlocklistResponse
13
14   initialize () {
15     return new Promise(res => {
16       const app = express()
17
18       app.get('/blocklist', (req: express.Request, res: express.Response) => {
19         return res.json(this.body)
20       })
21
22       app.listen(42100, () => res())
23     })
24   }
25
26   replace (body: BlocklistResponse) {
27     this.body = body
28   }
29 }