A robust Node.js/Express API to manage schools and calculate distance. Supports both MySQL and Neon PostgreSQL.
- Live URL: https://cautious-ermengarde-arya007-0f824957.koyeb.app
- Interactive API Docs (Swagger): https://cautious-ermengarde-arya007-0f824957.koyeb.app/api-docs
- Example Endpoint: https://cautious-ermengarde-arya007-0f824957.koyeb.app/api/schools/all
Note: The application is deployed on Koyeb and is kept awake (prevented from sleeping) by a GitHub Actions workflow that pings the server every 30 minutes.
npm install- Copy
.env.exampleto.envand fill in credentials. npm run init-db(initializes tables based on chosen DB)npm run dev- Visit
http://localhost:3000/api-docsto view the local Swagger documentation.
PORT=3000
DB_TYPE=mysql # or 'neon'
# MySQL connection string
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=
DB_NAME=school_db
# Neon (PostgreSQL) connection string
# DATABASE_URL=postgresql://user:password@hostname.neon.tech/dbname?sslmode=require
curl -X POST http://localhost:3000/api/schools/addSchool \
-H "Content-Type: application/json" \
-d '{"name":"Springfield High","address":"123 Main St","latitude":40.7128,"longitude":-74.006,"established_year":1990}'curl "http://localhost:3000/api/schools/listSchools?latitude=40.7&longitude=-74.0"curl "http://localhost:3000/api/schools/all"curl "http://localhost:3000/api/schools/1"curl -X PATCH http://localhost:3000/api/schools/1/status \
-H "Content-Type: application/json" \
-d '{"status":"inactive"}'curl -X DELETE "http://localhost:3000/api/schools/1"A fully configured Postman collection is included.
- Local File: Import the file located at
postman/School Management API.postman_collection.jsoninto your Postman client. - Shared Link: You can also download/view the collection directly from the repository.