This is an API for testing bank system. User can fetch bank details and use them accordingly.
All the data is fetched from https://bank-server-api-da9z.onrender.com endpoint.
GET /api/banks/| Parameter | Requested body | Description |
|---|---|---|
No parameters |
No body |
Required. _ |
[
{
"id": 60,
"name": "ABHYUDAYA COOPERATIVE BANK LIMITED"
},
{
"id": 1,
"name": "STATE BANK OF INDIA"
}
]
GET /api/:bankId/branches| Parameter | Requested body | Description |
|---|---|---|
No parameters |
{"bankId" : "int"} |
Required. bankId for which you want branches details |
[
{
"bank_name": "ABHYUDAYA COOPERATIVE BANK LIMITED",
"bank_id": 60,
"branch": "RTGS-HO",
"ifsc": "ABHY0065001",
"address": "ABHYUDAYA BANK BLDG., B.NO.71, NEHRU NAGAR, KURLA (E), MUMBAI-400024",
"city": "MUMBAI",
"district": "GREATER MUMBAI",
"state": "MAHARASHTRA"
},
{
"bank_name": "ABHYUDAYA COOPERATIVE BANK LIMITED",
"bank_id": 60,
"branch": "ABHYUDAYA NAGAR",
"ifsc": "ABHY0065002",
"address": "ABHYUDAYA EDUCATION SOCIETY, OPP. BLDG. NO. 18, ABHYUDAYA NAGAR, KALACHOWKY, MUMBAI - 400033",
"city": "MUMBAI",
"district": "GREATER MUMBAI",
"state": "MAHARASHTRA"
}
]
Install project with npm
cd project
npm install
node server.jsObjective: Establish a structured database to store bank and branch information.
Actions:
- Created a PostgreSQL database on Render.
- Designed two tables,
BanksandBranches, with appropriate fields and relationships.
Objective: Insert initial data into the database to facilitate development and testing.
Actions:
- Utilized pgAdmin4 for a remote connection to populate the
BanksandBranchestables with data.
Objective: Set up an Express server to handle API requests and interact with the PostgreSQL database.
Actions:
-
Project Initialization:
- Initialized the project with
npm initto createpackage.json. - Installed necessary dependencies:
express,pg.
- Initialized the project with
-
Server Configuration:
- Configured Express for server setup.
- Connected to the PostgreSQL database.
- Added middleware to parse JSON requests.
-
Route Creation:
- Defined API endpoints:
/banks: To retrieve information about all banks./banks/:bankId/branches: To retrieve branches associated with a specific bank.
- Defined API endpoints:
-
Controller Development:
- Developed a controller to handle the logic for fetching data from the database and responding to API requests.
-
Model Building:
- Created models for
BankandBranchto represent the database tables and define their relationships.
- Created models for
Objective: Ensure the API endpoints function correctly.
Actions:
- Created test cases using Jest and Supertest to verify the functionality of the API routes.
- Tested:
- Retrieval of all banks.
- Retrieval of branches for a specific bank.
The time taken to complete the entire work is nearly 2-3 days.