A Book Repository API 😄
This API was developed to store names of books and authors and create a relationship in the database.
Languages used:
- Node.js https://nodejs.org/en/download/
- Sequelize (ORM) https://sequelize.org/
- Docker https://docs.docker.com/engine/install/ubuntu/
- PostgresSQL https://www.postgresql.org/download/
What will be needed to run the code:
2. Inside the project root, type in the terminal “npm install”
3. Now let’s run docker, because we won’t need to configure a database on the machine, but run on localhost and your “docker-compose.yml” is already configured
3.1 The use command “docker-compose up -d”
3.2 Check container logs docker “docker compose logs”
3.3 The database goes on http://localhost:16543 and
Get Diogo Almeida’s stories in your inbox
Join Medium for free to get updates from this writer.
User: admin@admin.com and password: admin123
3.4 Add server
3.5 Enter the database name and add the server, remembering that the password is the same as the one that entered the database initially and the hostname is “apiBook”. Click on Save
4. Using the modeling already done by sequelize, let’s import it to the database, with the command “npm or yarn sequelize db:migrate”
5. As we created a container by docker, our api is already instantiated in this container and can be accessed by “http://localhost:3000”
6. Using insomnia or Postman we will make our requests following the following routes:
- POST: http://localhost:3000/cadAuthor -> Create an author
- POST: http://localhost:3000/cadBook/idAuthorCreate/list -> Creates a book linked to that author
- GET: http://localhost:3000/repo-book -> Requires all registered books
- GET: http://localhost:3000/repo-book/idBook -> Requires the specific id of the book with its linked author
- GET: http://localhost:3000/cad-author/idAuthor -> Pulls the author and all books linked to it
- DELETE: http://localhost:3000/repo-book/:id -> Delete the book
Thanks a lot for reading 🤟
- 😎 Follow on social networks:
- Linkedin: https://www.linkedin.com/in/diogo-dos-reis-almeida-3973541b1/
- Github: https://github.com/diogoX451
- Instagram: https://www.instagram.com/diogoreisalmeida07/
This api is undergoing improvements, you can follow it on my Github. So the features it has can be useful for a simple application on the web.😄
By: Diogo Almeida








