]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server.js
Video model refractoring -> use mongoose api
[github/Chocobozzz/PeerTube.git] / server.js
index 9772ce92b63eb2fbb4e79108b960da7360618a99..63aeb7145959348f3e406cae86cfa70132616e58 100644 (file)
--- a/server.js
+++ b/server.js
@@ -28,10 +28,9 @@ const customValidators = require('./server/helpers/customValidators')
 const database = require('./server/initializers/database')
 const installer = require('./server/initializers/installer')
 const logger = require('./server/helpers/logger')
-const poolRequests = require('./server/lib/poolRequests')
+const poolRequests = require('./server/lib/requestsScheduler')
 const routes = require('./server/controllers')
 const utils = require('./server/helpers/utils')
-const videos = require('./server/lib/videos')
 const webtorrent = require('./server/lib/webtorrent')
 
 // Get configurations
@@ -56,28 +55,27 @@ app.use(expressValidator({
 
 // ----------- Views, routes and static files -----------
 
-// Livereload
-app.use(require('connect-livereload')({
-  port: 35729
-}))
-
 // Catch sefaults
 require('segfault-handler').registerHandler()
 
 // API routes
-const api_route = '/api/' + constants.API_VERSION
-app.use(api_route, routes.api)
+const apiRoute = '/api/' + constants.API_VERSION
+app.use(apiRoute, routes.api)
 
 // Static files
-app.use('/app', express.static(path.join(__dirname, '/client'), { maxAge: 0 }))
+app.use('/client', express.static(path.join(__dirname, '/client/dist'), { maxAge: 0 }))
 // 404 for static files not found
-app.use('/app/*', function (req, res, next) {
+app.use('/client/*', function (req, res, next) {
   res.sendStatus(404)
 })
 
+// Thumbnails path for express
+const thumbnailsPhysicalPath = path.join(__dirname, config.get('storage.thumbnails'))
+app.use(constants.THUMBNAILS_STATIC_PATH, express.static(thumbnailsPhysicalPath, { maxAge: 0 }))
+
 // Client application
 app.use('/*', function (req, res, next) {
-  res.sendFile(path.join(__dirname, 'client/index.html'))
+  res.sendFile(path.join(__dirname, 'client/dist/index.html'))
 })
 
 // ----------- Tracker -----------
@@ -139,11 +137,11 @@ installer.installApplication(function (err) {
       // Activate the pool requests
       poolRequests.activate()
 
-      videos.seedAllExisting(function () {
+      // videos.seedAllExisting(function () {
         logger.info('Seeded all the videos')
         logger.info('Server listening on port %d', port)
         app.emit('ready')
-      })
+      // })
     })
   })
 })