Module avaiable on npm registry. Simple module that simplifies the creation of REST APIs on Express. The module is designed to help building rest apis, that expose CRUD functionalities on collections of datas.
GET /collection ---> retrieve collection of resources
GET /collection/:id ---> retrieve resource with id, from collection
the same philosophy for POST (create) , PUT (update), DELETE (delete)
##GETTING STARTED
server.js
var expressmap = require('express-routes-map'),
http = require('http'),
var app = express(),
.....
....
expressmap(app)
.defineRoutes('/collectionA', require('./routes/collectionA'))
.defineRoutes('/collectionB',require('./routes/collectionB'))
.defineRoutes('/collectionC',require('./routes/collectionC'))
.map();
The routes have to be build like the follow:
routes/collectionA.js
var item = {
get : function(req,res){
....
},
put : function(req,res){
},
delete : function(req,res){
}
};
var collection = {
get : function(req,res){
},
post : function(req,res){
},
delete : function(req,res){
}
};
exports.item = item;
exports.collection = collection;