This package has been deprecated

Author message:

Please use @roit/roit-response-handler packages instead.

roit-response-api-node

1.0.10 • Public • Published

ROIT response api for node

Library to standardize api response for services.

Basic Usage

import { OkResponse } from "roit-response-api-node"

app.post('/users', function(req, res) {

	// Send to client
	apires.send(OkResponse(user, 'User successfully created.'));
}
import { ErrorResponse } from "roit-response-api-node"

app.post('/users', function(req, res) {

	const errors = [{
		code: XXX,
		message: "Error in execute request!"
	}]

	// Send to client
	apires.send(ErrorResponse(errors, 'User successfully created.'));
}

Response Format

SUCCESS
Content-Type: application/json

{
	"status": "SUCCESS",
	"message": "User successfully created.",
	"data": { ... },
	"errors": null
}
ERROR
Content-Type: application/json

{
	"status": "ERROR",
	"message": "Error in create user.",
	"data": null,
	"errors": [
		{
			"code": XXX,
			"message": "Error in execute request!"
		}
	]
}

Readme

Keywords

Package Sidebar

Install

npm i roit-response-api-node

Weekly Downloads

1

Version

1.0.10

License

ISC

Unpacked Size

3.37 kB

Total Files

7

Last publish

Collaborators

  • jeremias.silva