node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

serenity-partial-response-helper

serenity partial response helper

Common module for serenity applications.

This module is designed to abstract the partial response support for serenity API's.

It is implemented based on google partial response spec

How to install?

Install via npm and git

npm install git+https://github.com/appirio-tech/lc1-node-partial-reponse-helper.git

Configuration

This module has no specific configurations. Application using it have to make sure that they instantiate serenity-datasource module and pass it during this module initialization. If the datasource is invalid error would be thrown

Error conditions has to be handled by application.

How to use?

var serenityResponseHelper = require('lc1-node-partial-reponse-helper');
var serenityDatasource = require('lc1-node-datasource');
// For serenity datasource configuration see serenity module docs
var config = require('config');
var datasource = new serenityDatasource(config);
var partialResponseHelper = new serenityResponseHelper(datasource);

The module exports two functions

  • parseFields

    This module parse the request query parameters and make it available while reducing object to partial resonse This is added as an middleware to express application usally before any controller logic.

  • reduceFieldsAndExpandObject

    This is also added as an middleware to express application usually just before sendnig the response to client