New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

standard-api-response

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

standard-api-response

Generic API response object for consistent API output across services

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

Standard API Response

Build Status

This is a generic API response object for consistent API output across services. it is mostly meant for internal InterNACHI use, but anyone is welcome to use it.

Basic Usage

app.post('/users', function(req, res) {
	// Handle provided data and build new user object
	// ...

	// Create API response object
	var apires = new OkResponse(user, OkResponse.codes.CREATED, 'User successfully created.');

	// Send to client
	apires.send(res);
}

Response Format

HTTP/1.1 201 OK
Content-Type: application/json

{
	"ok": true,
	"message": "User successfully created.",
	"data": { ... },
	"httpCode": 201, // Same as HTTP response code
	"error": { ... } // Only present if "ok" == false
}

Keywords

api

FAQs

Package last updated on 01 Oct 2013

Did you know?

Socket

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.

Install

Related posts