-
Notifications
You must be signed in to change notification settings - Fork 59
/
http_server.js
executable file
·66 lines (47 loc) · 1.61 KB
/
http_server.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
// add http server
// -----------------------
// YOUR CODE
var low = require('lowdb');
var fs = require('lowdb/adapters/FileSync');
var adapter = new fs('db.json');
var db = low(adapter);
// configure express to serve static files from public directory
// ------------------------------------------------------------------
// YOUR CODE
// init the data store
db.defaults({ posts: []}).write();
// list posts
app.get('/data', function(req, res){
// YOUR CODE
});
// ----------------------------------------------------
// add post - test using:
// curl http://localhost:3000/posts/ping/1/false
// ----------------------------------------------------
app.get('/posts/:title/:id/:published', function(req, res){
// YOUR CODE
});
// ----------------------------------------------------
// filter by published state - test using:
// curl http://localhost:3000/published/true
// ----------------------------------------------------
app.get('/published/:boolean', function(req, res){
// YOUR CODE
});
// ----------------------------------------------------
// update published value - test using:
// curl http://localhost:3000/published/1/true
// ----------------------------------------------------
app.get('/published/:id/:boolean', function(req, res){
// YOUR CODE
});
// ----------------------------------------------------
// delete entry by id - test using:
// curl http://localhost:3000/delete/5
// ----------------------------------------------------
app.get('/delete/:id/', function(req, res){
// YOUR CODE
});
// start server
// -----------------------
// YOUR CODE