https://github.com/rishabh-kumar01/airline-api-gateway
"Air Connect: A microservice-based airline booking backend with API Gateway. Features authentication, booking, flight search, and reminder services. Implements routing and rate-limiting for efficient, secure operations."
https://github.com/rishabh-kumar01/airline-api-gateway
api api-gateway backend microservices restful-api
Last synced: over 1 year ago
JSON representation
"Air Connect: A microservice-based airline booking backend with API Gateway. Features authentication, booking, flight search, and reminder services. Implements routing and rate-limiting for efficient, secure operations."
- Host: GitHub
- URL: https://github.com/rishabh-kumar01/airline-api-gateway
- Owner: Rishabh-Kumar01
- Created: 2024-07-25T08:10:46.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-25T19:12:27.000Z (almost 2 years ago)
- Last Synced: 2025-01-22T14:22:11.987Z (over 1 year ago)
- Topics: api, api-gateway, backend, microservices, restful-api
- Language: JavaScript
- Homepage:
- Size: 45.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Welcome to Airline API Gateway
## GitHub repository links for the four services in this microservice architecture:
- Auth Service -
[GitHub Repository Link](https://github.com/Rishabh-Kumar01/Auth-Service)
- Flight and Search Service -
[GitHub Repository Link](https://github.com/Rishabh-Kumar01/FlightsAndSerachService)
- Reminder Service -
[GitHub Repository Link](https://github.com/Rishabh-Kumar01/Reminder-Service)
- Booking Service -
[GitHub Repository Link](https://github.com/Rishabh-Kumar01/BookingService)
## Project Setup
- Clone the project on your local
- Execute `npm install` on the same path as of your root directory of the
downlaoded project
- Create a `.env` file in the root directory and add the following environment
variable
```
PORT=8004
AUTH_SERVICE_URL="http://localhost:8001"
FLIGHT_AND_SEARCH_SERVICE_URL="http://localhost:8000"
REMINDER_SERVICE_URL="http://localhost:8003"
BOOKING_SERVICE_URL="http://localhost:8002"
AUTH_SERVICE_PATH="/authservice"
FLIGHT_AND_SEARCH_SERVICE_PATH="/flightandsearchservice"
REMINDER_SERVICE_PATH="/reminderservice"
BOOKING_SERVICE_PATH="/bookingservice"
```
## Features
### HTTP Proxy Middleware
- The API Gateway uses the `http-proxy-middleware` library to create a reverse
proxy. This allows the gateway to forward incoming requests to various
microservices based on the request path.
- Configured paths and their corresponding target URLs are:
- Auth Service: `${AUTH_SERVICE_PATH}` -> `${AUTH_SERVICE_URL}`
- Booking Service: `${BOOKING_SERVICE_PATH}` -> `${BOOKING_SERVICE_URL}`
- Reminder Service: `${REMINDER_SERVICE_PATH}` -> `${REMINDER_SERVICE_URL}`
- Flight and Search Service: `${FLIGHT_AND_SEARCH_SERVICE_PATH}` ->
`${FLIGHT_AND_SEARCH_SERVICE_URL}`
### Rate Limiting
- The API Gateway implements rate limiting using the `express-rate-limit`
library to prevent abuse and ensure fair usage of resources.
- The rate limiter is configured to allow a maximum of 5 requests per minute
from a single IP address. Exceeding this limit will result in a
`429 Too Many Requests` response with a message indicating to try again after
15 minutes.
### Additional Features
- **IP Logging:** The gateway logs the IP address of each incoming request for
monitoring and security purposes.
- **Compression:** Using `compression` middleware to gzip compress responses for
improved performance.
- **Request Logging:** Using `morgan` to log HTTP requests for debugging and
monitoring.
## Running the API Gateway
- Start the API Gateway using the following command `npm start`
## Running the pm2 server
- "pm2:start": "pm2 start src/server.js --name airline-api-gateway",
- "pm2:stop": "pm2 stop airline-api-gateway",
- "pm2:delete": "pm2 delete airline-api-gateway"
### Then the run the command `npm run pm2:start` to start the pm2 server and so on to stop and delete.