
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Simple and structured application level JSON responses for Express. Based on JSend specification.
Simple and structured application level JSON responses for Express. Based on JSend specification (http://labs.omniti.com/labs/jsend).
npm install jsender
Setup the middleware in your Express app. Before any routes.
var express = require('express')
, jsender = require('jsender')
;
var app = express();
// ... (other middlewares)
app.use(jsender());
app.get('/', function (req, res){
res.success({
notice: 'Hello, World!'
});
});
// JSON Response
// {
// "status": "success",
// "data": {
// "notice": "Hello, World!"
// }
// }
JSender augments the node res
object with the following methods.
success(data)
function (req, res){
res.success({
notice: 'Hello, World!'
});
};
// JSON Response
// {
// "status": "success",
// "data": {
// "notice": "Hello, World!"
// }
// }
fail(data)
function (req, res){
res.fail({
name: 'Name is required.'
});
};
// JSON Response
// {
// "status": "fail",
// "data": {
// "name": "Name is required."
// }
// }
error(message, data, code)
function (req, res){
res.error('Server error.');
};
// JSON Response
// {
// "status": "error",
// "message": "Server error."
// }
jsend(err, data)
null
.function (req, res){
books.find()
.exec(res.jsend);
};
// same as
function (req, res){
books.find()
.exec(function (err, data){
if (err)
return res.jsend(err);
res.jsend(null, data);
});
};
FAQs
Simple and structured application level JSON responses for Express. Based on JSend specification.
We found that jsender demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.