Suppress json object to speed up your rest api, by removing duplicate entities
If you are using nosql database, and your table is look like this, so do suppress of this json, exlude all entities to a nother store object. See here the result.
- decrease response size, in my example, 674 kb became to 140kb; end response time 53ms became to 33ms.
- decrease memory size, if you store the object in memory, using suppress and de-supress, does decrease memory size dramaticaly. in my exmple, 755780B became to 189296B.
install by npm
npm i suppress-js
import { suppress, deSuppress } from 'suppress-js';
suppress(result, //* id property, defualt :'_id'*//);
deSuppress(response);
resolve = (req, res, next) => {
const json = res.json;
res.json = (result) => {
const suppressResult = suppress(result);
return json.call(res, suppressResult);
};
return next();
}