- Go Cryptography: This provides supplementary Go cryptography libraries.
- GoDotEnv: This will help with managing environment variables.
- GORM: This is an ORM (Object Relational Mapper) for Golang. In addition to the library, the GORM dialect (driver) for Postgres is installed to enable connections to PostgreSQL databases.
- JWT-Go: A Go implementation of JSON Web Tokens.
It assumes that you meet the prerequisites stated above to follow the steps below:
Clone repository
git clone https://github.com/edujudici/diary-api.git
Running database local
docker run --name postgres_db -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=diary -d postgres
Running application
go run main.go
https://documenter.getpostman.com/view/6493792/2s93sgVpmF
# register new user
POST: http://localhost:8000/register
# login with user and pass
# return jwt token
POST: http://localhost:8000/login
Example payload to register/login
{
"username": "userfortest",
"password": "passfortest"
}
# get all entries, set Bearer Token
GET: http://localhost:8008/api/entry
# create entry, set Bearer Token
POST: http://localhost:8008/api/entry
{
"content": "content here"
}
License
MIT