aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/instances-index/mock-instances-index.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-03-11 16:54:52 +0100
committerChocobozzz <me@florianbigard.com>2021-03-24 18:18:41 +0100
commit32a18cbf33a7cdbbe3d4885d32e4b67e19cdc1cf (patch)
tree1db53245688a6b7839cab00f9d65e6c1c1774b00 /shared/extra-utils/instances-index/mock-instances-index.ts
parent3fbc6974334ca58c068f0f9def0b0a40db2a6de1 (diff)
downloadPeerTube-32a18cbf33a7cdbbe3d4885d32e4b67e19cdc1cf.tar.gz
PeerTube-32a18cbf33a7cdbbe3d4885d32e4b67e19cdc1cf.tar.zst
PeerTube-32a18cbf33a7cdbbe3d4885d32e4b67e19cdc1cf.zip
Add new plugin/peertube version notifs
Diffstat (limited to 'shared/extra-utils/instances-index/mock-instances-index.ts')
-rw-r--r--shared/extra-utils/instances-index/mock-instances-index.ts38
1 files changed, 0 insertions, 38 deletions
diff --git a/shared/extra-utils/instances-index/mock-instances-index.ts b/shared/extra-utils/instances-index/mock-instances-index.ts
deleted file mode 100644
index 2604eda03..000000000
--- a/shared/extra-utils/instances-index/mock-instances-index.ts
+++ /dev/null
@@ -1,38 +0,0 @@
1import * as express from 'express'
2
3export class MockInstancesIndex {
4 private readonly indexInstances: { host: string, createdAt: string }[] = []
5
6 initialize () {
7 return new Promise<void>(res => {
8 const app = express()
9
10 app.use('/', (req: express.Request, res: express.Response, next: express.NextFunction) => {
11 if (process.env.DEBUG) console.log('Receiving request on mocked server %s.', req.url)
12
13 return next()
14 })
15
16 app.get('/api/v1/instances/hosts', (req: express.Request, res: express.Response) => {
17 const since = req.query.since
18
19 const filtered = this.indexInstances.filter(i => {
20 if (!since) return true
21
22 return i.createdAt > since
23 })
24
25 return res.json({
26 total: filtered.length,
27 data: filtered
28 })
29 })
30
31 app.listen(42101, () => res())
32 })
33 }
34
35 addInstance (host: string) {
36 this.indexInstances.push({ host, createdAt: new Date().toISOString() })
37 }
38}