Skip to content

Repository files navigation

Getting Started

This API was made on NextJS framework.

In this case only for backend purpose, using express under the hood and MongoDB as noSQL DB.

Requirements for the project

To build a Rest-API to manage users and their contacts.

User needs:

  • To create an user.
  • To update the contacts of a certain user.
  • To get the contacts in common of 2 or more users.
  • To get all the contacts from an user.

For this case we found a solution with 2 endpoints, "/users" and "/users/contacts", later on we go in deep with this.

Running the server

First, build the docker image:

docker-compose build

Then run the cluster:

 docker-compose up

Once the container is running in localhost:3000 you can start making requests to the API.

REST API

You can use this postman collection if you want.

  • To create an user: “/api/users” (POST)

    {
      "name": "John",
      "lastName": "Doe",
      "phone": "+34672690444"
    }
  • To save/update contacts by user given: “/api/users/contacts?userid=1” (PUT)

    Create an user and save the ID given once created.

    [
      {
          "contactName":"Mengano",
          "phone":"+34672690444"
      },
      {
          "contactName":"Fulano",
          "phone":"+34672690451"
      }
    ]
  • To get common contacts of 2 users given “/api/users/contacts?userid=1&userid=2” (GET)

  • To get all the contacts by user given “/api/users/contacts?userid=1” (GET)

Flow chart

ScreenShot

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages