Skip to content

osvaldoabel/user-api

Repository files navigation

Documentation

Build Status

. Introduction
. Project Requirements
. Api Endoints
. TO DO

Introduction

In this repository, we have everything we need to run this User Api project using docker containers. Below you can see a basic guide to learning how to run it in your local environment.

In this project, we create a REST API (user-api) using hexagonal architecture or ports & adapters architecture resulting in a robust and flexible project. So it's pretty simple to add new features, new Entities, etc. Including if we need to add a console adapter, the application layers will keep intact.

Swagger docs

image

Requirements

You need to have Git and Docker installed and running on your machine.

Clone Project

$ git clone https://gitlab.com/osvaldoabel/user-api project-name

Run Project

# Get into the cloned repo
$ cd user-api

# Build and start containers, 
$ docker-compose up -d --build 
# You can also verify the containers status
$ docker-compose ps
  # get into vm.app to do anything you might need
$ docker exec -it vm.app bash

API Endpoints

  • CREATE User

POST http://localhost:8800/users HTTP/1.1
Content-Type: application/json

{
    "name": "User example",
    "age": 40,
    "email": "abel44@test.com",
    "password": "123456",
    "status": "active",
    "address":  "Rua teste, 123"
}
  • UPDATE User

PUT http://localhost:8800/users/4d4edebc-ed56-4fa7-bb14-df0f9204a16a HTTP/1.1
Content-Type: application/json
Authorization: Bearer {{token}}

{
    "id": "4d4edebc-ed56-4fa7-bb14-df0f9204a16a",
    "name": "user ",
    "age": 37,
    "address": "Rua teste, 123 ate 9"
}
  • LIST users (Paginated)

# /users?page=4&limit=2

GET http://0.0.0.0:8800/users?page=4&limit=2 HTTP/1.1
Content-Type: application/json 
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTIwNTM1NDgsInN1YiI6ImJjNTkwMzg1LTFjOTgtNDNkNy1iN2FmLTY3OWI1OGUzNzc5YSJ9.oJhTOIGNqYZ0Wb4rwrviVlKOjoesvqg0OtETn3y0Nsg

  • SHOW User

#/v1/users/fa9f88f4-4fe8-46d8-afb3-85886c50ec4c 

curl -X GET http://localhost:8888/v1/users/fa9f88f4-4fe8-46d8-afb3-85886c50ec4c -H 'Content-Type: application/json' \
  -d '{
    "name": "User 3 - updated",
    "email": "updated3@example.com",
    "status": "active",
    "address": "My Address",
    "password": "semsenha",
    "age": 35
}'

To DO

NOTE: It Would be interesting if we persisted we implement a rate limit.

NOTE 2 This is just a hypothetical scenario. If your project doesn't grow to this magnitude, you don't need to implement it this way.

Developed by Osvaldo Abel

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages