1.0.1 • Published 2 years ago

respontor v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

respontor

Library for who wants to give response more readable

Usage;

const response = require('respontor');

response.json({
  message: 'This is success message',
});
// returns { message: 'This is success message', status: 200 },

response.json({
  message: 'This is error message',
}, response.BAD_REQUEST);
// returns { message: 'This is error message', status: 400 },

response.message('This is success message').catch();
// returns { message: 'This is success message', status: 200 },

response.message('This is error message').status(response.BAD_REQUEST).catch();
// returns { message: 'This is error message', status: 400 },

response.status(response.BAD_REQUEST).message('This is error message').catch();
// returns { message: 'This is error message', status: 400 },

response.status(response.BAD_REQUEST).message('This is error message').with({
  why: 'This is why you got the error'
}).catch();
// returns { message: 'This is error message', why: 'This is why you got error', status: 200 },