1.0.4 • Published 8 years ago

node-service-proxy v1.0.4

Weekly downloads
21
License
-
Repository
-
Last release
8 years ago

node-service-proxy

proxy request

Install

npm install node-service-proxy --save

Usage

var proxy = require('node-service-proxy');

module.exports = require('express').Router()
    .put('/your-route', function (req, res, next) {
        proxy(req, res, next, {
            host: 'your.upstream.server',
            port: 'your-upstream-service-port',
            path: '/your/upstream/service/route',
            method: 'POST'
        });
    })
    .post('/your-another-route', function (req, res, next) {
        proxy(req, res, next, {
            host: 'your.upstream.server',
            port: 'your-upstream.port',
            path: '/your/upstream/service/route',
            method: 'POST',
            dataMapper: function(d){
                d.userId = d.member_id;
                
                return d;
            },
            continueNext: true,
            dataFieldName: 'upstreamData'
        }, function(req, res, next) {
            if(req.upstreamData.isSuccess) {
                res.send('ok');
            } else {
                res.send('not ok');
            }
        });
    })
;
1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago