]>
Commit | Line | Data |
---|---|---|
8bff1fe0 C |
1 | import * as express from 'express' |
2 | ||
3 | type BlocklistResponse = { | |
4 | data: { | |
5 | value: string | |
6 | action?: 'add' | 'remove' | |
91b8e675 | 7 | updatedAt?: string |
8bff1fe0 C |
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 | } |