commit | author | age
|
6ef0cc
|
1 |
/** |
D |
2 |
* Main application routes |
|
3 |
*/ |
|
4 |
|
|
5 |
'use strict'; |
|
6 |
|
c382ab
|
7 |
const errors = require('./components/errors'); |
D |
8 |
const path = require('path'); |
6ef0cc
|
9 |
|
D |
10 |
module.exports = function(app) { |
cdbd77
|
11 |
|
D |
12 |
app.use(function(req, res, next) { |
|
13 |
res.header("Access-Control-Allow-Origin", "*"); |
|
14 |
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); |
2bb44e
|
15 |
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); |
cdbd77
|
16 |
next(); |
D |
17 |
}); |
6ef0cc
|
18 |
// Insert routes below |
D |
19 |
app.use('/api/todos', require('./api/todo')); |
|
20 |
|
|
21 |
// All undefined asset or api routes should return a 404 |
|
22 |
app.route('/:url(api|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) { |
de1231
|
28 |
return res.status(200).json({OK: true, timestamp: Date.now()}); |
D |
29 |
// res.sendFile(path.resolve(app.get('appPath') + '/index.html')); |
6ef0cc
|
30 |
}); |
D |
31 |
}; |