New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lengoo-api-response-formatter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lengoo-api-response-formatter - npm Package Compare versions

Comparing version

to
1.2.0

37

lib/Response.js

@@ -67,2 +67,3 @@ const _ = require('lodash');

this._validations = [];
this._pagination;
this._mongoError = {};

@@ -84,6 +85,2 @@ }

set status(input) {
if (Number.isInteger(input)) {
throw new TypeError('"status" must to be an integer, ' + (typeof input) + ' given.');
}
this._status = input

@@ -268,2 +265,26 @@ }

set pagination(input) {
let defaults = {
records: {
limit: 0,
total: 0
},
pages: {
current: 0,
total: 0,
},
links: {
previous: false,
current: false,
next: false,
}
};
this._pagination = _.pickBy(input, function (value, key) {
if (_.has(defaults, key)) {
return true;
}
});
}
/**

@@ -275,7 +296,13 @@ * Get the formatted response

get() {
return {
let response = {
data: this._data,
error: this._error,
validations: this._validations
};
if (this._pagination) {
response.pagination = this._pagination;
}
return response;
}

@@ -282,0 +309,0 @@ }

4

package.json
{
"name": "lengoo-api-response-formatter",
"version": "1.1.3",
"version": "1.2.0",
"description": "A lib to keep your responses formatted and consistent through your project",

@@ -19,3 +19,3 @@ "main": "./lib/Response.js",

],
"author": "Rodrigo Duarte <rodrigo.duarte@lengoo.de> (https://www.lengoo.de)",
"author": "Rodrigo Duarte <rodrigo.terminus@gmail.com> (https://www.lengoo.de)",
"license": "MIT",

@@ -22,0 +22,0 @@ "bugs": {