Skip to content

flea89/express-routes-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EXPRESS-ROUTES-MAP

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.

Exaple

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;

Bitdeli Badge

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published