Skip to content

Latest commit

 

History

History
178 lines (115 loc) · 4.12 KB

File metadata and controls

178 lines (115 loc) · 4.12 KB

CodersCamp 2020 - Projekt końcowy REST API

PikaBook - Gotta read them all!


Mangos Team presents a system for books exchange.

Where users can finally make their reader's dreams come true. All of us, the readers, are struggling with the same problem - after some time our bookshelves are full of volumes, series of books we've already read. As there are books we want to keep for life, there are some that were meant to be read only once (We feel sorry for them too). PikaBook can give them a second life! Our API allows you to find other people that are willing to adopt your unneeded books in exchange for readings they offers.

Used technologies

  • Node.js / Express
  • REST API
  • JWT validation
  • NoSQL MongoDB and mongoose
  • authorization and authentication with Json Web Token
  • jest

Our team

Mentor: Łukasz Dutka


How to run it

Local set up

  1. Clone the repo
  2. npm install
  3. update src/pre-start/env/developement.env file with your Mongo database url DATABASE_URL=
  4. npm start:dev

Registration

To use most of API functionalities, you need to make an account and authorize yourself.

  1. Register with POST /api/users and provide
    {
        "password":
        "email":
        "name":
        "location":
    }
  1. Log in using POST /api/auth with
    {
        "password":
        "email":
    }

API functionalities

  • create an accaunt and log in to the system
  • add and remove books to/from their collection
  • filter books by users, location or title
  • user can initiate exchange with other user, propose its own books for other user's titles by creating a basket
  • possible to change basket status to track the book exchange
  • users can communicate over messages to agree on a details of the exchange
  • pokes - interaction between users, to let others know you are interested in one of their books

Books

Get the full list of all books. Possible parameters:

Parameter Type Description
location string Filter books by owner's location
name string Filter book by title
author string Filter book by author
year number Filter book by year published
genres list of strings separated by comma Filter by genre
GET /api/books
GET /api/books?name=book&location=city?genres=action,fantasy

Get a book by id

GET /api/books/:id

Add book

POST /api/books

Update one of actually logged in user books

PUT /api/books/:id

Delete book of actually logged in user

DELETE /api/books/:id

User

Get the list of all users

GET /api/users

Get a user by id

GET /api/users/:id/

Get user's books by id

GET /api/users/:id/books

Sending messages between users

Send a new messaage

POST /api/conversations

Update a message

PUT /api/conversations

Basket for books exchange

Available basket's status codes: 'pending', 'accepted', 'rejected', 'cancelled', 'offered','failedByRequestor', 'failedByTarget', 'success'

Create a basket

POST /api/baskets

Get a basket by id

GET /api/baskets/:id

Update a basket

PUT /api/baskets/:id

Pokes

Poke a user

POST /api/pokes

Update a poke

POST /api/pokes/:id

Logged user specific actions

Get a currently logged user

GET /api/me/

Get all books of the currently logged user

GET /api/me/books

Get all baskets of the currently logged user, possible to filter by status

GET /api/me/baskets
GET /api/me/baskets=offered

Get all conversations of the currently logged user

GET /api/me/conversations

Get a conversation with a specific user

GET /api/me/conversations/:id

Get all pokes of the currently logged user

GET /api/me/pokes

Get a poke by its ID

GET /api/me/pokes/:id

Get all baskets of currently logged user

GET /api/me/baskets