- Clone the repository
- Set up MongoDB (Both Local and MongoDB Atlas can be used)
- Create
.env
file at the root of this repository with:
MONGO_URI=mongodb://<YOUR MONGO CONNECTION STRING>
MONGO_DATABASE_NAME=<YOUR DATABASE NAME>
TOKEN_HOUR_LIFESPAN=<TIME IN HOUR FOR TOKEN LIFESPAN>
API_SECRET=<YOUR API SECRET>
go mod tidy
to get all the Go requirementsgo run .
to start the API
The API will be available at localhost:8080
This repo use swagger as the documentation. The generation process of the documentation is a follows. More info at https://github.com/swaggo/swag
- Add comments to your API source code.
- Install swag cli tools by:
go install github.com/swaggo/swag/cmd/swag@latest
- Run
swag init
to generate the documentation. - The documentation will be available at http://localhost:8080/swagger/index.html
go test .
With docker the development process can be easier. The database and the go environment will be automatically set up for you. You will need docker and docker-compose. The processes for running using docker as as follows.
- Build the images
docker-compose build
- Start the service by
docker-compose up
The API will be available at localhost:8080
When you build the images all of the file of this repository will be copied to the container. Then the go compiler will be run in the container.
Which means if you made change to the code you must re run docker-compose build