]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Server: move remote routes in their own directory
authorChocobozzz <florian.bigard@gmail.com>
Fri, 30 Dec 2016 11:53:41 +0000 (12:53 +0100)
committerChocobozzz <florian.bigard@gmail.com>
Fri, 30 Dec 2016 11:53:41 +0000 (12:53 +0100)
server/controllers/api/index.js
server/controllers/api/remote/index.js [new file with mode: 0644]
server/controllers/api/remote/videos.js [moved from server/controllers/api/remote.js with 97% similarity]
server/helpers/utils.js

index 4cb65ed55d0e7ba5ce297de4f88804a7aa8272c5..f13ff922c949804c9a654345f5f2a952b110a58f 100644 (file)
@@ -2,6 +2,8 @@
 
 const express = require('express')
 
+const utils = require('../../helpers/utils')
+
 const router = express.Router()
 
 const clientsController = require('./clients')
@@ -18,7 +20,7 @@ router.use('/requests', requestsController)
 router.use('/users', usersController)
 router.use('/videos', videosController)
 router.use('/ping', pong)
-router.use('/*', badRequest)
+router.use('/*', utils.badRequest)
 
 // ---------------------------------------------------------------------------
 
@@ -29,7 +31,3 @@ module.exports = router
 function pong (req, res, next) {
   return res.send('pong').status(200).end()
 }
-
-function badRequest (req, res, next) {
-  res.type('json').status(400).end()
-}
diff --git a/server/controllers/api/remote/index.js b/server/controllers/api/remote/index.js
new file mode 100644 (file)
index 0000000..2947632
--- /dev/null
@@ -0,0 +1,16 @@
+'use strict'
+
+const express = require('express')
+
+const utils = require('../../../helpers/utils')
+
+const router = express.Router()
+
+const videosRemoteController = require('./videos')
+
+router.use('/videos', videosRemoteController)
+router.use('/*', utils.badRequest)
+
+// ---------------------------------------------------------------------------
+
+module.exports = router
similarity index 97%
rename from server/controllers/api/remote.js
rename to server/controllers/api/remote/videos.js
index be5e6dc98e99e16dd82459e7eddc5387bb42e57f..87c49bff918bdaa0c773224bd06530d5223dfd57 100644 (file)
@@ -4,15 +4,15 @@ const eachSeries = require('async/eachSeries')
 const express = require('express')
 const waterfall = require('async/waterfall')
 
-const db = require('../../initializers/database')
-const middlewares = require('../../middlewares')
+const db = require('../../../initializers/database')
+const middlewares = require('../../../middlewares')
 const secureMiddleware = middlewares.secure
 const validators = middlewares.validators.remote
-const logger = require('../../helpers/logger')
+const logger = require('../../../helpers/logger')
 
 const router = express.Router()
 
-router.post('/videos',
+router.post('/',
   validators.signature,
   secureMiddleware.checkSignature,
   validators.remoteVideos,
index 9f27671b6f5712b8550dbfe4c5b378d6e703af66..7e0c9823c5a3842ebbd648ce572368902eb42376 100644 (file)
@@ -5,11 +5,16 @@ const crypto = require('crypto')
 const logger = require('./logger')
 
 const utils = {
+  badRequest,
   cleanForExit,
   generateRandomString,
   isTestInstance
 }
 
+function badRequest (req, res, next) {
+  res.type('json').status(400).end()
+}
+
 function generateRandomString (size, callback) {
   crypto.pseudoRandomBytes(size, function (err, raw) {
     if (err) return callback(err)