Skip to content

Wokoro/way_farer

Repository files navigation

Build Status Coverage Status Test Coverage Maintainability Codacy Badge dependencies Status Known Vulnerabilities License: MIT

WayFarer

WayFarer is a public bus transportation booking API that is meant to power front-end applications. It helps users and admin to easily carry out activities involved in booking and managing a trip.

WayFarer provides users a handful of other functionalities, which includes options to select a prefered sit when booking a trip, ability for users to delete their previously booked trips and get a view of all currently booked trips, which can be filtered by origin or destination.

Requirements

WayFarer is built with Node.js which is a backend technology and Express server which is a framework that enables creating Node.js applications easier.

WayFarer requires the installation of Node.js and npm (Node Package Manager). The backend is written in ES2015 so Babel is needed to compile it.

Installation

  • Clone or download this repository
  • Install dependencies
  • Start the server
git clone [email protected]/Wokoro/way_farer
npm install
npm start

Usage

WayFarer is hosted on Heroku here. Click on the link to access WayFarer easily.

You can also use Postman to make requests. A sample of Postman requests is published online as well. You can take a look at it to see examples of requests made to WayFarer and the responses gotten.

To use the API, make requests to the endpoints supported by WayFarer and get your responses as JSON objects ready to use in the frontend.

Features

Required Features

  1. User can sign up.
  2. User can sign in.
  3. Admin can create a trip.
  4. Admin can cancel a trip.
  5. Both Admin and Users can see all trips.
  6. Users can book a seat on a trip.
  7. View all bookings. An Admin can see all bookings, while user can see all of his/her bookings.
  8. Users can delete their booking.

Optional Features

  1. Users can get a list of filtered trips based on origin.
  2. Users can get a list of filtered trips based on destination.
  3. Users can specify their seat numbers when making a booking.

Endpoints

BasePath: https://way_farer-api.heroku.com or http//:localhost:3000
Request Type Function Access Level Enpoint Postman Collection
POST Sign Up User /api/v1/auth/signup
POST Sign In User /api/v1/auth/signin
POST Create a trip Admin /api/v1/trips
GET Get all trips User /api/v1/trips
GET Get all trips based on destination or origin User /api/v1/trips/?filter=""
PATCH Change sit after booking User(limited to his/her bookings) /api/v1/trips/:bookingId
POST Book a seat on a trip User /api/v1/bookings
GET View all bookings. An Admin can see all bookings, while user can see all of his/her bookings. Admin and User(limited to his/her booking) /api/v1/bookings
DELETE Delete a booking. User /api/v1/bookings/:bookingId
PATCH Cancel a trip Admin /api/v1//trips/:tripId

Sample sign up request:

{
    "email" : "[email protected]" ,
    "first_name" : "James" ,
    "last_name" : "Softman" ,
    "sex" : "male",
    "password" : "secret" ,
    "comfirm_password" : "secret" ,
    "is_admin" : true,
    "phone_number": "09077484759"
}

Sample response

{
    "status" : "success" ,
    "status_code" : 200,
    "data" : {
        "user_id" : 1,
        "is_admin": true,
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MzA4LCJpYXQiOjE1NTUxMDQzODQsImV4cCI6MTU1NTEwNzk4NH0.FCLELkNiNK8aqtIFLSGzRo1GUzLRfjpwM2NNl3Su2ow"
    }
}

Sample sign In request:

{
  "email": "[email protected]",
  "password": "secret"
}

Sample response

{
    "status" : "success" ,
    "status_code" : 200 ,
    "data" : {
        "user_id" : 1 ,
        "is_admin" : true ,
        "token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MzA4LCJpYXQiOjE1NTUxMDQzODQsImV4cCI6MTU1NTEwNzk4NH0.FCLELkNiNK8aqtIFLSGzRo1GUzLRfjpwM2NNl3Su2ow"
    }
}

Documentation

Documentation for this app is available at: API docs

You can also find the Postman collection to see more examples.

Tests

npm test

License

WayFarer is available under the MIT license. Visit LICENSE for more details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published