diff options
author | Chocobozzz <me@florianbigard.com> | 2018-12-26 10:36:24 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-01-09 11:15:15 +0100 |
commit | cef534ed53e4518fe0acf581bfe880788d42fc36 (patch) | |
tree | 115b51ea5136849a2336d44915c7780649f25dc2 /server.ts | |
parent | 1de1d05f4c61fe059fa5e24e79c92582f0e7e4b3 (diff) | |
download | PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.gz PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.zst PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.zip |
Add user notification base code
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -28,7 +28,7 @@ import { checkMissedConfig, checkFFmpeg } from './server/initializers/checker-be | |||
28 | 28 | ||
29 | // Do not use barrels because we don't want to load all modules here (we need to initialize database first) | 29 | // Do not use barrels because we don't want to load all modules here (we need to initialize database first) |
30 | import { logger } from './server/helpers/logger' | 30 | import { logger } from './server/helpers/logger' |
31 | import { API_VERSION, CONFIG, CACHE, HTTP_SIGNATURE } from './server/initializers/constants' | 31 | import { API_VERSION, CONFIG, CACHE } from './server/initializers/constants' |
32 | 32 | ||
33 | const missed = checkMissedConfig() | 33 | const missed = checkMissedConfig() |
34 | if (missed.length !== 0) { | 34 | if (missed.length !== 0) { |
@@ -90,7 +90,7 @@ import { | |||
90 | servicesRouter, | 90 | servicesRouter, |
91 | webfingerRouter, | 91 | webfingerRouter, |
92 | trackerRouter, | 92 | trackerRouter, |
93 | createWebsocketServer, botsRouter | 93 | createWebsocketTrackerServer, botsRouter |
94 | } from './server/controllers' | 94 | } from './server/controllers' |
95 | import { advertiseDoNotTrack } from './server/middlewares/dnt' | 95 | import { advertiseDoNotTrack } from './server/middlewares/dnt' |
96 | import { Redis } from './server/lib/redis' | 96 | import { Redis } from './server/lib/redis' |
@@ -100,6 +100,7 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch | |||
100 | import { YoutubeDlUpdateScheduler } from './server/lib/schedulers/youtube-dl-update-scheduler' | 100 | import { YoutubeDlUpdateScheduler } from './server/lib/schedulers/youtube-dl-update-scheduler' |
101 | import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redundancy-scheduler' | 101 | import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redundancy-scheduler' |
102 | import { isHTTPSignatureDigestValid } from './server/helpers/peertube-crypto' | 102 | import { isHTTPSignatureDigestValid } from './server/helpers/peertube-crypto' |
103 | import { PeerTubeSocket } from './server/lib/peertube-socket' | ||
103 | 104 | ||
104 | // ----------- Command line ----------- | 105 | // ----------- Command line ----------- |
105 | 106 | ||
@@ -136,7 +137,7 @@ app.use(bodyParser.urlencoded({ extended: false })) | |||
136 | app.use(bodyParser.json({ | 137 | app.use(bodyParser.json({ |
137 | type: [ 'application/json', 'application/*+json' ], | 138 | type: [ 'application/json', 'application/*+json' ], |
138 | limit: '500kb', | 139 | limit: '500kb', |
139 | verify: (req: express.Request, _, buf: Buffer, encoding: string) => { | 140 | verify: (req: express.Request, _, buf: Buffer) => { |
140 | const valid = isHTTPSignatureDigestValid(buf, req) | 141 | const valid = isHTTPSignatureDigestValid(buf, req) |
141 | if (valid !== true) throw new Error('Invalid digest') | 142 | if (valid !== true) throw new Error('Invalid digest') |
142 | } | 143 | } |
@@ -189,7 +190,7 @@ app.use(function (err, req, res, next) { | |||
189 | return res.status(err.status || 500).end() | 190 | return res.status(err.status || 500).end() |
190 | }) | 191 | }) |
191 | 192 | ||
192 | const server = createWebsocketServer(app) | 193 | const server = createWebsocketTrackerServer(app) |
193 | 194 | ||
194 | // ----------- Run ----------- | 195 | // ----------- Run ----------- |
195 | 196 | ||
@@ -228,6 +229,8 @@ async function startApplication () { | |||
228 | // Redis initialization | 229 | // Redis initialization |
229 | Redis.Instance.init() | 230 | Redis.Instance.init() |
230 | 231 | ||
232 | PeerTubeSocket.Instance.init(server) | ||
233 | |||
231 | // Make server listening | 234 | // Make server listening |
232 | server.listen(port, hostname, () => { | 235 | server.listen(port, hostname, () => { |
233 | logger.info('Server listening on %s:%d', hostname, port) | 236 | logger.info('Server listening on %s:%d', hostname, port) |