npm fast-gateway 2.8.0
Adding urlRewrite hook

latest releases: 3.5.0, 3.4.7, 3.4.6...
3 years ago

We added a new urlRewrite hook that simplifies URL rewrites using req path or queryString params:

'use strict'

const gateway = require('../index')
const PORT = process.env.PORT || 8080

gateway({
  routes: [{
    pathRegex: '',
    prefix: '/customers/:customerId',
    target: 'http://localhost:3000',
    urlRewrite: ({ params: { customerId } }) => `/users/${customerId}`
  }]
}).start(PORT).then(server => {
  console.log(`API Gateway listening on ${PORT} port!`)
})

const service = require('restana')({})
service
  .get('/users/:id', (req, res) => res.send('Hello ' + req.params.id))
  .start(3000).then(() => console.log('Service listening on 3000 port!'))

Issue ref: #58

Don't miss a new fast-gateway release

NewReleases is sending notifications on new releases.