[
  {
    "path": ".gitignore",
    "content": "# file types\n*.o\n*.a\n*.so\n*.exe\n*.test\n*.prof\n*.db\n*.DS_Store\n\n# folders\nvendor\nnode_modules\ntmp\n"
  },
  {
    "path": ".vscode/launch.json",
    "content": "{\n  \"version\": \"0.2.0\",\n  \"configurations\": [\n    {\n      \"name\": \"Launch\",\n      \"type\": \"go\",\n      \"request\": \"launch\",\n      \"mode\": \"debug\",\n      \"remotePath\": \"\",\n      \"port\": 2345,\n      \"host\": \"127.0.0.1\",\n      \"program\": \"${fileDirname}\",\n      \"env\": {},\n      \"args\": [],\n      \"showLog\": true\n    }\n  ]\n}"
  },
  {
    "path": "Godeps/Godeps.json",
    "content": "{\n\t\"ImportPath\": \"github.com/markcheno/go-vue-starter\",\n\t\"GoVersion\": \"go1.8\",\n\t\"GodepVersion\": \"v79\",\n\t\"Deps\": [\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/auth0/go-jwt-middleware\",\n\t\t\t\"Rev\": \"f3f7de3b9e394e3af3b88e1b9457f6f71d1ae0ac\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/dgrijalva/jwt-go\",\n\t\t\t\"Comment\": \"v3.0.0-17-g2268707\",\n\t\t\t\"Rev\": \"2268707a8f0843315e2004ee4f1d021dc08baedf\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/gorilla/mux\",\n\t\t\t\"Comment\": \"v1.3.0-5-g599cba5\",\n\t\t\t\"Rev\": \"599cba5e7b6137d46ddf58fb1765f5d928e69604\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/jinzhu/gorm\",\n\t\t\t\"Comment\": \"v1.0-138-g45ccb13\",\n\t\t\t\"Rev\": \"45ccb134373e7d9fa76d5987a6fed6cd5a5adfd4\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/jinzhu/gorm/dialects/postgres\",\n\t\t\t\"Comment\": \"v1.0-138-g45ccb13\",\n\t\t\t\"Rev\": \"45ccb134373e7d9fa76d5987a6fed6cd5a5adfd4\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/jinzhu/gorm/dialects/sqlite\",\n\t\t\t\"Comment\": \"v1.0-138-g45ccb13\",\n\t\t\t\"Rev\": \"45ccb134373e7d9fa76d5987a6fed6cd5a5adfd4\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/jinzhu/inflection\",\n\t\t\t\"Rev\": \"1c35d901db3da928c72a72d8458480cc9ade058f\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/lib/pq\",\n\t\t\t\"Comment\": \"go1.0-cutoff-166-g2704adc\",\n\t\t\t\"Rev\": \"2704adc878c21e1329f46f6e56a1c387d788ff94\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/lib/pq/hstore\",\n\t\t\t\"Comment\": \"go1.0-cutoff-166-g2704adc\",\n\t\t\t\"Rev\": \"2704adc878c21e1329f46f6e56a1c387d788ff94\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/lib/pq/oid\",\n\t\t\t\"Comment\": \"go1.0-cutoff-166-g2704adc\",\n\t\t\t\"Rev\": \"2704adc878c21e1329f46f6e56a1c387d788ff94\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/mattn/go-sqlite3\",\n\t\t\t\"Comment\": \"v1.2.0-80-gcf7286f\",\n\t\t\t\"Rev\": \"cf7286f069c3ef596efcc87781a4653a2e7607bd\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/satori/go.uuid\",\n\t\t\t\"Comment\": \"v1.1.0-8-g5bf94b6\",\n\t\t\t\"Rev\": \"5bf94b69c6b68ee1b541973bb8e1144db23a194b\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"github.com/urfave/negroni\",\n\t\t\t\"Comment\": \"v0.2.0-104-gc0db5fe\",\n\t\t\t\"Rev\": \"c0db5feaa33826cd5117930c8f4ee5c0f565eec6\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"golang.org/x/crypto/bcrypt\",\n\t\t\t\"Rev\": \"9ef620b9ca2f82b55030ffd4f41327fa9e77a92c\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"golang.org/x/crypto/blowfish\",\n\t\t\t\"Rev\": \"9ef620b9ca2f82b55030ffd4f41327fa9e77a92c\"\n\t\t},\n\t\t{\n\t\t\t\"ImportPath\": \"golang.org/x/net/context\",\n\t\t\t\"Rev\": \"d1e1b351919c6738fdeb9893d5c998b161464f0c\"\n\t\t}\n\t]\n}\n"
  },
  {
    "path": "Godeps/Readme",
    "content": "This directory tree is generated automatically by godep.\n\nPlease do not edit.\n\nSee https://github.com/tools/godep for more information.\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017 Mark Chenoweth\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# go-vue-starter\n\nCopyright 2017 Mark Chenoweth\n\n## Golang Starter project with Vue.js single page client\n\n### Work in progress...\n\n### Features:\n- Middleware: [Negroni](https://github.com/urfave/negroni)\n\n- Router: [Gorilla](https://github.com/gorilla/mux)\n\n- Orm: [Gorm](https://github.com/jinzhu/gorm) (sqlite or postgres)\n\n- Jwt authentication: [jwt-go](https://github.com/dgrijalva/jwt-go) and [go-jwt-middleware](https://github.com/auth0/go-jwt-middleware)\n\n- [Vue.js](https://vuejs.org/) spa client with webpack\n\n- User management\n\n### TODO:\n- config from file\n\n- email confirmation\n\n- logrus\n\n- letsencrypt tls\n\n### To get started:\n\n``` bash\n# clone repository\ngo get github.com/markcheno/go-vue-starter\ncd $GOPATH/src/github.com/markcheno/go-vue-starter\n\n# install Go dependencies (and make sure ports 3000/8080 are open)\ngo get -u ./... \ngo run server.go\n\n# open a new terminal and change to the client dir\ncd client\n\n# install dependencies\nnpm install\n\n# serve with hot reload at localhost:8080\nnpm run dev\n\n# build for production with minification\nnpm run build\n```\n\n### License\n\nMIT License  - see LICENSE for more details"
  },
  {
    "path": "api/api.go",
    "content": "package api\n\nimport (\n\t\"github.com/markcheno/go-vue-starter/models\"\n)\n\n// API -\ntype API struct {\n\tusers  *models.UserManager\n\tquotes *models.QuoteManager\n}\n\n// NewAPI -\nfunc NewAPI(db *models.DB) *API {\n\n\tusermgr, _ := models.NewUserManager(db)\n\tquotemgr, _ := models.NewQuoteManager(db)\n\n\treturn &API{\n\t\tusers:  usermgr,\n\t\tquotes: quotemgr,\n\t}\n}\n"
  },
  {
    "path": "api/quotes.go",
    "content": "package api\n\nimport \"net/http\"\n\n// Quote -\nfunc (api *API) Quote(w http.ResponseWriter, req *http.Request) {\n\tquote := api.quotes.RandomQuote()\n\tw.Write([]byte(quote.Text))\n}\n\n// SecretQuote -\nfunc (api *API) SecretQuote(w http.ResponseWriter, req *http.Request) {\n\tquote := api.quotes.RandomQuote()\n\tw.Write([]byte(quote.Text))\n}\n"
  },
  {
    "path": "api/users.go",
    "content": "package api\n\nimport (\n\t\"encoding/json\"\n\t\"net/http\"\n\n\t\"github.com/markcheno/go-vue-starter/auth\"\n\t\"github.com/markcheno/go-vue-starter/models\"\n)\n\n// UserJSON - json data expected for login/signup\ntype UserJSON struct {\n\tUsername string `json:\"username\"`\n\tPassword string `json:\"password\"`\n}\n\n// UserSignup -\nfunc (api *API) UserSignup(w http.ResponseWriter, req *http.Request) {\n\n\tdecoder := json.NewDecoder(req.Body)\n\tjsondata := UserJSON{}\n\terr := decoder.Decode(&jsondata)\n\n\tif err != nil || jsondata.Username == \"\" || jsondata.Password == \"\" {\n\t\thttp.Error(w, \"Missing username or password\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif api.users.HasUser(jsondata.Username) {\n\t\thttp.Error(w, \"username already exists\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tuser := api.users.AddUser(jsondata.Username, jsondata.Password)\n\n\tjsontoken := auth.GetJSONToken(user)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write([]byte(jsontoken))\n}\n\n// UserLogin -\nfunc (api *API) UserLogin(w http.ResponseWriter, req *http.Request) {\n\n\tdecoder := json.NewDecoder(req.Body)\n\tjsondata := UserJSON{}\n\terr := decoder.Decode(&jsondata)\n\n\tif err != nil || jsondata.Username == \"\" || jsondata.Password == \"\" {\n\t\thttp.Error(w, \"Missing username or password\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tuser := api.users.FindUser(jsondata.Username)\n\tif user.Username == \"\" {\n\t\thttp.Error(w, \"username not found\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif !api.users.CheckPassword(user.Password, jsondata.Password) {\n\t\thttp.Error(w, \"bad password\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tjsontoken := auth.GetJSONToken(user)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write([]byte(jsontoken))\n\n}\n\n// GetUserFromContext - return User reference from header token\nfunc (api *API) GetUserFromContext(req *http.Request) *models.User {\n\tuserclaims := auth.GetUserClaimsFromContext(req)\n\tuser := api.users.FindUserByUUID(userclaims[\"uuid\"].(string))\n\treturn user\n}\n\n// UserInfo - example to get\nfunc (api *API) UserInfo(w http.ResponseWriter, req *http.Request) {\n\n\tuser := api.GetUserFromContext(req)\n\tjs, _ := json.Marshal(user)\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(js)\n}\n"
  },
  {
    "path": "auth/auth.go",
    "content": "package auth\n\nimport (\n\t\"net/http\"\n\t\"time\"\n\n\tjwtmiddleware \"github.com/auth0/go-jwt-middleware\"\n\tjwt \"github.com/dgrijalva/jwt-go\"\n\t\"github.com/markcheno/go-vue-starter/models\"\n)\n\n// signingKey set up a global string for our secret\nvar signingKey = []byte(\"knrjkevdckjh\")\n\n// JwtMiddleware handler for jwt tokens\nvar JwtMiddleware = jwtmiddleware.New(jwtmiddleware.Options{\n\tValidationKeyGetter: func(token *jwt.Token) (interface{}, error) {\n\t\treturn signingKey, nil\n\t},\n\tUserProperty:  \"user\",\n\tDebug:         false,\n\tSigningMethod: jwt.SigningMethodHS256,\n})\n\n// GetToken create a jwt token with user claims\nfunc GetToken(user *models.User) string {\n\ttoken := jwt.New(jwt.SigningMethodHS256)\n\tclaims := token.Claims.(jwt.MapClaims)\n\tclaims[\"uuid\"] = user.UUID\n\tclaims[\"exp\"] = time.Now().Add(time.Hour * 24).Unix()\n\tsignedToken, _ := token.SignedString(signingKey)\n\treturn signedToken\n}\n\n// GetJSONToken create a JSON token string\nfunc GetJSONToken(user *models.User) string {\n\ttoken := GetToken(user)\n\tjsontoken := \"{\\\"id_token\\\": \\\"\" + token + \"\\\"}\"\n\treturn jsontoken\n}\n\n// GetUserClaimsFromContext return \"user\" claims as a map from request\nfunc GetUserClaimsFromContext(req *http.Request) map[string]interface{} {\n\t//claims := context.Get(req, \"user\").(*jwt.Token).Claims.(jwt.MapClaims)\n\tclaims := req.Context().Value(\"user\").(*jwt.Token).Claims.(jwt.MapClaims)\n\treturn claims\n}\n"
  },
  {
    "path": "client/.babelrc",
    "content": "{\n  \"presets\": [\n    [\"env\", { \"modules\": false }],\n    \"stage-2\"\n  ],\n  \"plugins\": [\"transform-runtime\"],\n  \"comments\": false,\n  \"env\": {\n    \"test\": {\n      \"presets\": [\"env\", \"stage-2\"],\n      \"plugins\": [ \"istanbul\" ]\n    }\n  }\n}\n"
  },
  {
    "path": "client/.editorconfig",
    "content": "root = true\n\n[*]\ncharset = utf-8\nindent_style = space\nindent_size = 2\nend_of_line = lf\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n"
  },
  {
    "path": "client/.eslintignore",
    "content": "build/*.js\nconfig/*.js\n"
  },
  {
    "path": "client/.eslintrc.js",
    "content": "// http://eslint.org/docs/user-guide/configuring\n\nmodule.exports = {\n  root: true,\n  parser: 'babel-eslint',\n  parserOptions: {\n    sourceType: 'module'\n  },\n  env: {\n    browser: true,\n  },\n  // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style\n  extends: 'standard',\n  // required to lint *.vue files\n  plugins: [\n    'html'\n  ],\n  // add your custom rules here\n  'rules': {\n    // allow paren-less arrow functions\n    'arrow-parens': 0,\n    // allow async-await\n    'generator-star-spacing': 0,\n    // allow debugger during development\n    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0\n  }\n}\n"
  },
  {
    "path": "client/.gitignore",
    "content": ".DS_Store\nnode_modules/\ndist/\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\ntest/unit/coverage\ntest/e2e/reports\nselenium-debug.log\n"
  },
  {
    "path": "client/.postcssrc.js",
    "content": "// https://github.com/michael-ciniawsky/postcss-load-config\n\nmodule.exports = {\n  \"plugins\": {\n    // to edit target browsers: use \"browserlist\" field in package.json\n    \"autoprefixer\": {}\n  }\n}\n"
  },
  {
    "path": "client/README.md",
    "content": "# starter\n\n> Go/Vue starter project\n\n## Build Setup\n\n``` bash\n# install dependencies\nnpm install\n\n# serve with hot reload at localhost:8080\nnpm run dev\n\n# build for production with minification\nnpm run build\n\n# build for production and view the bundle analyzer report\nnpm run build --report\n\n# run unit tests\nnpm run unit\n\n# run e2e tests\nnpm run e2e\n\n# run all tests\nnpm test\n```\n\nFor detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).\n"
  },
  {
    "path": "client/build/build.js",
    "content": "require('./check-versions')()\n\nprocess.env.NODE_ENV = 'production'\n\nvar ora = require('ora')\nvar rm = require('rimraf')\nvar path = require('path')\nvar chalk = require('chalk')\nvar webpack = require('webpack')\nvar config = require('../config')\nvar webpackConfig = require('./webpack.prod.conf')\n\nvar spinner = ora('building for production...')\nspinner.start()\n\nrm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {\n  if (err) throw err\n  webpack(webpackConfig, function (err, stats) {\n    spinner.stop()\n    if (err) throw err\n    process.stdout.write(stats.toString({\n      colors: true,\n      modules: false,\n      children: false,\n      chunks: false,\n      chunkModules: false\n    }) + '\\n\\n')\n\n    console.log(chalk.cyan('  Build complete.\\n'))\n    console.log(chalk.yellow(\n      '  Tip: built files are meant to be served over an HTTP server.\\n' +\n      '  Opening index.html over file:// won\\'t work.\\n'\n    ))\n  })\n})\n"
  },
  {
    "path": "client/build/check-versions.js",
    "content": "var chalk = require('chalk')\nvar semver = require('semver')\nvar packageConfig = require('../package.json')\nvar shell = require('shelljs')\nfunction exec (cmd) {\n  return require('child_process').execSync(cmd).toString().trim()\n}\n\nvar versionRequirements = [\n  {\n    name: 'node',\n    currentVersion: semver.clean(process.version),\n    versionRequirement: packageConfig.engines.node\n  },\n]\n\nif (shell.which('npm')) {\n  versionRequirements.push({\n    name: 'npm',\n    currentVersion: exec('npm --version'),\n    versionRequirement: packageConfig.engines.npm\n  })\n}\n\nmodule.exports = function () {\n  var warnings = []\n  for (var i = 0; i < versionRequirements.length; i++) {\n    var mod = versionRequirements[i]\n    if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {\n      warnings.push(mod.name + ': ' +\n        chalk.red(mod.currentVersion) + ' should be ' +\n        chalk.green(mod.versionRequirement)\n      )\n    }\n  }\n\n  if (warnings.length) {\n    console.log('')\n    console.log(chalk.yellow('To use this template, you must update following to modules:'))\n    console.log()\n    for (var i = 0; i < warnings.length; i++) {\n      var warning = warnings[i]\n      console.log('  ' + warning)\n    }\n    console.log()\n    process.exit(1)\n  }\n}\n"
  },
  {
    "path": "client/build/dev-client.js",
    "content": "/* eslint-disable */\nrequire('eventsource-polyfill')\nvar hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')\n\nhotClient.subscribe(function (event) {\n  if (event.action === 'reload') {\n    window.location.reload()\n  }\n})\n"
  },
  {
    "path": "client/build/dev-server.js",
    "content": "require('./check-versions')()\n\nvar config = require('../config')\nif (!process.env.NODE_ENV) {\n  process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)\n}\n\nvar opn = require('opn')\nvar path = require('path')\nvar express = require('express')\nvar webpack = require('webpack')\nvar proxyMiddleware = require('http-proxy-middleware')\nvar webpackConfig = process.env.NODE_ENV === 'testing'\n  ? require('./webpack.prod.conf')\n  : require('./webpack.dev.conf')\n\n// default port where dev server listens for incoming traffic\nvar port = process.env.PORT || config.dev.port\n// automatically open browser, if not set will be false\nvar autoOpenBrowser = !!config.dev.autoOpenBrowser\n// Define HTTP proxies to your custom API backend\n// https://github.com/chimurai/http-proxy-middleware\nvar proxyTable = config.dev.proxyTable\n\nvar app = express()\nvar compiler = webpack(webpackConfig)\n\nvar devMiddleware = require('webpack-dev-middleware')(compiler, {\n  publicPath: webpackConfig.output.publicPath,\n  quiet: true\n})\n\nvar hotMiddleware = require('webpack-hot-middleware')(compiler, {\n  log: () => {}\n})\n// force page reload when html-webpack-plugin template changes\ncompiler.plugin('compilation', function (compilation) {\n  compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {\n    hotMiddleware.publish({ action: 'reload' })\n    cb()\n  })\n})\n\n// proxy api requests\nObject.keys(proxyTable).forEach(function (context) {\n  var options = proxyTable[context]\n  if (typeof options === 'string') {\n    options = { target: options }\n  }\n  app.use(proxyMiddleware(options.filter || context, options))\n})\n\n// handle fallback for HTML5 history API\napp.use(require('connect-history-api-fallback')())\n\n// serve webpack bundle output\napp.use(devMiddleware)\n\n// enable hot-reload and state-preserving\n// compilation error display\napp.use(hotMiddleware)\n\n// serve pure static assets\nvar staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)\napp.use(staticPath, express.static('./static'))\n\nvar uri = 'http://localhost:' + port\n\nvar _resolve\nvar readyPromise = new Promise(resolve => {\n  _resolve = resolve\n})\n\nconsole.log('> Starting dev server...')\ndevMiddleware.waitUntilValid(() => {\n  console.log('> Listening at ' + uri + '\\n')\n  // when env is testing, don't need open it\n  if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {\n    opn(uri)\n  }\n  _resolve()\n})\n\nvar server = app.listen(port)\n\nmodule.exports = {\n  mounted: readyPromise,\n  close: () => {\n    server.close()\n  }\n}\n"
  },
  {
    "path": "client/build/utils.js",
    "content": "var path = require('path')\nvar config = require('../config')\nvar ExtractTextPlugin = require('extract-text-webpack-plugin')\n\nexports.assetsPath = function (_path) {\n  var assetsSubDirectory = process.env.NODE_ENV === 'production'\n    ? config.build.assetsSubDirectory\n    : config.dev.assetsSubDirectory\n  return path.posix.join(assetsSubDirectory, _path)\n}\n\nexports.cssLoaders = function (options) {\n  options = options || {}\n\n  var cssLoader = {\n    loader: 'css-loader',\n    options: {\n      minimize: process.env.NODE_ENV === 'production',\n      sourceMap: options.sourceMap\n    }\n  }\n\n  // generate loader string to be used with extract text plugin\n  function generateLoaders (loader, loaderOptions) {\n    var loaders = [cssLoader]\n    if (loader) {\n      loaders.push({\n        loader: loader + '-loader',\n        options: Object.assign({}, loaderOptions, {\n          sourceMap: options.sourceMap\n        })\n      })\n    }\n\n    // Extract CSS when that option is specified\n    // (which is the case during production build)\n    if (options.extract) {\n      return ExtractTextPlugin.extract({\n        use: loaders,\n        fallback: 'vue-style-loader'\n      })\n    } else {\n      return ['vue-style-loader'].concat(loaders)\n    }\n  }\n\n  // https://vue-loader.vuejs.org/en/configurations/extract-css.html\n  return {\n    css: generateLoaders(),\n    postcss: generateLoaders(),\n    less: generateLoaders('less'),\n    sass: generateLoaders('sass', { indentedSyntax: true }),\n    scss: generateLoaders('sass'),\n    stylus: generateLoaders('stylus'),\n    styl: generateLoaders('stylus')\n  }\n}\n\n// Generate loaders for standalone style files (outside of .vue)\nexports.styleLoaders = function (options) {\n  var output = []\n  var loaders = exports.cssLoaders(options)\n  for (var extension in loaders) {\n    var loader = loaders[extension]\n    output.push({\n      test: new RegExp('\\\\.' + extension + '$'),\n      use: loader\n    })\n  }\n  return output\n}\n"
  },
  {
    "path": "client/build/vue-loader.conf.js",
    "content": "var utils = require('./utils')\nvar config = require('../config')\nvar isProduction = process.env.NODE_ENV === 'production'\n\nmodule.exports = {\n  loaders: utils.cssLoaders({\n    sourceMap: isProduction\n      ? config.build.productionSourceMap\n      : config.dev.cssSourceMap,\n    extract: isProduction\n  })\n}\n"
  },
  {
    "path": "client/build/webpack.base.conf.js",
    "content": "var path = require('path')\nvar utils = require('./utils')\nvar config = require('../config')\nvar vueLoaderConfig = require('./vue-loader.conf')\n\nfunction resolve (dir) {\n  return path.join(__dirname, '..', dir)\n}\n\nmodule.exports = {\n  entry: {\n    app: './src/main.js'\n  },\n  output: {\n    path: config.build.assetsRoot,\n    filename: '[name].js',\n    publicPath: process.env.NODE_ENV === 'production'\n      ? config.build.assetsPublicPath\n      : config.dev.assetsPublicPath\n  },\n  resolve: {\n    extensions: ['.js', '.vue', '.json'],\n    alias: {\n      'vue$': 'vue/dist/vue.esm.js',\n      '@': resolve('src')\n    }\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.(js|vue)$/,\n        loader: 'eslint-loader',\n        enforce: 'pre',\n        include: [resolve('src'), resolve('test')],\n        options: {\n          formatter: require('eslint-friendly-formatter')\n        }\n      },\n      {\n        test: /\\.vue$/,\n        loader: 'vue-loader',\n        options: vueLoaderConfig\n      },\n      {\n        test: /\\.js$/,\n        loader: 'babel-loader',\n        include: [resolve('src'), resolve('test')]\n      },\n      {\n        test: /\\.(png|jpe?g|gif|svg)(\\?.*)?$/,\n        loader: 'url-loader',\n        options: {\n          limit: 10000,\n          name: utils.assetsPath('img/[name].[hash:7].[ext]')\n        }\n      },\n      {\n        test: /\\.(woff2?|eot|ttf|otf)(\\?.*)?$/,\n        loader: 'url-loader',\n        options: {\n          limit: 10000,\n          name: utils.assetsPath('fonts/[name].[hash:7].[ext]')\n        }\n      }\n    ]\n  }\n}\n"
  },
  {
    "path": "client/build/webpack.dev.conf.js",
    "content": "var utils = require('./utils')\nvar webpack = require('webpack')\nvar config = require('../config')\nvar merge = require('webpack-merge')\nvar baseWebpackConfig = require('./webpack.base.conf')\nvar HtmlWebpackPlugin = require('html-webpack-plugin')\nvar FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')\n\n// add hot-reload related code to entry chunks\nObject.keys(baseWebpackConfig.entry).forEach(function (name) {\n  baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])\n})\n\nmodule.exports = merge(baseWebpackConfig, {\n  module: {\n    rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })\n  },\n  // cheap-module-eval-source-map is faster for development\n  devtool: '#cheap-module-eval-source-map',\n  plugins: [\n    new webpack.DefinePlugin({\n      'process.env': config.dev.env\n    }),\n    // https://github.com/glenjamin/webpack-hot-middleware#installation--usage\n    new webpack.HotModuleReplacementPlugin(),\n    new webpack.NoEmitOnErrorsPlugin(),\n    // https://github.com/ampedandwired/html-webpack-plugin\n    new HtmlWebpackPlugin({\n      filename: 'index.html',\n      template: 'index.html',\n      inject: true\n    }),\n    new FriendlyErrorsPlugin()\n  ]\n})\n"
  },
  {
    "path": "client/build/webpack.prod.conf.js",
    "content": "var path = require('path')\nvar utils = require('./utils')\nvar webpack = require('webpack')\nvar config = require('../config')\nvar merge = require('webpack-merge')\nvar baseWebpackConfig = require('./webpack.base.conf')\nvar CopyWebpackPlugin = require('copy-webpack-plugin')\nvar HtmlWebpackPlugin = require('html-webpack-plugin')\nvar ExtractTextPlugin = require('extract-text-webpack-plugin')\nvar OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')\n\nvar env = process.env.NODE_ENV === 'testing'\n  ? require('../config/test.env')\n  : config.build.env\n\nvar webpackConfig = merge(baseWebpackConfig, {\n  module: {\n    rules: utils.styleLoaders({\n      sourceMap: config.build.productionSourceMap,\n      extract: true\n    })\n  },\n  devtool: config.build.productionSourceMap ? '#source-map' : false,\n  output: {\n    path: config.build.assetsRoot,\n    filename: utils.assetsPath('js/[name].[chunkhash].js'),\n    chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')\n  },\n  plugins: [\n    // http://vuejs.github.io/vue-loader/en/workflow/production.html\n    new webpack.DefinePlugin({\n      'process.env': env\n    }),\n    new webpack.optimize.UglifyJsPlugin({\n      compress: {\n        warnings: false\n      },\n      sourceMap: true\n    }),\n    // extract css into its own file\n    new ExtractTextPlugin({\n      filename: utils.assetsPath('css/[name].[contenthash].css')\n    }),\n    // Compress extracted CSS. We are using this plugin so that possible\n    // duplicated CSS from different components can be deduped.\n    new OptimizeCSSPlugin({\n      cssProcessorOptions: {\n        safe: true\n      }\n    }),\n    // generate dist index.html with correct asset hash for caching.\n    // you can customize output by editing /index.html\n    // see https://github.com/ampedandwired/html-webpack-plugin\n    new HtmlWebpackPlugin({\n      filename: process.env.NODE_ENV === 'testing'\n        ? 'index.html'\n        : config.build.index,\n      template: 'index.html',\n      inject: true,\n      minify: {\n        removeComments: true,\n        collapseWhitespace: true,\n        removeAttributeQuotes: true\n        // more options:\n        // https://github.com/kangax/html-minifier#options-quick-reference\n      },\n      // necessary to consistently work with multiple chunks via CommonsChunkPlugin\n      chunksSortMode: 'dependency'\n    }),\n    // split vendor js into its own file\n    new webpack.optimize.CommonsChunkPlugin({\n      name: 'vendor',\n      minChunks: function (module, count) {\n        // any required modules inside node_modules are extracted to vendor\n        return (\n          module.resource &&\n          /\\.js$/.test(module.resource) &&\n          module.resource.indexOf(\n            path.join(__dirname, '../node_modules')\n          ) === 0\n        )\n      }\n    }),\n    // extract webpack runtime and module manifest to its own file in order to\n    // prevent vendor hash from being updated whenever app bundle is updated\n    new webpack.optimize.CommonsChunkPlugin({\n      name: 'manifest',\n      chunks: ['vendor']\n    }),\n    // copy custom static assets\n    new CopyWebpackPlugin([\n      {\n        from: path.resolve(__dirname, '../static'),\n        to: config.build.assetsSubDirectory,\n        ignore: ['.*']\n      }\n    ])\n  ]\n})\n\nif (config.build.productionGzip) {\n  var CompressionWebpackPlugin = require('compression-webpack-plugin')\n\n  webpackConfig.plugins.push(\n    new CompressionWebpackPlugin({\n      asset: '[path].gz[query]',\n      algorithm: 'gzip',\n      test: new RegExp(\n        '\\\\.(' +\n        config.build.productionGzipExtensions.join('|') +\n        ')$'\n      ),\n      threshold: 10240,\n      minRatio: 0.8\n    })\n  )\n}\n\nif (config.build.bundleAnalyzerReport) {\n  var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin\n  webpackConfig.plugins.push(new BundleAnalyzerPlugin())\n}\n\nmodule.exports = webpackConfig\n"
  },
  {
    "path": "client/config/dev.env.js",
    "content": "var merge = require('webpack-merge')\nvar prodEnv = require('./prod.env')\n\nmodule.exports = merge(prodEnv, {\n  NODE_ENV: '\"development\"'\n})\n"
  },
  {
    "path": "client/config/index.js",
    "content": "// see http://vuejs-templates.github.io/webpack for documentation.\nvar path = require('path')\n\nmodule.exports = {\n  build: {\n    env: require('./prod.env'),\n    index: path.resolve(__dirname, '../dist/index.html'),\n    assetsRoot: path.resolve(__dirname, '../dist'),\n    assetsSubDirectory: 'static',\n    assetsPublicPath: '/',\n    productionSourceMap: false,\n    // Gzip off by default as many popular static hosts such as\n    // Surge or Netlify already gzip all static assets for you.\n    // Before setting to `true`, make sure to:\n    // npm install --save-dev compression-webpack-plugin\n    productionGzip: false,\n    productionGzipExtensions: ['js', 'css'],\n    // Run the build command with an extra argument to\n    // View the bundle analyzer report after build finishes:\n    // `npm run build --report`\n    // Set to `true` or `false` to always turn it on or off\n    bundleAnalyzerReport: process.env.npm_config_report\n  },\n  dev: {\n    env: require('./dev.env'),\n    port: 8080,\n    autoOpenBrowser: true,\n    assetsSubDirectory: 'static',\n    assetsPublicPath: '/',\n    // proxyTable: {},\n    proxyTable: {\n       '/api': {\n         target: 'http://localhost:3000/api',\n         changeOrigin: true,\n         pathRewrite: {\n             '^/api': ''\n         }\n      }\n    },\n    // CSS Sourcemaps off by default because relative paths are \"buggy\"\n    // with this option, according to the CSS-Loader README\n    // (https://github.com/webpack/css-loader#sourcemaps)\n    // In our experience, they generally work as expected,\n    // just be aware of this issue when enabling this option.\n    cssSourceMap: false\n  }\n}\n"
  },
  {
    "path": "client/config/prod.env.js",
    "content": "module.exports = {\n  NODE_ENV: '\"production\"'\n}\n"
  },
  {
    "path": "client/index.html",
    "content": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"utf-8\">\n    <title>Quote Server</title>\n    <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" integrity=\"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u\" crossorigin=\"anonymous\">\n  </head>\n  <body>\n    <div id=\"app\"></div>\n    <script src=\"https://code.jquery.com/jquery-3.2.1.slim.min.js\" integrity=\"sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g=\" crossorigin=\"anonymous\"></script>\n    <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js\" integrity=\"sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa\" crossorigin=\"anonymous\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "client/package.json",
    "content": "{\n  \"name\": \"starter\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Go/Vue starter project\",\n  \"author\": \"Mark Chenoweth\",\n  \"private\": true,\n  \"scripts\": {\n    \"dev\": \"node build/dev-server.js\",\n    \"start\": \"node build/dev-server.js\",\n    \"build\": \"node build/build.js\",\n    \"lint\": \"eslint --ext .js,.vue src\"\n  },\n  \"dependencies\": {\n    \"hoek\": \"^5.0.3\",\n    \"mime\": \"^2.3.1\",\n    \"npm\": \"^6.14.6\",\n    \"tough-cookie\": \"^2.4.3\",\n    \"vue\": \"^2.5.16\",\n    \"vue-resource\": \"^1.5.0\",\n    \"vue-router\": \"^2.8.1\"\n  },\n  \"devDependencies\": {\n    \"autoprefixer\": \"^6.7.2\",\n    \"babel-core\": \"^6.26.2\",\n    \"babel-eslint\": \"^7.2.3\",\n    \"babel-loader\": \"^6.2.10\",\n    \"babel-plugin-transform-runtime\": \"^6.22.0\",\n    \"babel-preset-env\": \"^1.6.1\",\n    \"babel-preset-stage-2\": \"^6.22.0\",\n    \"babel-register\": \"^6.26.0\",\n    \"chalk\": \"^1.1.3\",\n    \"chromedriver\": \"^2.38.2\",\n    \"compression-webpack-plugin\": \"^2.0.0\",\n    \"connect-history-api-fallback\": \"^1.5.0\",\n    \"copy-webpack-plugin\": \"^4.5.1\",\n    \"css-loader\": \"^2.1.1\",\n    \"eslint\": \"^4.19.1\",\n    \"eslint-config-standard\": \"^6.2.1\",\n    \"eslint-friendly-formatter\": \"^2.0.7\",\n    \"eslint-loader\": \"^1.9.0\",\n    \"eslint-plugin-html\": \"^4.0.1\",\n    \"eslint-plugin-promise\": \"^3.7.0\",\n    \"eslint-plugin-standard\": \"^2.0.1\",\n    \"eventsource-polyfill\": \"^0.9.6\",\n    \"express\": \"^4.18.2\",\n    \"extract-text-webpack-plugin\": \"^2.1.2\",\n    \"file-loader\": \"^0.10.0\",\n    \"friendly-errors-webpack-plugin\": \"^1.7.0\",\n    \"html-webpack-plugin\": \"^2.30.1\",\n    \"http-proxy-middleware\": \"^0.19.1\",\n    \"opn\": \"^4.0.2\",\n    \"optimize-css-assets-webpack-plugin\": \"^5.0.1\",\n    \"ora\": \"^1.4.0\",\n    \"rimraf\": \"^2.6.2\",\n    \"semver\": \"^5.5.0\",\n    \"shelljs\": \"^0.8.5\",\n    \"url-loader\": \"^1.1.2\",\n    \"vue-loader\": \"^11.1.4\",\n    \"vue-style-loader\": \"^2.0.0\",\n    \"vue-template-compiler\": \"^2.5.16\",\n    \"webpack\": \"^2.7.0\",\n    \"webpack-bundle-analyzer\": \"^4.8.0\",\n    \"webpack-dev-middleware\": \"^1.12.2\",\n    \"webpack-hot-middleware\": \"^2.25.3\",\n    \"webpack-merge\": \"^2.6.1\"\n  },\n  \"engines\": {\n    \"node\": \">= 4.0.0\",\n    \"npm\": \">= 3.0.0\"\n  },\n  \"browserslist\": [\n    \"> 1%\",\n    \"last 2 versions\",\n    \"not ie <= 8\"\n  ]\n}\n"
  },
  {
    "path": "client/src/App.vue",
    "content": "<template>\n<div id=\"app\">\n\n  <nav class=\"navbar navbar-default navbar-static-top\">\n    <div class=\"container\">\n      <div class=\"navbar-header\">\n        <button type=\"button\" class=\"navbar-toggle collapsed\" data-toggle=\"collapse\" data-target=\"#navbar\" aria-expanded=\"false\" aria-controls=\"navbar\">\n          <span class=\"sr-only\">Toggle navigation</span>\n          <span class=\"icon-bar\"></span>\n          <span class=\"icon-bar\"></span>\n          <span class=\"icon-bar\"></span>\n        </button>\n        <a class=\"navbar-brand\" href=\"#\">Brand</a>\n      </div>\n      <div id=\"navbar\" class=\"navbar-collapse collapse\">\n        <ul class=\"nav navbar-nav\">\n          <li><router-link to=\"home\">Home</router-link></li>\n          <li v-if=\"!isAuthenticated()\"><router-link to=\"login\">Login</router-link></li>\n          <li v-if=\"!isAuthenticated()\"><router-link to=\"signup\">Sign Up</router-link></li>\n          <li v-if=\"isAuthenticated()\"><router-link to=\"secretquote\">Secret Quote</router-link></li>\n          <li v-if=\"isAuthenticated()\"><router-link to=\"userinfo\">User Info</router-link></li>\n          <li v-if=\"isAuthenticated()\"><router-link to=\"logout\" @click.native=\"logout()\">Logout</router-link></li>\n        </ul>\n      </div>\n    </div>\n  </nav>\n\n  <div class=\"container\">\n    <router-view></router-view>\n  </div>\n</div>\n</template>\n\n<script>\nimport auth from './auth'\n\nexport default {\n\n  data () {\n    return {\n    }\n  },\n\n  methods: {\n    logout () {\n      auth.logout(this)\n    },\n    isAuthenticated () {\n      return auth.isAuthenticated()\n    }\n  }\n}\n</script>\n"
  },
  {
    "path": "client/src/auth/index.js",
    "content": "const API_URL = '/api/user/'\nconst LOGIN_URL = API_URL + 'login'\nconst SIGNUP_URL = API_URL + 'signup'\n\nexport default {\n\n  login (context, creds, redirect) {\n    context.$http.post(LOGIN_URL, creds).then(response => {\n      localStorage.setItem('id_token', response.body.id_token)\n      if (redirect) {\n        context.$router.replace(redirect)\n      }\n    }, response => {\n      context.error = response.statusText\n    })\n  },\n\n  signup (context, creds, redirect) {\n    context.$http.post(SIGNUP_URL, creds).then(response => {\n      localStorage.setItem('id_token', response.body.id_token)\n      if (redirect) {\n        context.$router.replace(redirect)\n      }\n    }, response => {\n      context.error = response.statusText\n    })\n  },\n\n  logout (context) {\n    localStorage.removeItem('id_token')\n    context.$router.replace('/home')\n  },\n\n  isAuthenticated () {\n    var jwt = localStorage.getItem('id_token')\n    if (jwt) {\n      return true\n    }\n    return false\n  },\n\n  getAuthHeader () {\n    return {\n      'Authorization': 'Bearer ' + localStorage.getItem('id_token')\n    }\n  }\n}\n"
  },
  {
    "path": "client/src/components/Home.vue",
    "content": "<template>\n  <div class=\"col-sm-6 col-sm-offset-3\">\n    <h1>Get a public quote!</h1>\n    <button class=\"btn btn-primary\" v-on:click=\"getQuote()\">Get a Quote</button>\n    <div class=\"quote-area\" v-if=\"quote\">\n      <h2><blockquote>{{ quote }}</blockquote></h2>\n    </div>\n  </div>\n</template>\n\n<script>\nexport default {\n  data () {\n    return {\n      quote: ''\n    }\n  },\n  methods: {\n    getQuote () {\n      this.$http.get('/api/quote/random').then(response => {\n        this.quote = response.body\n      }, response => {\n        console.log(response)\n      })\n    }\n  }\n}\n</script>\n"
  },
  {
    "path": "client/src/components/Login.vue",
    "content": "<template>\n  <div class=\"col-sm-4 col-sm-offset-4\">\n    <h2>Log In</h2>\n    <div class=\"alert alert-danger\" v-if=\"error\">\n      <p>{{ error }}</p>\n    </div>\n    <div class=\"form-group\">\n      <input\n        type=\"text\"\n        class=\"form-control\"\n        placeholder=\"Enter your username\"\n        v-model=\"credentials.username\"\n        v-on:keyup.enter=\"submit\"\n      >\n    </div>\n    <div class=\"form-group\">\n      <input\n        type=\"password\"\n        class=\"form-control\"\n        placeholder=\"Enter your password\"\n        v-model=\"credentials.password\"\n        v-on:keyup.enter=\"submit\"\n      >\n    </div>\n    <button class=\"btn btn-primary\" @click=\"submit\">Login</button>\n  </div>\n</template>\n\n<script>\nimport auth from '../auth'\n\nexport default {\n  data () {\n    return {\n      credentials: {\n        username: '',\n        password: ''\n      },\n      error: ''\n    }\n  },\n  methods: {\n    submit () {\n      var credentials = {\n        username: this.credentials.username,\n        password: this.credentials.password\n      }\n      auth.login(this, credentials, 'secretquote')\n    }\n  }\n}\n</script>\n"
  },
  {
    "path": "client/src/components/SecretQuote.vue",
    "content": "<template>\n  <div class=\"col-sm-6 col-sm-offset-3\">\n    <h1>Get a secret quote!</h1>\n    <button class=\"btn btn-warning\" v-on:click=\"getQuote()\">Get a Quote</button>\n    <div class=\"quote-area\" v-if=\"quote\">\n      <h2>\n        <blockquote>{{ quote }}</blockquote>\n      </h2>\n    </div>\n  </div>\n</template>\n\n<script>\nimport auth from '../auth'\n\nexport default {\n  data () {\n    return {\n      quote: ''\n    }\n  },\n  methods: {\n    getQuote () {\n      this.$http\n        .get('/api/quote/protected/random', { headers: auth.getAuthHeader() })\n        .then(\n          response => {\n            this.quote = response.body\n          },\n          response => {\n            if (response.status === 401) {\n              auth.logout(this)\n            }\n            console.log(response)\n          }\n        )\n    }\n  }\n}\n</script>\n"
  },
  {
    "path": "client/src/components/Signup.vue",
    "content": "<template>\n  <div class=\"col-sm-4 col-sm-offset-4\">\n    <h2>Sign Up</h2>\n    <div class=\"alert alert-danger\" v-if=\"error\">\n      <p>{{ error }}</p>\n    </div>\n    <div class=\"form-group\">\n      <input\n        type=\"text\"\n        class=\"form-control\"\n        placeholder=\"Enter your username\"\n        v-model=\"credentials.username\"\n        v-on:keyup.enter=\"submit\"\n      >\n    </div>\n    <div class=\"form-group\">\n      <input\n        type=\"password\"\n        class=\"form-control\"\n        placeholder=\"Enter your password\"\n        v-model=\"credentials.password\"\n        v-on:keyup.enter=\"submit\"\n      >\n    </div>\n    <button class=\"btn btn-primary\" @click=\"submit\">Signup</button>\n  </div>\n</template>\n\n<script>\nimport auth from '../auth'\n\nexport default {\n\n  data () {\n    return {\n      credentials: {\n        username: '',\n        password: ''\n      },\n      error: ''\n    }\n  },\n  methods: {\n    submit () {\n      var credentials = {\n        username: this.credentials.username,\n        password: this.credentials.password\n      }\n      // console.log('signup: credentials=', credentials)\n      auth.signup(this, credentials, 'secretquote')\n    }\n  }\n}\n</script>\n"
  },
  {
    "path": "client/src/components/UserInfo.vue",
    "content": "<template>\n  <div class=\"col-sm-6 col-sm-offset-3\">\n    <h1>User Info</h1>\n    <pre>{{ userinfo }}</pre>\n  </div>\n</template>\n\n<script>\nimport auth from '../auth'\n\nexport default {\n  data () {\n    return {\n      userinfo: ''\n    }\n  },\n  mounted () {\n    this.getUserInfo()\n  },\n  methods: {\n    getUserInfo () {\n      this.$http.get('/api/user/info', { headers: auth.getAuthHeader() }).then(\n        response => {\n          this.userinfo = response.body\n        },\n        response => {\n          if (response.status === 401) {\n            auth.logout(this)\n          }\n          console.log(response)\n        }\n      )\n    }\n  }\n}\n</script>\n"
  },
  {
    "path": "client/src/main.js",
    "content": "// The Vue build version to load with the `import` command\n// (runtime-only or standalone) has been set in webpack.base.conf with an alias.\nimport Vue from 'vue'\nimport App from './App'\nimport Home from '@/components/Home'\nimport Login from '@/components/Login'\nimport Signup from '@/components/Signup'\nimport SecretQuote from '@/components/SecretQuote'\nimport UserInfo from '@/components/UserInfo'\n\nimport VueResource from 'vue-resource'\nVue.use(VueResource)\n\nimport VueRouter from 'vue-router'\nVue.use(VueRouter)\n\nVue.config.productionTip = true\n\nimport auth from './auth'\n\nfunction requireAuth (to, from, next) {\n  if (!auth.isAuthenticated()) {\n    this.$router.replace('/login')\n  } else {\n    next()\n  }\n}\n\nconst router = new VueRouter({\n  mode: 'history',\n  // base: __dirname,\n  routes: [\n    {\n      path: '/',\n      component: Home\n    },\n    {\n      path: '/home',\n      name: 'home',\n      component: Home\n    },\n    {\n      path: '/login',\n      name: 'login',\n      component: Login\n    },\n    {\n      path: '/signup',\n      name: 'signup',\n      component: Signup\n    },\n    {\n      path: '/secretquote',\n      name: 'secretquote',\n      component: SecretQuote,\n      beforeEnter: requireAuth\n    },\n    {\n      path: '/userinfo',\n      name: 'userinfo',\n      component: UserInfo,\n      beforeEnter: requireAuth\n    }\n  ]\n})\n\n/* eslint-disable no-new */\nnew Vue({\n  el: '#app',\n  router,\n  template: '<App/>',\n  components: { App }\n})\n"
  },
  {
    "path": "client/static/.gitkeep",
    "content": ""
  },
  {
    "path": "models/db.go",
    "content": "package models\n\nimport (\n\t\"github.com/jinzhu/gorm\"\n\t// postgress db driver\n\t_ \"github.com/jinzhu/gorm/dialects/postgres\"\n\t// sqlite db driver\n\t_ \"github.com/jinzhu/gorm/dialects/sqlite\"\n)\n\n// DB abstraction\ntype DB struct {\n\t*gorm.DB\n}\n\n// NewPostgresDB - postgres database\nfunc NewPostgresDB(dataSourceName string) *DB {\n\n\tdb, err := gorm.Open(\"postgres\", dataSourceName)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err = db.DB().Ping(); err != nil {\n\t\tpanic(err)\n\t}\n\n\t//db.LogMode(true)\n\n\treturn &DB{db}\n}\n\n// NewSqliteDB - sqlite database\nfunc NewSqliteDB(databaseName string) *DB {\n\n\tdb, err := gorm.Open(\"sqlite3\", databaseName)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err = db.DB().Ping(); err != nil {\n\t\tpanic(err)\n\t}\n\n\t//db.LogMode(true)\n\n\treturn &DB{db}\n}\n"
  },
  {
    "path": "models/quotes.go",
    "content": "package models\n\nimport (\n\t\"math/rand\"\n\n\t\"github.com/jinzhu/gorm\"\n\t// postgress db driver\n\t_ \"github.com/jinzhu/gorm/dialects/postgres\"\n\t// import sqlite3 driver\n\t_ \"github.com/jinzhu/gorm/dialects/sqlite\"\n)\n\n// Quote struct\ntype Quote struct {\n\tgorm.Model\n\tText string\n}\n\n// QuoteManager struct\ntype QuoteManager struct {\n\tdb *DB\n}\n\n// NewQuoteManager - Create a quote manager that can be used for retrieving quotes\nfunc NewQuoteManager(db *DB) (*QuoteManager, error) {\n\n\tdb.AutoMigrate(&Quote{})\n\n\tquotemgr := QuoteManager{}\n\n\tquotemgr.db = db\n\n\treturn &quotemgr, nil\n}\n\n// RandomQuote - return a random quote\nfunc (qm *QuoteManager) RandomQuote() *Quote {\n\tquote := Quote{\n\t\tText: quotes[rand.Intn(len(quotes))],\n\t}\n\treturn &quote\n}\n\nvar quotes = []string{\n\t\"Chuck Norris doesn't call the wrong number. You answer the wrong phone.\",\n\t\"Chuck Norris has already been to Mars; that's why there are no signs of life.\",\n\t\"Chuck Norris and Superman once fought each other on a bet. The loser had to start wearing his underwear on the outside of his pants.\",\n\t\"Some magicans can walk on water, Chuck Norris can swim through land.\",\n\t\"Chuck Norris once urinated in a semi truck's gas tank as a joke....that truck is now known as Optimus Prime.\",\n\t\"Chuck Norris doesn't flush the toilet, he scares the sh*t out of it\",\n\t\"Chuck Norris counted to infinity - twice.\",\n\t\"Chuck Norris can cut through a hot knife with butter\",\n\t\"Chuck Norris is the reason why Waldo is hiding.\",\n\t\"Death once had a near-Chuck Norris experience\",\n\t\"When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.\",\n\t\"Chuck Norris can slam a revolving door.\",\n\t\"Chuck Norris once kicked a horse in the chin. Its decendants are known today as Giraffes.\",\n\t\"Chuck Norris will never have a heart attack. His heart isn't nearly foolish enough to attack him.\",\n\t\"Chuck Norris once got bit by a rattle snake........ After three days of pain and agony ..................the rattle snake died\",\n\t\"Chuck Norris can win a game of Connect Four in only three moves.\",\n\t\"When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.\",\n\t\"There is no theory of evolution. Just a list of animals Chuck Norris allows to live.\",\n\t\"Chuck Norris can light a fire by rubbing two ice-cubes together.\",\n\t\"Chuck Norris doesn’t wear a watch. HE decides what time it is.\",\n\t\"The original title for Alien vs. Predator was Alien and Predator vs Chuck Norris.\",\n\t\"The film was cancelled shortly after going into preproduction. No one would pay nine dollars to see a movie fourteen seconds long.\",\n\t\"Chuck Norris doesn't read books. He stares them down until he gets the information he wants.\",\n\t\"Chuck Norris made a Happy Meal cry.\",\n\t\"Outer space exists because it's afraid to be on the same planet with Chuck Norris.\",\n\t\"If you spell Chuck Norris in Scrabble, you win. Forever.\",\n\t\"Chuck Norris can make snow angels on a concrete slab.\",\n\t\"Chuck Norris destroyed the periodic table, because Chuck Norris only recognizes the element of surprise.\",\n\t\"Chuck Norris has to use a stunt double when he does crying scenes.\",\n\t\"Chuck Norris' hand is the only hand that can beat a Royal Flush.\",\n\t\"There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.\",\n\t\"Chuck Norris does not sleep. He waits.\",\n\t\"Chuck Norris tells a GPS which way to go.\",\n\t\"Some people wear Superman pajamas. Superman wears Chuck Norris pajamas.\",\n\t\"Chuck Norris's tears cure cancer ..... to bad he has never cried\",\n\t\"Chuck Norris doesn't breathe, he holds air hostage.\",\n\t\"Chuck Norris had a staring contest with Medusa, and won.\",\n\t\"When life hands Chuck Norris lemons, he makes orange juice.\",\n\t\"When Chuck Norris goes on a picnic, the ants bring him food.\",\n\t\"Chuck Norris gives Freddy Krueger nightmares.\",\n\t\"They once made a Chuck Norris toilet paper, but there was a problem: It wouldn't take shit from anybody.\",\n\t\"Chuck Norris can punch a cyclops between the eyes.\",\n\t\"Chuck Norris doesn't mow his lawn, he stands on the porch and dares it to grow\",\n\t\"Chuck Norris put out a forest fire. using only gasoline\",\n\t\"Chuck Norris CAN believe it's not butter.\",\n\t\"Custom t-shirts provided by Spreadshirt\",\n}\n"
  },
  {
    "path": "models/users.go",
    "content": "package models\n\nimport (\n\t\"github.com/jinzhu/gorm\"\n\t// postgress db driver\n\t_ \"github.com/jinzhu/gorm/dialects/postgres\"\n\t// import sqlite3 driver\n\t_ \"github.com/jinzhu/gorm/dialects/sqlite\"\n\tuuid \"github.com/satori/go.uuid\"\n\t\"golang.org/x/crypto/bcrypt\"\n)\n\n// User struct\ntype User struct {\n\tgorm.Model `json:\"-\"`\n\tUsername   string `gorm:\"not null;unique\" json:\"username\"`\n\tPassword   string `gorm:\"not null\" json:\"-\"`\n\tUUID       string `gorm:\"not null;unique\" json:\"uuid\"`\n}\n\n// UserManager struct\ntype UserManager struct {\n\tdb *DB\n}\n\n// NewUserManager - Create a new *UserManager that can be used for managing users.\nfunc NewUserManager(db *DB) (*UserManager, error) {\n\n\tdb.AutoMigrate(&User{})\n\n\tusermgr := UserManager{}\n\n\tusermgr.db = db\n\n\treturn &usermgr, nil\n}\n\n// HasUser - Check if the given username exists.\nfunc (state *UserManager) HasUser(username string) bool {\n\tif err := state.db.Where(\"username=?\", username).Find(&User{}).Error; err != nil {\n\t\treturn false\n\t}\n\treturn true\n}\n\n// FindUser -\nfunc (state *UserManager) FindUser(username string) *User {\n\tuser := User{}\n\tstate.db.Where(\"username=?\", username).Find(&user)\n\treturn &user\n}\n\n// FindUserByUUID -\nfunc (state *UserManager) FindUserByUUID(uuid string) *User {\n\tuser := User{}\n\tstate.db.Where(\"uuid=?\", uuid).Find(&user)\n\treturn &user\n}\n\n// AddUser - Creates a user and hashes the password\nfunc (state *UserManager) AddUser(username, password string) *User {\n\tpasswordHash := state.HashPassword(username, password)\n\tguid, _ := uuid.NewV4()\n\tuser := &User{\n\t\tUsername: username,\n\t\tPassword: passwordHash,\n\t\tUUID:     guid.String(),\n\t}\n\tstate.db.Create(&user)\n\treturn user\n}\n\n// HashPassword - Hash the password (takes a username as well, it can be used for salting).\nfunc (state *UserManager) HashPassword(username, password string) string {\n\thash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)\n\tif err != nil {\n\t\tpanic(\"Permissions: bcrypt password hashing unsuccessful\")\n\t}\n\treturn string(hash)\n}\n\n// CheckPassword - compare a hashed password with a possible plaintext equivalent\nfunc (state *UserManager) CheckPassword(hashedPassword, password string) bool {\n\tif bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(password)) != nil {\n\t\treturn false\n\t}\n\treturn true\n}\n"
  },
  {
    "path": "routes/routes.go",
    "content": "package routes\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/gorilla/mux\"\n\t\"github.com/markcheno/go-vue-starter/api\"\n\t\"github.com/markcheno/go-vue-starter/auth\"\n\t\"github.com/urfave/negroni\"\n)\n\n// NewRoutes builds the routes for the api\nfunc NewRoutes(api *api.API) *mux.Router {\n\n\tmux := mux.NewRouter()\n\n\t// client static files\n\tmux.Handle(\"/\", http.FileServer(http.Dir(\"./client/dist/\"))).Methods(\"GET\")\n\tmux.PathPrefix(\"/static/js\").Handler(http.StripPrefix(\"/static/js/\", http.FileServer(http.Dir(\"./client/dist/static/js/\"))))\n\n\t// api\n\ta := mux.PathPrefix(\"/api\").Subrouter()\n\n\t// users\n\tu := a.PathPrefix(\"/user\").Subrouter()\n\tu.HandleFunc(\"/signup\", api.UserSignup).Methods(\"POST\")\n\tu.HandleFunc(\"/login\", api.UserLogin).Methods(\"POST\")\n\tu.Handle(\"/info\", negroni.New(\n\t\tnegroni.HandlerFunc(auth.JwtMiddleware.HandlerWithNext),\n\t\tnegroni.Wrap(http.HandlerFunc(api.UserInfo)),\n\t))\n\n\t// quotes\n\tq := a.PathPrefix(\"/quote\").Subrouter()\n\tq.HandleFunc(\"/random\", api.Quote).Methods(\"GET\")\n\tq.Handle(\"/protected/random\", negroni.New(\n\t\tnegroni.HandlerFunc(auth.JwtMiddleware.HandlerWithNext),\n\t\tnegroni.Wrap(http.HandlerFunc(api.SecretQuote)),\n\t))\n\n\treturn mux\n}\n"
  },
  {
    "path": "server.go",
    "content": "package main\n\nimport (\n\t\"github.com/markcheno/go-vue-starter/api\"\n\t\"github.com/markcheno/go-vue-starter/models\"\n\t\"github.com/markcheno/go-vue-starter/routes\"\n\t\"github.com/urfave/negroni\"\n)\n\nfunc main() {\n\tdb := models.NewSqliteDB(\"data.db\")\n\tapi := api.NewAPI(db)\n\troutes := routes.NewRoutes(api)\n\tn := negroni.Classic()\n\tn.UseHandler(routes)\n\tn.Run(\":3000\")\n}\n"
  }
]