This project is an assignment given by Educase India to develop a set of Node.js APIs for managing school data.
The system enables adding new schools and retrieving a list of schools sorted by proximity to a user-specified location.
- Build APIs using Node.js, Express.js, and MySQL.
- Allow users to:
- Add new schools with details like name, address, latitude, and longitude.
- Retrieve schools sorted by geographical proximity to the user's location.
Create a schools table in MySQL with the following fields:
| Field | Type | Description |
|---|---|---|
| id | INT (PK) | Primary Key (Auto Increment) |
| name | VARCHAR | School Name |
| address | VARCHAR | School Address |
| latitude | FLOAT | School Latitude (Geo Coordinate) |
| longitude | FLOAT | School Longitude (Geo Coordinate) |
- Endpoint:
/addSchool - Method:
POST - Payload:
{ "name": "ABC Public School", "address": "New Delhi, India", "latitude": 28.6139, "longitude": 77.2090 }
-
Endpoint:
/listSchools -
Method:
GET -
Parameters:
latitude→ User's latitudelongitude→ User's longitude
-
Functionality:
- Fetches all schools from the database.
- Calculates distance between the user’s location and each school.
- Returns schools sorted by proximity (nearest first).