aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/mock-servers/joinpeertube-versions.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/mock-servers/joinpeertube-versions.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/mock-servers/joinpeertube-versions.ts')
-rw-r--r--shared/extra-utils/mock-servers/joinpeertube-versions.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/shared/extra-utils/mock-servers/joinpeertube-versions.ts b/shared/extra-utils/mock-servers/joinpeertube-versions.ts
new file mode 100644
index 000000000..d7d5b2c49
--- /dev/null
+++ b/shared/extra-utils/mock-servers/joinpeertube-versions.ts
@@ -0,0 +1,31 @@
1import * as express from 'express'
2
3export class MockJoinPeerTubeVersions {
4 private latestVersion: 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('/versions.json', (req: express.Request, res: express.Response) => {
17 return res.json({
18 peertube: {
19 latestVersion: this.latestVersion
20 }
21 })
22 })
23
24 app.listen(42102, () => res())
25 })
26 }
27
28 setLatestVersion (latestVersion: string) {
29 this.latestVersion = latestVersion
30 }
31}