This repository contains source code for Soccer API.
To run the project localy, make sure minimum requirements are fulfilled.
- Go version 1.10 or higher
- PostgreSQL version 12
- Docker (optional) -- see here.
Since the project already use Go Module, I recommend to put the source code in any folder but GOPATH.
-
Make sure Go is installed as global command (first time only)
-
Clone this project and go to the root project to install all dependencies (first time only)
// clone the repository > git clone https://github.com/usernamesalah/soccer-api.git // change directory to root project folder > cd soccer // install all the dependencies > make init
-
Running your PostgreSQL
-
While still in root project build and run the app
// build project > make build // source env > source .env.development // run project > ./bin/soccer // now go to http://localhost:8080/ in your browser to check the app.
-
Make sure Docker and Docker Compose is installed
-
Run
docker-compose up
-
Build and run the app as described on the previous section.
make test
for access POST , PUT and DELETE API you need to login with default (admin:admin)
We use swag to generate necearry Swagger files for API documentation. Everytime we run make build
, the Swagger documentation will be updated.
To configure your API documentation, please refer to swag's declarative comments format and examples.
To access the documentation, please visit API DOCUMENTATION.
- /api/v1 contains controllers and API route registry
- /pkg
- /pkg/models contains table models
- /pkg/services contains database transactions
In this project, I use some tools listed below
- All libraries listed in go.mod
- "github.com/vektra/mockery". To Generate Mocks for testing needs.