/booker

An example Node/Postgres application.

Primary LanguageJavaScript

Booker

An example Node/PostgreSQL application.

Getting Started

Postgres

 docker run --name some-postgres \
     -e POSTGRES_USER=mild \
     -e POSTGRES_PASSWORD=bitter \
     -e POSTGRES_DB=ipa # Will default to POSTGRES_USER \
     -p 5432:5432 \
     -d postgres

Initialise the .env file using the values used above.

cp .env.example .env

Server

npm i

npm start

Example Requests

Example cURL requests can be found below.

Add User

curl -d '{"email": "foo@bar.com"}' \
    -H "Content-Type: application/json" \
    -X POST http://localhost:3000/users

Get User

curl http://localhost:3000/users/{user_id}

Get Users

curl http://localhost:3000/users

Create Booking

curl -d '{"userId": "1", "dateTime": "2020-01-01 12:00:00"}' \
    -H "Content-Type: application/json" \
    -X POST http://localhost:3000/bookings

Get Booking

curl http://localhost:3000/bookings/{booking_id}

Get Bookings

curl http://localhost:3000/bookings

Get Bookings by user

curl http://localhost:3000/bookings/user/{user_id}

Delete Booking

curl -X DELETE http://localhost:3000/bookings/{booking_id}