1.0.10 • Published 6 years ago

roit-response-api-node v1.0.10

Weekly downloads
81
License
ISC
Repository
bitbucket
Last release
6 years ago

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!"
		}
	]
}
1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago