Vision Engine is a video conferencing application. This is a Node.js Express API Gateway that acts as a single entry point for vision engine client apps to interact with multiple microservices.
-
Unified API: The API Gateway provides a unified API for clients to access various microservices through a single entry point.
-
Reverse Proxy: The gateway uses
http-proxy-middleware
to create a reverse proxy, forwarding requests to the appropriate microservice instance. -
Middleware: The gateway uses middleware for tasks such as logging and request parsing.
- Node.js (version 14 or higher)
- npm (Node Package Manager) or yarn
- Clone the repository:
git clone https://github.com/anandh4411/vision-engine-api-gateway.git
cd vision-engine-api-gateway
- Install the dependencies:
npm install
- Create a
.env
file in the root directory and set the following environment variables:
NODE_ENV='development'
NODE_DOMAIN_URL='http://localhost'
Replace the url with the URLs of your microservice instances.
- Start the Express API Gateway:
node app.js
- Or use nodemon:
npm i nodemon
nodemon app.js
The API Gateway will start listening on the specified port (default: 3000) and forward incoming requests to the microservices based on the load balancing strategy.
To add more routes to the API Gateway, follow these steps:
- Create a new route file (e.g.,
myRoute.js
) in thesrc/routes
directory. - Define your route handlers in
myRoute.js
. - Import the new route in
app.js
and mount it usingapp.use()
.
const myRoute = require("./src/routes/myRoute");
app.use("/myroute", myRoute);
If you want to enable logging of incoming requests during development, set NODE_ENV=development in your .env file.
Contributions are welcome! If you find a bug or have any suggestions, please open an issue or submit a pull request.
Thanks to the creators and maintainers of Express and http-proxy-middleware for their excellent libraries.
This project is licensed under the MIT License.