Self-paced

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Bootcamp

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Search from all Lessons


Login

Start interactive tutorial

← Back to Projects

Exercise Starwars Blog Express Api

Difficulty

  • easy

Average duration

8 hrs

Technologies

  • REST

  • typeOrm

  • Node

    Express

Difficulty

  • easy

Average duration

8 hrs

Technologies

🌱 How to start this project

Today we are going to build an API to manage a blog (The StarWars Blog). Users of this blog will be able to list planets, characters, and add or remove favorites.

To allow users to do all this, we must follow these steps:

  1. Start by modeling the database: create a database and the necessary tables to store that information. You may have already done this in the StarWars DataModeling project in node/express.
  2. Create your endpoints using Express.
  3. Constantly test your endpoints with Postman.

🌱 How to start this project

Do not clone this repository because we are going to use a different template.

We recommend opening the express.js template using a development environment like Codespaces (recommended). Alternatively, you can clone it on your local computer using the git clone command.

These are the repositories you need to open or clone:

1https://github.com/4GeeksAcademy/expressjs-rest-hello

⚠ If you work locally, you must have a database and Node.js, but if you use Codespaces or Gitpod, everything is already installed.

👉 Please follow these steps on how to start a coding project.

💡 Important: Remember to save and upload your code to GitHub by creating a new repository, updating the remote (git remote set-url origin <your new url>), and uploading the code to your new repository using the add, commit, and push commands from the git terminal.

📝 Instructions

Create an API connected to a database and implement the following endpoints (very similar to SWAPI.dev or SWAPI.tech):

  • [GET] /people Retrieve all people records from the database using Express.
  • [GET] /people/:people_id Show the information of a single character by its id, using route parameters in Express.
  • [GET] /planets Retrieve all planet records from the database.
  • [GET] /planets/:planet_id Show the information of a single planet by its id.

Additionally, create the following endpoints to manage users and their favorites:

  • [GET] /users Retrieve all blog users from the database.

  • [GET] /users/favorites Retrieve all favorites that belong to the current user.

  • [POST] /favorite/planet/:planet_id Add a new favorite planet to the current user, where :planet_id represents the ID of the planet to be added.

  • [POST] /favorite/people/:people_id Add a new favorite character to the current user, where :people_id represents the ID of the character to be added.

  • [DELETE] /favorite/planet/:planet_id Remove a favorite planet from the current user using its id.

  • [DELETE] /favorite/people/:people_id Remove a favorite character from the current user using its id.

  • Your current API does not have an authentication system implemented yet. Therefore, the only way to create users is directly in the database. Use tools like an admin panel or a database manager to manually add users.

Note: Here is an example in Postman: https://documenter.getpostman.com/view/2432393/TzRSgnTS#a4174b48-3fc8-46e3-bf82-19a08107666f

📖 Fundamentals

This exercise will allow you to practice the following skills and concepts:

  1. Building APIs using the REST standard (a.k.a: RESTful APIs).
  2. Building a database using the ORM called TypeORM.
  3. Using and understanding database migration systems with TypeORM's native migrations.

😎 Feeling confident?

The following requirements are not necessary to complete the project successfully, but you can develop them to continue your learning if you feel confident enough.

+4 Create endpoints to add (POST), modify (PUT), and delete (DELETE) planets and people. This way, the entire database can be managed via API instead of relying on the admin.

This and other projects are used to learn to code by students of 4Geeks Academy Coding Bootcamp conducted by Alejandro Sánchez and many other contributors. Learn more about our Programming Courses to become a Full Stack Developer, or our Data Science Bootcamp.

Sign up and get access to solution files and videos for free

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies

Sign up and get access to solution files and videos for free

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies