Coder Social home page Coder Social logo

krofax / transport-booking-backend-api Goto Github PK

View Code? Open in Web Editor NEW
91.0 7.0 50.0 19 KB

A public bus transportation booking API - Such that Users book tickets for their trips, can see all their bookings and have the right to cancel any booking they do not want to use again.

JavaScript 100.00%

transport-booking-backend-api's Introduction

Transport Booking Server

A public bus transportation booking server, developed the back-end API with NodeJs and ExpressJs

Table of Contents (Optional)

Usage

Features

Add to Base URL above

  • Use the following Endpoints

    POST /auth/signup Create User Account

    POST /auth/signin Login A User

    POST /trips Create a trip (Needs admin priviledges)

    GET /trips Get all trips

    POST /bookings Book a seat on a trip

    GET /bookings See all of your bookings

    DELETE /bookings/:bookingId Delete A Booking

    PATCH /trips/:tripId Cancel A Trip (Needs admin priviledges)

    GET /user/seed Seed users table with users with admin rights

    POST /admin/signup An admin can add new admin (Needs admin priviledges)

    PUT /user/:id/admin An admin can give a registered user admin right (Needs admin priviledges)

    PUT /bookings/:bookingId Update Booking Seat Number

    POST /buses Add a bus (Needs admin priviledges)

    GET /buses Get all buses (Needs admin priviledges)

    GET /trips/origin?origin="origin" Filter trips by origin

    GET /trips/destination?destination="destination" Filter trips by destination

  • A successful response will be

     { status: 'success', data: {} }

    or

     { status: 'success', data: [] }

    and an unsuccessful response will be

    { status: 'error', error: '​relevant-error-message' }

Contributing

I would love to hear from anyone that will like to contribute

Prerequisites

Settings

If you want set up locally you can follow these steps, you can also use postman(https://www.getpostman.com/downloads/) to test. Clone the repository, open terminal in root and do the following on terminal

$ npm install

After Setting up the database, create database tables running the command below, its advisable to run the command more than once and make sure your database is updated with the tables:

$ npm run create-dev-tables

Start server by running:

$ npm run start

Seed Database tables with users(with admin right) by running the command below, its advisable to run it more than once:

$ npm run seed-user-table

or use

GET /user/seed Endpoint

Test endpoints by running:

$ npm run test

License

None for now.

developed with 💕 by Blessing Krofegha

transport-booking-backend-api's People

Contributors

krofax avatar orionjoshi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

transport-booking-backend-api's Issues

pool.query returns a promise if no callback passed

Hi!

I was following your guide and I've noticed that you created an unnecessary promise.

query(quertText, params) {
    return new Promise((resolve, reject) => {
      pool.query(quertText, params)
        .then((res) => {
          resolve(res);
        })
        .catch((err) => {
          reject(err);
        });
    });
  },

The upper could be transformed

query(quertText, params) {
     return pool.query(quertText, params);
}

to this, because if you don't provide a callback function it returns a promise.

Thanks for your post btw.
Have a nice day.

npm run create-dev-tables throws ReferenceError: createFamilyTable is not defined

Hi,

i was following settings steps, but got an error at step "npm run create-dev-tables"

[email protected] create-dev-tables /home/trgo/Transport-Booking-Backend-Api
babel-node ./app/db/dev/dbConnection createAllTables

/home/trgo/Transport-Booking-Backend-Api/app/db/dev/dbConnection.js:152
createFamilyTable();
^

ReferenceError: createFamilyTable is not defined

After commenting row createFamilyTable() all works as expected.
Thank you.

Authentication | drop the table are not working well..

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.