Skip to content

badalsharma9929/project-ride

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rides API

A simple REST API for managing users and rides.

Setup

  1. Install dependencies:

    npm install
  2. Start the server:

    npm run dev

The server will start on port 3000.

API Documentation

Authentication

Register User

  • POST /api/users/register
  • Body:
    {
      "username": "john_doe",
      "password": "secure123"
    }
  • Response:
    {
      "message": "User registered successfully",
      "username": "john_doe"
    }

Rides

List Rides

  • GET /api/rides
  • Response:
    [
      {
        "id": "1",
        "distance": 5.2,
        "fare": 120
      },
      {
        "id": "2",
        "distance": 3.8,
        "fare": 90
      }
    ]

Get Ride Details

  • 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"
    }

Error Handling

The API returns appropriate HTTP status codes and error messages:

  • 400 - Bad Request (invalid input)
  • 404 - Not Found
  • 500 - Internal Server Error

Testing

Run tests using:

npm test

About

Fery - Assignment Submission Link 2025 Batch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors