From e85782f7da44267e11714a63567feb7e0127126e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 7 Nov 2015 18:22:05 +0100 Subject: Views refractoring --- routes/api/v1/index.js | 12 +++++++----- routes/index.js | 22 ++++------------------ routes/views.js | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 23 deletions(-) create mode 100644 routes/views.js (limited to 'routes') diff --git a/routes/api/v1/index.js b/routes/api/v1/index.js index 9a4ec8438..f5504ad85 100644 --- a/routes/api/v1/index.js +++ b/routes/api/v1/index.js @@ -1,10 +1,12 @@ ;(function () { 'use strict' - var api = {} - api.videos = require('./videos') - api.remoteVideos = require('./remoteVideos') - api.pods = require('./pods') + var express = require('express') + var router = express.Router() - module.exports = api + router.use('/videos', require('./videos')) + router.use('/remotevideos', require('./remoteVideos')) + router.use('/pods', require('./pods')) + + module.exports = router })() diff --git a/routes/index.js b/routes/index.js index 690913a84..ecca80721 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,24 +1,10 @@ ;(function () { 'use strict' - function getPartial (req, res) { - var directory = req.params.directory - var name = req.params.name - - res.render('partials/' + directory + '/' + name) - } - - function getIndex (req, res) { - res.render('index') + var routes = { + api: require('./api/' + global.API_VERSION), + views: require('./views') } - var express = require('express') - var middleware = require('../middlewares') - - var router = express.Router() - - router.get('/partials/:directory/:name', middleware.cache(), getPartial) - router.get(/^\/(index)?$/, middleware.cache(), getIndex) - - module.exports = router + module.exports = routes })() diff --git a/routes/views.js b/routes/views.js new file mode 100644 index 000000000..690913a84 --- /dev/null +++ b/routes/views.js @@ -0,0 +1,24 @@ +;(function () { + 'use strict' + + function getPartial (req, res) { + var directory = req.params.directory + var name = req.params.name + + res.render('partials/' + directory + '/' + name) + } + + function getIndex (req, res) { + res.render('index') + } + + var express = require('express') + var middleware = require('../middlewares') + + var router = express.Router() + + router.get('/partials/:directory/:name', middleware.cache(), getPartial) + router.get(/^\/(index)?$/, middleware.cache(), getIndex) + + module.exports = router +})() -- cgit v1.2.3