Technologies • Getting Started • API Endpoints • Unit Tests •
Simple API with account creation and authentication
- Golang
- Docker
- PostgreSQL
- Fiber
git clone https://github.com/jotace1/go-auth-apiUse 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}cd go-auth-api
mockery --all
docker-compose up| 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 |
REQUEST
{
"username": "Joao",
"email": "joao@email.com",
"password": "1234567"
}RESPONSE
{
"account_id": "5a37d698-78e1-470e-8eb7-94c5aa802b8e",
"username": "Joao",
"email": "joao@email.com"
}REQUEST
{
"email": "joao123@email.com",
"password": "1234567"
}RESPONSE
{
"token": "OwoMRHsaQwyAgVoc3OXmL1JhMVUYXGGBbCTK0GBgiYitwQwjf0gVoBmkbuyy0pSi"
}REQUEST HEADER
"Authorization": "Bearer OwoMRHsaQwyAgVoc3OXmL1JhMVUYXGGBbCTK0GBgiYitwQwjf0gVoBmkbuyy0pSi"RESPONSE
"You are authenticated"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