Skip to content

Repository files navigation

Ride Management API

Deployed at this Domain using vercel might be slow because of MongoDB cloud : https://fery-api.vercel.app/api-docs/debug-env#

Overview

This is a simple API for managing users and rides. The API includes endpoints for:

  • Registering users
  • Listing rides
  • Fetching ride details

API Endpoints

1. Register User

Endpoint: POST /api/users/register
Request Body:

{
    "username": "testuser2",
    "password": "securepassword"
}

Response:
image

2. List Rides

Endpoint: GET /api/rides Response:

image

3. Ride Details

Endpoint: GET /api/rides/:id
Response (Valid ID):
image

Response (Invalid ID):

image

Tech Stack

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose

Setup Instructions

Prerequisites

  • Node.js and npm installed on your system.
  • MongoDB (local or cloud).

Steps

  1. Clone the repository:
    git clone https://github.com/Kimforee/FeryAPI
    cd FeryAPI
  2. Install dependencies:
    npm install
    npm install mongoose
  3. Set up the .env file:
    • Create a .env file in the root directory.
    • Add the following variables:
      MONGO_URI=mongodb://localhost:27017/rides
      PORT=5000
      
  4. Start the server:
    npm run dev
    Response:
    > ride-api@1.0.0 dev
    > nodemon server.js 
    [nodemon] 3.1.9
    [nodemon] to restart at any time, enter `rs`  
    [nodemon] watching path(s): *.*
    [nodemon] watching extensions: js,mjs,cjs,json
    [nodemon] starting `node server.js`
    Server running on port 5000
    MongoDB Connected: ride-shard-00-01.chhcg.mongodb.net

Testing

  • Use Postman or cURL to test the endpoints.
  • Ensure MongoDB is running before testing.

Directory Structure

├── controllers/
│   ├── rideController.js
│   ├── userController.js
├── models/
│   └── User.js
├── routes/
│   ├── rideRoutes.js
│   ├── userRoutes.js
├── utils/
│   └── mockRides.js
├── server.js
├── package.json
├── .env
├── README.md

About

A lightweight and efficient service for user registration and ride management. It provides endpoints for registering users, retrieving a list of rides, and fetching detailed ride information, built using Node.js and Express with MongoDB for persistence.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages