We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5d1aa7f commit ef1b95dCopy full SHA for ef1b95d
demos/url-rewrite.js
@@ -0,0 +1,20 @@
1
+'use strict'
2
+
3
+const gateway = require('../index')
4
+const PORT = process.env.PORT || 8080
5
6
+gateway({
7
+ routes: [{
8
+ pathRegex: '',
9
+ prefix: '/customers/:customerId',
10
+ target: 'http://localhost:3000',
11
+ urlRewrite: ({ params: { customerId } }) => `/users/${customerId}`
12
+ }]
13
+}).start(PORT).then(server => {
14
+ console.log(`API Gateway listening on ${PORT} port!`)
15
+})
16
17
+const service = require('restana')({})
18
+service
19
+ .get('/users/:id', (req, res) => res.send('Hello ' + req.params.id))
20
+ .start(3000).then(() => console.log('Service listening on 3000 port!'))
0 commit comments