aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-19 14:58:28 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-19 14:58:28 +0200
commita96aed15188174c50885dda0df3164a67295e11f (patch)
tree7e3941324614e52a2f6ab7755224ab8ae8f8c19f /server.ts
parentbda65bdc9f3ce7d4b6e97cb9afaca25b71added3 (diff)
downloadPeerTube-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.ts44
1 files changed, 24 insertions, 20 deletions
diff --git a/server.ts b/server.ts
index 72bb11e74..f50e5bad4 100644
--- a/server.ts
+++ b/server.ts
@@ -79,26 +79,6 @@ app.use(morgan('combined', {
79app.use(bodyParser.json({ limit: '500kb' })) 79app.use(bodyParser.json({ limit: '500kb' }))
80app.use(bodyParser.urlencoded({ extended: false })) 80app.use(bodyParser.urlencoded({ extended: false }))
81 81
82// ----------- Views, routes and static files -----------
83
84// API
85const apiRoute = '/api/' + API_VERSION
86app.use(apiRoute, apiRouter)
87
88// Services (oembed...)
89app.use('/services', servicesRouter)
90
91// Client files
92app.use('/', clientsRouter)
93
94// Static files
95app.use('/', staticRouter)
96
97// Always serve index client page (the client is a single page application, let it handle routing)
98app.use('/*', function (req, res, next) {
99 res.sendFile(path.join(__dirname, '../client/dist/index.html'))
100})
101
102// ----------- Tracker ----------- 82// ----------- Tracker -----------
103 83
104const trackerServer = new TrackerServer({ 84const trackerServer = new TrackerServer({
@@ -122,6 +102,30 @@ wss.on('connection', function (ws) {
122 trackerServer.onWebSocketConnection(ws) 102 trackerServer.onWebSocketConnection(ws)
123}) 103})
124 104
105const onHttpRequest = trackerServer.onHttpRequest.bind(trackerServer)
106app.get('/tracker/announce', (req, res) => onHttpRequest(req, res, { action: 'announce' }))
107app.get('/tracker/scrape', (req, res) => onHttpRequest(req, res, { action: 'scrape' }))
108
109// ----------- Views, routes and static files -----------
110
111// API
112const apiRoute = '/api/' + API_VERSION
113app.use(apiRoute, apiRouter)
114
115// Services (oembed...)
116app.use('/services', servicesRouter)
117
118// Client files
119app.use('/', clientsRouter)
120
121// Static files
122app.use('/', staticRouter)
123
124// Always serve index client page (the client is a single page application, let it handle routing)
125app.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