aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-12-26 10:36:24 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-01-09 11:15:15 +0100
commitcef534ed53e4518fe0acf581bfe880788d42fc36 (patch)
tree115b51ea5136849a2336d44915c7780649f25dc2 /server.ts
parent1de1d05f4c61fe059fa5e24e79c92582f0e7e4b3 (diff)
downloadPeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.gz
PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.zst
PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.zip
Add user notification base code
Diffstat (limited to 'server.ts')
-rw-r--r--server.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/server.ts b/server.ts
index 868a03ba4..b50151859 100644
--- a/server.ts
+++ b/server.ts
@@ -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)
30import { logger } from './server/helpers/logger' 30import { logger } from './server/helpers/logger'
31import { API_VERSION, CONFIG, CACHE, HTTP_SIGNATURE } from './server/initializers/constants' 31import { API_VERSION, CONFIG, CACHE } from './server/initializers/constants'
32 32
33const missed = checkMissedConfig() 33const missed = checkMissedConfig()
34if (missed.length !== 0) { 34if (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'
95import { advertiseDoNotTrack } from './server/middlewares/dnt' 95import { advertiseDoNotTrack } from './server/middlewares/dnt'
96import { Redis } from './server/lib/redis' 96import { Redis } from './server/lib/redis'
@@ -100,6 +100,7 @@ import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-sch
100import { YoutubeDlUpdateScheduler } from './server/lib/schedulers/youtube-dl-update-scheduler' 100import { YoutubeDlUpdateScheduler } from './server/lib/schedulers/youtube-dl-update-scheduler'
101import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redundancy-scheduler' 101import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redundancy-scheduler'
102import { isHTTPSignatureDigestValid } from './server/helpers/peertube-crypto' 102import { isHTTPSignatureDigestValid } from './server/helpers/peertube-crypto'
103import { 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 }))
136app.use(bodyParser.json({ 137app.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
192const server = createWebsocketServer(app) 193const 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)