- This can help you quickly start your new Go and Fiber web application.
- Fiber and Go have been updated a lot since this was made.
- There are some pretty gore patterns 😱 from my youth(excuse 😅) that should definitely not be used.
- This repository still has useful configurations and code to get you started, but it's not a complete template that you can use without making changes.
- For more up-to-date info please refer to Gofiber Recipes
Used libraries:
- Gofiber Docker Dev Setup with Hot Reload
- User Auth functionality (Signup, Login, Forgot and Reset Password)
- JWT Authentication
- RESTful API
- Swagger REST API documentation
- Gorm (Golang SQL DB ORM) with Postgres implementation and auto migration
- MongoDB using the official mongo driver
- Configs via environmental variables
- Improved Input Validations(could be better)
- Custom Error messages
- Email notification (Welcome email, Reset password email)
- Redis
- Casbin
- WebSocket
- gRPC
- Improve MongoDB data integrity
- Create
.env
, i.e.
cp .env.example .env
- Download and install Swag for generating docs
go install github.com/swaggo/swag/cmd/swag@latest
- Run
- NOTE: You have to generate swagger docs before running the app.
# Terminal 1
swag init # Generates Swagger Docs
# Terminal 2
docker compose --env-file .env up # docker compose up (Run App With AutoReload)
docker compose --env-file .env down # docker compose down (Shutdown App)
- API
http://localhost:8000/api/v1
- Swagger Doc
http://localhost:8000/api/v1/swagger
- Create
.env
, i.e.
cp .env.example .env
- Update your
.env
variables for production
- Point to your prod database
- Update JWT issuer, secret key , blah blah
- Basically just follow good production practice
- Download Swag for generating docs
- Btw, you can use tags to exclude building swagger docs on prod
- Currently, they're not served because of a check in routes, but are needed to be build
go install github.com/swaggo/swag/cmd/swag@latest
- Generate Swagger Docs. You have to generate swagger docs before packaging the app.
swag init # Generates Swagger
- Build Your Image
- Permission the build script to run.
chmod +x docker-build.sh
- You could set the image port on
Dockerfile.prod
- Run the build script. You must provide a version tag as shown below.
./docker-build.sh -v gofiber:1.0.0
- Data Migrations ?
- Logger
- Unit tests
maybe?
- SMS notification (2FA ,Reset password code)
- GraphQL
- Deploy on Kubernetes
- Write an article
- Building Swago from source code -
go build -o swag.exe cmd/swag/main.go
Open to Suggestions and Pull Requests