node-service-proxy
proxy request
Last updated 4 years ago by jeff-tian .
Original npm · Tarball · package.json
$ cnpm install node-service-proxy 
SYNC missed versions from official npm registry.

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');
            }
        });
    })
;

Current Tags

  • 1.0.4                                ...           latest (4 years ago)

5 Versions

  • 1.0.4                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 6
Last Day 1
Last Week 5
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |