forked from triceratopstech/Subtask
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.js
More file actions
51 lines (40 loc) · 1.4 KB
/
Copy pathroutes.js
File metadata and controls
51 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// app/routes.js
// grab the nerd model we just created
var db = require('./models');
module.exports = function(app) {
// server routes ===========================================================
// handle things like api calls
// authentication routes
// sample api route
app.get('/api/tasks', function(req, res) {
db.Tasks.findAll().then((tasks) => {res.json(tasks)});
});
app.get('/api/relationships', function(req, res) {
db.TaskRelationships.findAll().then((taskrelationships) => {res.json(taskrelationships)});
});
// route to handle creating goes here (app.post)
// route to handle delete goes here (app.delete)
// frontend routes =========================================================
// route to handle all angular requests
const allowedExt = [
'.js',
'.ico',
'.css',
'.png',
'.jpg',
'.woff2',
'.woff',
'.ttf',
'.svg',
];
app.get('*', function (req, res) {
//handle resource requests correctly
if (allowedExt.filter(ext => req.url.indexOf(ext) > 0).length > 0) {
var path = './dist/subtask' + req.url;
res.sendfile(path);
} else {
res.sendfile('./dist/subtask/index.html'); // load our public/index.html file
}
}
);
};