diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-19 14:58:28 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-19 14:58:28 +0200 |
commit | a96aed15188174c50885dda0df3164a67295e11f (patch) | |
tree | 7e3941324614e52a2f6ab7755224ab8ae8f8c19f /server.ts | |
parent | bda65bdc9f3ce7d4b6e97cb9afaca25b71added3 (diff) | |
download | PeerTube-a96aed15188174c50885dda0df3164a67295e11f.tar.gz PeerTube-a96aed15188174c50885dda0df3164a67295e11f.tar.zst PeerTube-a96aed15188174c50885dda0df3164a67295e11f.zip |
Add ability to download a video from direct link or torrent file
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 44 |
1 files changed, 24 insertions, 20 deletions
@@ -79,26 +79,6 @@ app.use(morgan('combined', { | |||
79 | app.use(bodyParser.json({ limit: '500kb' })) | 79 | app.use(bodyParser.json({ limit: '500kb' })) |
80 | app.use(bodyParser.urlencoded({ extended: false })) | 80 | app.use(bodyParser.urlencoded({ extended: false })) |
81 | 81 | ||
82 | // ----------- Views, routes and static files ----------- | ||
83 | |||
84 | // API | ||
85 | const apiRoute = '/api/' + API_VERSION | ||
86 | app.use(apiRoute, apiRouter) | ||
87 | |||
88 | // Services (oembed...) | ||
89 | app.use('/services', servicesRouter) | ||
90 | |||
91 | // Client files | ||
92 | app.use('/', clientsRouter) | ||
93 | |||
94 | // Static files | ||
95 | app.use('/', staticRouter) | ||
96 | |||
97 | // Always serve index client page (the client is a single page application, let it handle routing) | ||
98 | app.use('/*', function (req, res, next) { | ||
99 | res.sendFile(path.join(__dirname, '../client/dist/index.html')) | ||
100 | }) | ||
101 | |||
102 | // ----------- Tracker ----------- | 82 | // ----------- Tracker ----------- |
103 | 83 | ||
104 | const trackerServer = new TrackerServer({ | 84 | const trackerServer = new TrackerServer({ |
@@ -122,6 +102,30 @@ wss.on('connection', function (ws) { | |||
122 | trackerServer.onWebSocketConnection(ws) | 102 | trackerServer.onWebSocketConnection(ws) |
123 | }) | 103 | }) |
124 | 104 | ||
105 | const onHttpRequest = trackerServer.onHttpRequest.bind(trackerServer) | ||
106 | app.get('/tracker/announce', (req, res) => onHttpRequest(req, res, { action: 'announce' })) | ||
107 | app.get('/tracker/scrape', (req, res) => onHttpRequest(req, res, { action: 'scrape' })) | ||
108 | |||
109 | // ----------- Views, routes and static files ----------- | ||
110 | |||
111 | // API | ||
112 | const apiRoute = '/api/' + API_VERSION | ||
113 | app.use(apiRoute, apiRouter) | ||
114 | |||
115 | // Services (oembed...) | ||
116 | app.use('/services', servicesRouter) | ||
117 | |||
118 | // Client files | ||
119 | app.use('/', clientsRouter) | ||
120 | |||
121 | // Static files | ||
122 | app.use('/', staticRouter) | ||
123 | |||
124 | // Always serve index client page (the client is a single page application, let it handle routing) | ||
125 | app.use('/*', function (req, res) { | ||
126 | res.sendFile(path.join(__dirname, '../client/dist/index.html')) | ||
127 | }) | ||
128 | |||
125 | // ----------- Errors ----------- | 129 | // ----------- Errors ----------- |
126 | 130 | ||
127 | // Catch 404 and forward to error handler | 131 | // Catch 404 and forward to error handler |