
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
proto-jsend
Advanced tools
Express middleware for jSend responses.
With npm do:
npm install proto-jsend
Then assign as express middleware. This will add the jSend methods to the express request and response objects.
var app = express(),
jSend = require('proto-jsend');
app.use(jSend);
/**
* Send jSend success response to the client
*
* res.jSend will infer the status code (200 or 201 from the request http method)
* if jsonp is used req.method is always 'GET' so in this case req._method property must be set to the desired method e.g 'POST' if you wish to receive a 201 code
*
* @param {Object} data - data to send in response
*/
res.jSend = function (data) {
// ...
}
/**
* Send custom jSend "error" messages to client
*
* @param {Object} arguments - Object containing options for jSend.error
* @param {Number} arguments.code - HTTP Status Code 5xx (defaults to 500)
* @param {String} arguments.message - Message to be sent to the client
* @param {Object} [arguments.data] - Object to be sent to the client
*/
res.jSend.error = function (arguments) {
// ...
}
res.jSend.error({
code: 500,
message: "Internal Server Error",
data: new Error('Broke it!')
});
HTTP/1.1 500 Error
{
"status": "error",
"message": "Internal Server Error"
}
HTTP/1.1 500 Error
{
"status": "error",
"message": "Internal Server Error",
"data": "Error: Broke it!\n at Object.<anonymous> (/Users/foo/app.js:12:25)\n at Module._compile (module.js:460:26)\n at Object.Module._extensions..js (module.js:478:10)\n at Module.load (module.js:355:32)\n at Function.Module._load (module.js:310:12)\n at Function.Module.runMain (module.js:501:10)\n at startup (node.js:129:16)\n at node.js:814:3"
}
/**
* Send custom jSend "fail" messages to client
*
* @param {Object} arguments - Object containing options for jSend.fail
* @param {Number} arguments.code - HTTP Status Code 4xx (defailts to 400)
* @param {Object} arguments.data - Object to be sent to the Client
*/
res.jSend.fail = function (arguments) {
// ...
};
res.jSend.error({
code: 400,
message: "Bad Request",
data: {
title: "Title property of type string is required"
}
});
HTTP/1.1 400 Bad Request
{
"status": "fail",
"data": {
"title": "Title property of type string is required"
}
}
FAQs
jSend middleware for express
We found that proto-jsend 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
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.