REST API implementing Hexagonal Architecture (Ports & Adapters) making use of own scv-go-tools package.
It consists in a set of endpoints for user management that can indistinctly work with either a MongoDB or PostgreSQL instance, using the same handlers and business logic.
Provides:
make up
It starts 4 containers. Two of them are databases (MongoDB and PostgreSQL) and the other two are instances of the API, each of them already set up to work with one of the databases.
Both Swagger URLs are printed when running the command.
make down
Debugging configurations provided in launch.json for hitting both MongoDB and PostgreSQL containers. Just select the desired one in the VS Code´s build-in debugger and run it.
Then open http://localhost:{port}/swagger/index.html
, where {port}
is the value specified in launch.json for the selected configuration.
NOTES:
make up
). go run cmd/main.go --ver={version} --env={environment} --port={port} --db={database} --dsn={dsn}
or:
go build cmd/main.go
./main --ver={version} --env={environment} --port={port} --db={database} --dsn={dsn}
Provide the desired values to {version}
, {environment}
, {port}
, {database}
, {dsn}
.
Then open http://localhost:{port}/swagger/index.html
.
make test-unit
make cover
make test-integration
NOTES:
make swagger
make mocks
make goose
Write the file name without ".sql" suffix and press enter. Then edit the newly created file to define the behavior of the migration.
psql "{dsn}"
CREATE DATABASE {db_name};
az login
az postgres flexible-server db delete -g {resource_group} -s {resource_name} --database-name {db_name}
pg_dump -h {host} -U {username} {db_name} --schema-only > dump.sql
http://go-hexagonal-api-mongo-dev.westeurope.cloudapp.azure.com/swagger/index.html
http://go-hexagonal-api-postgres-dev.westeurope.cloudapp.azure.com/swagger/index.html
Sergi Canet Vela
This project is licensed under the terms of the MIT license.