Created
November 20, 2018 22:43
-
-
Save wesleymonaro/655108bfe67ef6f9cfc2c5444c356d7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const httpProxy = require('express-http-proxy'); | |
const app = express(); | |
const port = 3000; | |
const { | |
USERS_API_URL, | |
PRODUCTS_API_URL, | |
} = require('./URLs'); | |
const userServiceProxy = httpProxy(USERS_API_URL); | |
const productsServiceProxy = httpProxy(PRODUCTS_API_URL); | |
app.get('/', (req, res) => res.send('Hello Gateway API')); | |
app.get('/users', (req, res, next) => userServiceProxy(req, res, next)); | |
app.get('/products', (req, res, next) => productsServiceProxy(req, res, next)); | |
app.listen(port, () => console.log(`Example app listening on port ${port}!`)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment