book_store_items-api
Items API
This application follows the Model, View, and Controller (MVC) pattern.
It also uses the gorilla mux HTTP framework to handle the requests.
Item is the core domain of this application.
Getting Started
Prerequisites
Environment variables
export ES_URL="http://127.0.0.1:9200"
Installing and running locally
# Install dependencies
make install
# Run postgres locally as a container
make env
# Run server locally
make run
# Run server locally with custom environment variables
MYSQL_URL=root:passwd@tcp(127.0.0.1:3305)/users_db?charset=utf8 \
make run
Setting up git hooks
After cloning the repository, change the git hooks path so it's only possible to commit code with the required quality.
make git-config
Running the tests and coverage report
To view report of tests locally use the following command:
make env # prepares environment for testing
make test
Running the lint verification
make lint
Lint report generate by GolangCI-lint.
Running vulnerability check in Go dependencies
make audit
Audit report generate by Nancy.
Deployment
Build
make build
Create release image, add tag and push
Tip: Do not forget to login to docker hub account.
docker login -u "username" -p "access_token" docker.io
make image tag push
OR
make image
make tag VERSION=1.0.0
sudo make push VERSION=1.0.0
Note: Change the version to the desired version.
Run registry image locally
Tip: Before running it locally you need to prepare the environment with the following command.
make env
It creates the network and the database containers.
make run-docker
make remove-docker
Project Structure
Package organization
The package structure used in this project was inspired by the golang-standards project.
Project layers organization
The project layers structure used in this project was inspired by the Hexagonal Architecture (Ports & Adapters).
Contributing
See CONTRIBUTING documentation for more details.
Changelog
See CHANGELOG documentation for more details.