forked from deployd/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb-routes.js
executable file
·130 lines (115 loc) · 2.76 KB
/
db-routes.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
var app = require('./app');
require('express-namespace');
app.use('/db', function(req, res, next) {
// if (req.method == "GET") {
// next();
// } else {
setTimeout(next, 500);
// }
});
app.namespace('/db', function() {
app.get('/resourcetypes', function(req, res) {
res.send({
Collection: {
defaultPath: '/collection'
},
UserCollection: {
label: 'Users',
defaultPath: '/users'
}
});
});
app.get('/resources', function(req, res) {
// res.send([
// {
// _id: 0,
// path: '/todos',
// typeId: 'Collection',
// typeName: 'Collection',
// order: 1
// }, {
// _id: 1,
// path: '/users',
// typeId: 'UserCollection',
// typeName: 'User Collection',
// order: 2
// }
// ]);
res.send([]);
});
app.del('/resources/:id', function(req, res) {
console.log("Deleting ", req.url);
res.end();
});
app.put('/resources/:id', function(req, res) {
console.log("Updating", req.url, req.body);
res.send(req.body);
});
app.post('/resources', function(req, res) {
var content = req.body;
content._id = Math.round(Math.random() * 100);
console.log("Creating resource", content);
res.send(content);
});
app.get('/plugins/collection/types', function(req, res) {
res.send({
String: {
defaultName: 'string'
},
Number: {
defaultName: 'number'
},
Boolean: {
defaultName: 'boolean'
},
Date: {
defaultName: 'date'
}
});
});
app.get('/resources/:id', function(req, res){
res.send({
_id: req.param('id'),
properties: {
title: {
type: 'string',
typeLabel: 'String',
required: true,
order: 1
},
completed: {
type: 'boolean',
typeLabel: 'Boolean',
order: 2
}
}
});
});
app.put('/resources/:id', function(req, res) {
res.send(req.body);
});
app.get('/todos', function(req, res) {
res.send([{
_id: '6c84fb90-12c4-11e1-840d-7b25c5ee775a',
title: 'Feed the dog',
completed: true
}, {
_id: '110ec58a-a0f2-4ac4-8393-c866d813b8d1',
title: 'Water the tree',
completed: false
}, {
_id: '9f9039jg-39vj-29ck-saj3-9v09ds098vh3',
title: 'Send email',
completed: false
}]);
});
app.post('/todos', function(req, res) {
res.send(req.body);
});
app.put('/todos/:id', function(req, res) {
res.send(req.body);
});
app.del('/todos/:id', function(req, res) {
res.end();
});
});