This project contains a quick starter kit for a Go project using Vue as single page app. The Go server uses MongoDB to store data, supports JWT authentication and embedding the Vue build. The Vue single page app supports routing via Vue Router, state management via Vuex and implements Googles Material Design using Vuetify.
- Go API using Gorilla mux
- Go server to serve the Vue app
- MongoDB integration
- JWT authentication
- Embedding Vue build into Go binary using esc
- Go server configuration via .yml file
- Using Go Modules for dependency management
- Makefile based project
- Routing via vue-router
- State management via vuex
- Material Design using vuetify
- TypeScript support
- Class-Style Vue Components
The Go ♥ Vue Starter contains a Go server which serves the single page Vue app and an API whiche handles all request from the Vue frontend. To run the Go server and Vue app as separated process run the following commands:
git clone github.com/ricoberger/go-vue-starter
go get -u github.com/mjibson/esc
# Run the Vue app on localhost:8080
cd go-vue-starter/web/vue.js
yarn install
yarn serve
# Run the Go server on localhost:8081
cd go-vue-starter
make build
./bin/starter
If you want to serve the Vue frontend app within the Go server run:
git clone github.com/ricoberger/go-vue-starter
go get -u github.com/mjibson/esc
# Build the Vue app
cd go-vue-starter/web/vue.js
yarn install
yarn build
# Run the Go server and the Vue app on localhost:8080
cd go-vue-starter
make build
./bin/starter
You can build and run the Go ♥ Vue Starter by your own or you can use the prebuild binaries. Befor you start the Go ♥ Vue Starter edit the config.yml
file:
# Port where the go-vue-starter should listen on
listen_address: :8080
api:
# Domain is for the frontend
domain: http://localhost:8080
# Signing secret for the jwt authentication
signing_secret: "your-super-secret"
app:
database:
# Connection URL for MongoDB and the name of the MongoDB database
mongodb:
connection_uri: mongodb://localhost:27017
database_name: go-vue-starter
# Email credentials to send the verification, reset password, etc. email
mail:
identity:
username:
password:
host:
addr:
from:
# Use html or plaintext emails, must be true or false
html:
# Email subjects
subjects:
welcome: "Welcome to the Go + Vue Starter"
reset-password: "Reset password request"
email-verification: "Verify your email address"
email-changed: "Your email address has been changed"
After you adjust the configuration file you can use the Go ♥ Vue Starter as follows:
Usage of starter:
-config.file string
Path to the configuration file. (default "config.yml")
-debug
Show debug information.
-version
Show version information.
Go ♥ Vue Starter is build up on some dependencies for Go and Vue. The Go dependencies are:
- crypto - Go supplementary cryptography libraries
- esc - A simple file embedder for Go
- gorilla/mux - A powerful URL router and dispatcher for golang
- jwt-go - Golang implementation of JSON Web Tokens (JWT)
- logrus - Structured, pluggable logging for Go
- mongo-go-driver - The Go driver for MongoDB
- yaml.v2 - YAML support for the Go language
The dependencies for the Vue app are:
- jwt-decode - Decode JWT tokens
- md5 - a JavaScript function for hashing messages with MD5
- vue - Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web
- vue-class-component - ES / TypeScript decorator for class-style Vue components
- vue-property-decorator - Vue.js and Property Decorator
- vue-router - The official router for Vue.js
- vuetify - Material Component Framework for Vue.js 2
- vuex - Centralized State Management for Vue.js
- vuex-class - Binding helpers for Vuex and vue-class-component