Skip to content

jotace1/go-auth-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Auth API 💻

TechnologiesGetting StartedAPI EndpointsUnit Tests

Simple API with account creation and authentication

💻 Technologies

  • Golang
  • Docker
  • PostgreSQL
  • Fiber

🚀 Getting started

Prerequisites

Cloning

git clone https://github.com/jotace1/go-auth-api

Config .env variables

Use the .env.example as reference to create your configuration file .env with your own Credentials

DATABASE_URL={DATABASE_URL}
SIGNATURE_SECRET={JWT_SIGNATURE_SECRET}
DB_USER={DB_USER}
DB_PASSWORD={DB_PASSWORD}
DB_NAME={DB_NAME}

Starting

cd go-auth-api
mockery --all
docker-compose up

📍 API Endpoints

route description
POST /account creates an user account see request details
POST /account/login authenticate user into the api see request details
GET /auth/test test route to check if token is valid see request details

POST /account

REQUEST

{
  "username": "Joao",
  "email": "joao@email.com",
  "password": "1234567"
}

RESPONSE

{
  "account_id": "5a37d698-78e1-470e-8eb7-94c5aa802b8e",
  "username": "Joao",
  "email": "joao@email.com"
}

POST /account/login

REQUEST

{
  "email": "joao123@email.com",
  "password": "1234567"
}

RESPONSE

{
  "token": "OwoMRHsaQwyAgVoc3OXmL1JhMVUYXGGBbCTK0GBgiYitwQwjf0gVoBmkbuyy0pSi"
}

POST /auth/test

REQUEST HEADER

"Authorization": "Bearer OwoMRHsaQwyAgVoc3OXmL1JhMVUYXGGBbCTK0GBgiYitwQwjf0gVoBmkbuyy0pSi"

RESPONSE

"You are authenticated"

🩺 Unit tests

This application is covered by unit tests in the handlers and usecases layers, to run the tests you just need to:

go test ./... -coverprofile coverage.out

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors