drest
v1.1.6
Published
A node.js REST framework library
Downloads
6
Readme
dREST
A node.js REST framework library
See Documentation for more information
Example
Establish API methods
var api = {
user: {
getEyeColor : function (handler) {
handler.respond({eye_color:"green"});
},
setEyeColor: function (handler) {
var color = JSON.parse(handler.data).eyecolor;
handler.respond({response:"eye color set to "+color});
}
}
}
Create a router
var drest = require("drest");
var router = drest.createRouter(8100,"127.0.0.1");
router.addRoute({
method:"get",
path:"user/{number}/eyecolor",
authLevel:1,
action:api.user.getEyeColor
});
router.addRoute({
method:"post",
path:"user/{number}/eyecolor",
action:api.user.setEyeColor
});
router.setAuthLayer(
function(passthrough) {
passthrough.check(1);
}
);