express-gateway-plugin-array-transformer

0.0.2 • Public • Published

express-gateway-plugin-array-transformer

Plugin for express-gateway that allows for transformation of response body when the response is an array.

Based on Response Transformation policy that is built in to express-gateway. That policy only transforms the body if it's JSON, while this one transform array response body.

Installation

eg plugin install express-gateway-plugin-rewrite

Quick Start

  1. Ensure the plugin is included in system.config.yml file of your gateway. For example:
array-transformer:
  package: express-gateway-plugin-array-transformer

Note: if you install the plugin using eg plugin create, this will already be added.

  1. Add configuration to your gateway.config.yml file.
  policies:
      - array-transformer:
        - action:
            body:
              add:
                test: "'test'"
              remove:
                - hello
                - world

action.add: key-value pair to add to response body. The value can be a string (as above) or an expression. For example: test: req.body.rTest where rTest is a key in request payload.

action.remove: An array of keys to be removed.

Readme

Keywords

none

Package Sidebar

Install

npm i express-gateway-plugin-array-transformer

Weekly Downloads

2

Version

0.0.2

License

ISC

Unpacked Size

3.69 kB

Total Files

4

Last publish

Collaborators

  • jayh