I have built a backend system that support multiple feature of airline company.
This api gateway is backend for frontend
FRONT-END => MIDDLE-END => BACK-END
This project follow microservice architecture and it has four services for specific logic and one api gateway where all repository mention below.
- NodeJS This is a cross-platform runtime environment built on Chrome's V8 JavaScript engine used in running JavaScript codes on the server.
- ExpressJS This is a NodeJS web application framework.
- MySql This is an open-source relational database management system (RDBMS) that is widely used for managing and organizing data.
- Sequelize ORM This is a popular Object-Relational Mapping (ORM) library for Node.js. It provides a way to interact with relational databases such as MySQL, PostgreSQL, SQLite, and MSSQL using JavaScript..
- Sequelize cli The Sequelize Command Line Interface (CLI) is a powerful tool for working with Sequelize, which is a promise-based Node.js ORM (Object-Relational Mapping) for PostgreSQL, MySQL, SQLite, and MSSQL.
**Please note: You make sure that all the service working properly before initialize API Gateway
.
-
Clone the repository:
git clone https://github.com/singhvivekkumar/api-gateway.git
-
Move to the backend folder:
cd api-gateway
-
Install and set up Docker.
npm install
The .env
file should contain the following environment variables:
PORT=3005
BOOKING_SERVICE='http://localhost:<BOOKING_SERVICE_PORT_NUMBER>'
AUTH_SERVICE='http://localhost:<BOOKING_SERVICE_PORT_NUMBER>'
SEARCH_SERVICE='http://localhost:<BOOKING_SERVICE_PORT_NUMBER>'
AUTHENICATE_URL='http://localhost:<BOOKING_SERVICE_PORT_NUMBER>/api/v1/isauthenticated'
To start the backend server, run the following command:
npm start
GET http://localhost:3005/api/home
{ "message": "successfully hitted api gateway" }
POST: http://localhost:3005/auth/api/v1/signup`` body:
{
email: test@gamil.com,
password: 13245768
}`
HTTP/1.1 201 Ok
Status: 404 Not Found
Connection: keep-alive
Content-Type: application/json
{
"data": {
"id": 8,
"email": "<EMAIL_ID>",
"password": "<ENCRYPTED_PASSWORD>",
"updatedAt": "2023-11-24T18:27:28.189Z",
"createdAt": "2023-11-24T18:27:28.189Z"
},
"success": true,
"message": "Successfully user signed in website",
"err": {}
}
POST http://localhost:3005/auth/api/v1/signin body: { email: test@gamil.com, password: 13245768 }
HTTP/1.1 201 Ok
Status: 404 Not Found
Connection: keep-alive
Content-Type: application/json
{
"data": <JWT_TOKEN>,
"success": true,
"message": "Successfully user signed in website",
"err": {}
}
Congratulations! Your backend is now running at http://localhost:3005/.