TwoToc code
[YouAndWeb_TwoToc] / server / routes.js
1 /**
2  * Main application routes
3  */
4
5 'use strict';
6
7 var errors = require('./components/errors');
8 var path = require('path');
9
10 module.exports = function(app) {
11
12   // Insert routes below
13   app.use('/api/comments', require('./api/comment'));
14   app.use('/api/categories', require('./api/category'));
15   app.use('/api/shows', require('./api/show'));
16   app.use('/api/test', require('./api/message'));
17   app.use('/api/users', require('./api/user'));
18
19   app.use('/auth', require('./auth'));
20
21   // All undefined asset or api routes should return a 404
22   app.route('/:url(api|auth|components|app|bower_components|assets)/*')
23    .get(errors[404]);
24
25   // All other routes should redirect to the index.html
26   app.route('/*')
27     .get(function(req, res) {
28       res.sendFile(path.resolve(app.get('appPath') + '/index.html'));
29     });
30 };