Our last (but not least) Becode Project !
Some guy called Jeff asked us for a library manager for his books, so we did it!
With GraphQL
Our demo website (On Heroku)
- Node.js (Server)
- PostgreSQL (Database)
- Sequelize (ORM)
- Babel (Transpiler)
- Apollo-Server && Apollo Client
Playground (query testing) is here.
If you want to query the Playground with some authentication, you can get it from here.
npm run build:server
In the src/
folder :
npm install --save-dev sequelize-cli
-
Fill the
bin/config/config.json
with the database credentials. -
in the
src/
folder :
npx sequelize db:create
- Creates the database
sequelize db:migrate
- Creates the following tables :
* books
* borrows
* comments
* opinions
* users
Note : Tables names are plural
Sequelize db:seed
- Optional, fills the tables with 3 books and their info.
The entries in the database, type and references (relations) are in the /models
folder
* books => book
* borrows => borrow
* comments => comment
* opinions => opinion
* users => user
All the queries, with a getAll...
will, by default render 5 books.
However, you can pass the limit parameter :
e.g :
getAllUsers(limit: 10) {...}
More informations about our API is in the Playground
createBook()
An error will occur if the ISBN (10 or 13) exists in the database
createBorrow()
An error will occur if a user already borrowed 5 books we know we have plenty books, but hey, bring back the 5 others, please
bookReturn()
An error will occur if the user tries to give back a book that he never borrowed. maybe he stole it ?
createComment()
An error will occur if the user already gave his opinion on the book. give the book a thumbs up, please
giveOpinion()
An error will occur if the user tries to reply more than once on a comment No need for drama in the comment section
createUser()
An error will occur if a user's username or email are in the database.
For obvious reasons
🦄 Lindsay Vannebenne
🕶 Michael Jacquemart
🔭 Victor Philippe