Complete Golang and Nuxt (VueJS) boilerplate for your project with backend API, frontend, tests and CI/CD pipelines.
Waleed Gadelkareem
Posted on July 28, 2020
Skeleton
A complete Golang and Nuxt boilerplate for your project with backend API, frontend, tests and CI/CD pipelines.
Features
- Backend written in Golang using Beego framework.
- Frontend written in NodeJS using NUXT and Vue.js frameworks.
- Material design using Vuetify.
- JSON REST API based on jsonapi.org standard.
- Fully featured user registration, login, password reminder, profile update, 2FA authentication, SMS based mobile confirmation, ... etc.
- JSON Web Tokens (JWT) based authentication.
- Social login using Facebook, LinkedIn, Google, Github.
- SEO friendly thanks to the NUXT Static Generated (Pre Rendering).
- SQL migration using sql-migrate.
- Rate limiter for API routes to easily set a rate limit per IP for one or more routes.
- Role-based access control (RBAC) for API routes and permissions.
- Pagination implementation for API and frontend with caching.
- Multi-factor authentication using One Time Passwords and mobile SMS code.
- Nice Email templates using Hermes.
- Fully featured admin dashboard based on Vuetify Material Dashboard.
- Complete CI/CD pipelines including tests using GitLab .gitlab-ci.yml file.
- Deploy to Heroku using few easy steps.
- Automated development initialization using Docker compose and init file.
- Application Cache using Cachita with support for memory, Redis, database and file cache.
- Dependency injection.
- Backend API integration and unit tests.
- Frontend Jest tests.
Development
There are 2 methods to run Skeleton locally
- Install required libs locally on OSX:
./init.sh init
Then Run the frontend and backend servers:
./init.sh
-- OR --
- Run the full stack on Docker:
Note that
yarn install
might take some time.
docker-compose up
# run tests
docker exec -it skeleton_backend_1 /bin/bash -c "go test -v ./... -count=1 | sort -u"
Generate Nuxt static files
./build.sh
Deploy to Heroku
- Fork the Skeleton repository on Gitlab
-
Add the following CI/CD environment variables in your Gitlab's CI/CD settings section:
- HEROKU_API_KEY: Your free Heroku API KEY
- PROD_CONFIG_SECRET_FILE (optional): Base64 encoded string of the
./src/backend/conf/app.prod.ini.secret
file. Use the ./src/backend/conf/app.dev.ini.secret.example as an example.
echo "$PROD_SECRET_FILE_CONTENTS" | base64
Navigate to your Heroku apps to open your app URL.
For more information, check .gitlab-ci.yml to review how the production container is being generated in the pipelines.
-
Optionally you can also push your final image to Docker Hub by adding your username and password as CI/CD environment variables:
- DOCKER_HUB_USER: docker hub username
- DOCKER_HUB_PASSWORD: docker hub password
Services
Mail service
Skeleton works in development with MailHog in docker which you can access via http://localhost:8025/. To use MailTrap instead, change ./src/backend/conf/app.dev.ini SMTP config to match MailTrap settings.
Tests
Backend
cd src/backend
go test -v ./... -count=1 | sort -u
#extra
go test -v backend/controllers -count=1 -debug=7 -run TestUserController_VerifyMobile
Frontend
cd src/frontend
yarn test
Posted on July 28, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.