This project is a Node.js assignment focused on developing APIs for managing school data. The primary goal is to implement a set of APIs using the Express.js framework and MySQL to allow users to add new schools and retrieve a list of schools sorted by proximity to a user-specified location.
- Add School API: Allows users to add new schools to the database.
- List Schools API: Retrieves a list of schools sorted by proximity to the user's location.
Create a MySQL table named schools
with the following fields:
id
(Primary Key)name
(VARCHAR)address
(VARCHAR)latitude
(FLOAT)longitude
(FLOAT)
-
Add School API
- Endpoint:
/addSchool
- Method:
POST
- Payload: JSON object containing
name
,address
,latitude
, andlongitude
. - Functionality: Validates the input data and adds a new school to the
schools
table. - Validation: Ensures all fields are non-empty and of correct data types before insertion.
- Endpoint:
-
List Schools API
- Endpoint:
/listSchools
- Method:
GET
- Parameters: User's
latitude
andlongitude
. - Functionality: Fetches all schools from the database, calculates the geographical distance in km from the user's location, sorts the schools based on proximity, and returns the sorted list.
- Endpoint:
- Clone the Repository
git clone https://github.com/dkrpandit/Educase-India.git cd Educase-India
npm install