/
service.js
59 lines (51 loc) · 1.36 KB
/
service.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
/*
* service.js: Defines the web service for the Pinpoint module.
*
* (C) 2011 Charlie Robbins
* MIT LICENSE
*
*/
var journey = require('journey');
/**
* Creates the RESTful router for the pinpoint web service
*/
exports.createRouter = function () {
var router = new (journey.Router)({
strict: false,
strictUrls: false,
api: 'basic'
});
router.path(/\/bookmarks/, function () {
//
// LIST: GET to /bookmarks lists all bookmarks
//
this.get().bind(function (res) {
res.send(501, {}, { action: 'list' });
});
//
// SHOW: GET to /bookmarks/:id shows the details of a specific bookmark
//
this.get(/\/([\w|\d|\-|\_]+)/).bind(function (res, id) {
res.send(501, {}, { action: 'show' });
});
//
// CREATE: POST to /bookmarks creates a new bookmark
//
this.post().bind(function (res, bookmark) {
res.send(501, {}, { action: 'create' });
});
//
// UPDATE: PUT to /bookmarks updates an existing bookmark
//
this.put(/\/([\w|\d|\-|\_]+)/).bind(function (res, bookmark) {
res.send(501, {}, { action: 'update' });
});
//
// DELETE: DELETE to /bookmarks/:id deletes a specific bookmark
//
this.del(/\/([\w|\d|\-|\_]+)/).bind(function (res, id) {
res.send(501, {}, { action: 'delete' });
});
});
return router;
};