Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

buildRes

This plugin will help you configure your response messages easily, in ExpressJS

Usage

Specify the buildRes middleware, after specifying all the other route handlers.

app.use(index, '/');
app.use(users, '/users');

...

app.use(require('./lib/buildRes'));

Now, specify the response's configuration in the respose object, as a property buildRes, and then call next()

...

res.buildRes({
	// Configurations
});

next();

Configuration object defaults

  • status: 200
  • headers : {}
  • message: Accorging to the status code

Example

router.get('/', function(req, res, next) {
	
	// Configuration object
	res.buildRes = {
		status:404,
		headers: {
			header1: 'firstHeader',
			header2: 'secondHeader'
		},
		message: 'Sorry, not found'
	};
	
	// Call next()
	next();
});

About

This plugin will help you configure your response messages easily, in ExpressJS

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages