A simple REST API for managing users and rides.
-
Install dependencies:
npm install
-
Start the server:
npm run dev
The server will start on port 3000.
- POST
/api/users/register - Body:
{ "username": "john_doe", "password": "secure123" } - Response:
{ "message": "User registered successfully", "username": "john_doe" }
- GET
/api/rides - Response:
[ { "id": "1", "distance": 5.2, "fare": 120 }, { "id": "2", "distance": 3.8, "fare": 90 } ]
- GET
/api/rides/:id - Response:
{ "id": "1", "distance": 5.2, "fare": 120, "pickup": "Central Park", "dropoff": "Times Square", "duration": "15 mins", "status": "completed", "timestamp": "2024-01-20T10:30:00Z" }
The API returns appropriate HTTP status codes and error messages:
400- Bad Request (invalid input)404- Not Found500- Internal Server Error
Run tests using:
npm test