2.0.5 • Published 6 years ago

jsend-response-builder v2.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

About

A simple typescript library for creating JSend responses. Supports making "Success", "Error" and "Fail" responses.

Usage

The project is very simple to start using. You simply create an instance of the JSendResponseBuilder then start using the methods. The builder supports several options to customize the builder

Options

The options are currently a WIP but currently there are 2 available options.

OptionValuesDescription
case'kebab', 'camel', 'snake'By setting this, it controls what case type the object keys in the response are
deeptrue, falseBy setting this, it controls if nested objects in the reponse get normalized
namespaceKeystringBy setting this, it prevents the case type from rewriting the characters that separate a namespace from its key

Example

const data = {
    firstName: 'Joe',
    lastName: 'Hartzell'
};
const jsend = new JSendResponseBuilder();
const response = jsend.success(data);

// response output
// {
//     status: 'success',
//     data: {
//         firstName: 'Joe',
//         lastName: 'Hartzell'
//     }
// }

More examples can be found in the tests directory

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

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