]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server.ts
Add ability for uploaders to schedule video update
[github/Chocobozzz/PeerTube.git] / server.ts
index 8024655a35dfcbfebe7fe9f468adaf996ce2f225..ef89ff5f653dad11ef915af1dc13efc3c0e4032c 100644 (file)
--- a/server.ts
+++ b/server.ts
@@ -1,4 +1,6 @@
 // FIXME: https://github.com/nodejs/node/pull/16853
+import { ScheduleVideoUpdateModel } from './server/models/video/schedule-video-update'
+
 require('tls').DEFAULT_ECDH_CURVE = 'auto'
 
 import { isTestInstance } from './server/helpers/core-utils'
@@ -12,7 +14,6 @@ import * as bodyParser from 'body-parser'
 import * as express from 'express'
 import * as http from 'http'
 import * as morgan from 'morgan'
-import * as path from 'path'
 import * as bitTorrentTracker from 'bittorrent-tracker'
 import * as cors from 'cors'
 import { Server as WebSocketServer } from 'ws'
@@ -29,7 +30,7 @@ import { checkMissedConfig, checkFFmpeg, checkConfig } from './server/initialize
 
 // Do not use barrels because we don't want to load all modules here (we need to initialize database first)
 import { logger } from './server/helpers/logger'
-import { ACCEPT_HEADERS, API_VERSION, CONFIG, STATIC_PATHS } from './server/initializers/constants'
+import { API_VERSION, CONFIG, STATIC_PATHS } from './server/initializers/constants'
 
 const missed = checkMissedConfig()
 if (missed.length !== 0) {
@@ -81,6 +82,7 @@ import {
 import { Redis } from './server/lib/redis'
 import { BadActorFollowScheduler } from './server/lib/schedulers/bad-actor-follow-scheduler'
 import { RemoveOldJobsScheduler } from './server/lib/schedulers/remove-old-jobs-scheduler'
+import { UpdateVideosScheduler } from './server/lib/schedulers/update-videos-scheduler'
 
 // ----------- Command line -----------
 
@@ -95,7 +97,7 @@ if (isTestInstance()) {
       req.path.indexOf(STATIC_PATHS.WEBSEED) === -1
     ) {
       return (cors({
-        origin: 'http://localhost:3000',
+        origin: '*',
         exposedHeaders: 'Retry-After',
         credentials: true
       }))(req, res, next)
@@ -156,20 +158,11 @@ app.use('/', activityPubRouter)
 app.use('/', feedsRouter)
 app.use('/', webfingerRouter)
 
-// Client files
-app.use('/', clientsRouter)
-
 // Static files
 app.use('/', staticRouter)
 
-// Always serve index client page (the client is a single page application, let it handle routing)
-app.use('/*', function (req, res) {
-  if (req.accepts(ACCEPT_HEADERS) === 'html') {
-    return res.sendFile(path.join(__dirname, '../client/dist/index.html'))
-  }
-
-  return res.status(404).end()
-})
+// Client files, last valid routes!
+app.use('/', clientsRouter)
 
 // ----------- Errors -----------
 
@@ -210,6 +203,7 @@ async function startApplication () {
   // Enable Schedulers
   BadActorFollowScheduler.Instance.enable()
   RemoveOldJobsScheduler.Instance.enable()
+  UpdateVideosScheduler.Instance.enable()
 
   // Redis initialization
   Redis.Instance.init()