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.
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.
- Clone or download this repository
- Install dependencies
- Start the server
git clone git@github.com/Wokoro/way_farer
npm install
npm start
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.
- User can sign up.
- User can sign in.
- Admin can create a trip.
- Admin can cancel a trip.
- Both Admin and Users can see all trips.
- Users can book a seat on a trip.
- View all bookings. An Admin can see all bookings, while user can see all of his/her bookings.
- Users can delete their booking.
- Users can get a list of filtered trips based on origin.
- Users can get a list of filtered trips based on destination.
- Users can specify their seat numbers when making a booking.
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" : "testmail@yahoo.com" ,
"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": "testmail@yahoo.com",
"password": "secret"
}
Sample response
{
"status" : "success" ,
"status_code" : 200 ,
"data" : {
"user_id" : 1 ,
"is_admin" : true ,
"token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MzA4LCJpYXQiOjE1NTUxMDQzODQsImV4cCI6MTU1NTEwNzk4NH0.FCLELkNiNK8aqtIFLSGzRo1GUzLRfjpwM2NNl3Su2ow"
}
}
Documentation for this app is available at: API docs
You can also find the Postman collection to see more examples.
npm test
WayFarer is available under the MIT license. Visit LICENSE for more details.