A backend API for a public bus transportation booking server, created with Express.
Fork and clone a copy on your local machine. Typing npm install in your terminal will
download all the necessary packages needed for the server to work effectively.
- node shoule be installed on your local machine to run
npm install. - postgresql, the database needed to store data for API usage.
- postman, needed to view response from API endpoints.
npm start in your terminal will get the app running on localhost port 3000.
npm test will run a test to verify the veracity of the code.
You can modifly the variables in the .env file, to suit your needs.
All server api endpoints are secured with a JSON WEB TOKEN.
This resource /api/v1/auth/signup/ receives a POST request and sends an API response with the appropriate HTTP status code. Users can sign up to use resource
This resource /api/v1/auth/signin/ receives a POST request and sends an API response with the appropriate HTTP status code.
This resource /api/v1/trips receives a POST request and sends an API response with the appropriate HTTP status code. Admins can create trips.
This resource /api/v1/auth/signup/ receives a GET request and sends an API response with the appropriate HTTP status code. Users can view all trips.
This resource /api/v1/bookings/ receives a POST request and sends an API response with the appropriate HTTP status code. users can a book a seat on a trip.
This resource /api/v1/bookings/ receives a GET request and sends an API response with the appropriate HTTP status code. Admins can view all bookings, while users can view his/her bookings.
This resource /api/v1/bookings/:bookingId receives a DELETE request and sends an API response with the appropriate HTTP status code. Users can delete his/her bookings.
This resource /api/v1/trips/:tripId receives a PATCH request and sends an API response with the appropriate HTTP status code. Admins can cancel trips.
This resource /api/v1/trips/destination/:destination receives a GET request and sends an API response with the appropriate HTTP status code. Users can get trips filtered by destination.
This resource /api/v1/trips/origin/:origin receives a GET request and sends an API response with the appropriate HTTP status code. Users can get trips filtered by origin.
This resource /api/v1/bookings/user/:bookingId receives a PATCH request and sends an API response with the appropriate HTTP status code. Users can change seats after booking.
The tests confirms if the endpoints deliver the appropriate response and HTTP code, when given a valid request, and also to know if the error message delivered connotes the error.
A user signing up with all required parameters field will get a response similar to this
{
"status": "success",
"data": {
"user_id": 68,
"is_admin": false,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaXJzdE5hbWUiOiJraXl0IiwiZW1haWwiOiJrb2l5dEB5YWhvby5jb20iLCJsYXN0TmFtZSI6ImtvIiwicGFzc3dvcmQiOiJydHRyIiwiaWF0IjoxNTYyOTIxNzg4LCJleHAiOjE1NjI5MjIzOTJ9.MEStHWv_e5MHedALI35Po5La2OJXsgpkukBWS8Xnyhg"
}
}
while a user trying to get trips without an authorized token gets a response similar to this
{
"status": "error",
"error": "User unauthorized"
}
App is hosted on heroku
- Express - Backend server
- Postgresql - Database
- Mocha - To run test
- Andela - For the project guide
- Stack overflow - For the numerous unblocking :)