Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# WEBAPP
WEBAPP_HOST = localhost
WEBAPP_PORT = 3000
WEBAPP_BASE_URL = http://localhost:3000

# API
API_HOST = localhost
API_PORT = 3030

# METAAPI
EMBED_API_URL = http://localhost:3050

# 3rd party integrations
SENTRY_DNS_PUBLIC =
MAPBOX_TOKEN = pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ

# MAINTENANCE
MAINTENANCE =
18 changes: 18 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# WEBAPP
WEBAPP_HOST = ${WEBAPP_HOST}
WEBAPP_PORT = ${WEBAPP_PORT}
WEBAPP_BASE_URL = ${WEBAPP_BASE_URL}

# API
API_HOST = ${API_HOST}
API_PORT = ${API_PORT}

# METAAPI
EMBED_API_URL = ${EMBED_API_URL}

# 3rd party integrations
SENTRY_DNS_PUBLIC = ${SENTRY_DNS_PUBLIC}
MAPBOX_TOKEN = ${MAPBOX_TOKEN}

# MAINTENANCE
MAINTENANCE = ${MAINTENANCE}
35 changes: 0 additions & 35 deletions .env.tmp

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ npm-debug.log
/nbproject/private/
/nbproject/

# .env and .env-secrets
.env
.env-secrets

Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
- stage: Test and Build
script:
- yarn install --frozen-lockfile --non-interactive
- yarn test:env
- yarn test
- yarn run ci
- script:
- docker build -t humanconnection/frontend-nuxt .

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

This is the nuxt + express version of our WebApp as nuxt.js seams to be more stable and we have better options for keeping it updated.

## Build Setup
## Local installation

> we recommend to install the project locally for the best development ease and performance

Expand All @@ -34,6 +34,12 @@ $ yarn dev
$ yarn start
```

Create your individual set of environment variables:
```sh
$ cp .env.example .env
# now open .env and change it according to your setup
```

For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js).

## Env Vars
Expand Down
12 changes: 0 additions & 12 deletions entrypoint.sh

This file was deleted.

4 changes: 2 additions & 2 deletions middleware/authenticated.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isEmpty } from 'lodash'

export default async ({ store, route, redirect }) => {
let publicPages = process.env.publicPages
export default async ({ store, env, route, redirect }) => {
let publicPages = env.publicPages
publicPages.push('auth-logout')
// only affect non public pages
if (publicPages.indexOf(route.name) >= 0) {
Expand Down
4 changes: 2 additions & 2 deletions middleware/maintenance.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

export default async function ({ app, error, store, redirect, route }) {
export default async function ({ app, env, error, store, redirect, route }) {
let isMaintenanceEnabled = false
if (Boolean(app.$env.MAINTENANCE) === true) {
if (Boolean(env.MAINTENANCE) === true) {
error({ statusCode: 503, message: 'Maintenance Mode' })
return
}
Expand Down
17 changes: 14 additions & 3 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require('dotenv').config()
const path = require('path')

module.exports = {
Expand Down Expand Up @@ -112,8 +111,20 @@ module.exports = {
{src: '~/plugins/open-page-in-modal.js', ssr: false}
],
modules: [
'cookie-universal-nuxt',
'@nuxtjs/dotenv'
['@nuxtjs/dotenv', {
only: [
'WEBAPP_HOST',
'WEBAPP_PORT',
'WEBAPP_BASE_URL',
'API_HOST',
'API_PORT',
'EMBED_API_URL',
'SENTRY_DNS_PUBLIC',
'MAPBOX_TOKEN',
'MAINTENANCE'
]
}],
'cookie-universal-nuxt'
// '@nuxtjs/pwa'
],
router: {
Expand Down
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,20 @@
"yarn": ">= 1.3.0"
},
"scripts": {
"dev": "yarn dev:env && backpack dev",
"dev:local": "sh scripts/run-local.sh",
"dev:debug": "yarn dev:env && backpack dev --inspect-brk=9229",
"dev:env": "sh scripts/on-dev.sh",
"build": "yarn build:env && nuxt build && backpack build",
"build:env": "sh scripts/on-build.sh",
"start": "yarn start:env && node build/main.js",
"start:pm2": "yarn start:env && pm2 start node build/main.js -n frontend -i 2 --attach",
"start:env": "sh scripts/on-start.sh",
"refresh": "rm -rf node_modules && yarn install && npm run dev",
"ci": "yarn run eslint && yarn run test",
"clean": "rm -rf build/*",
"dev": "backpack dev",
"dev:debug": "backpack dev --inspect=0.0.0.0:9229",
"envsub": "envsub .env.template .env",
"build": "nuxt build && backpack build",
"start": "node build/main.js",
"start:pm2": "pm2 start node build/main.js -n frontend -i 2 --attach",
"deploy": "yarn run envsub && yarn run build && yarn run start:pm2",
"precommit": "yarn eslint",
"eslint": "eslint --ext .js,.vue .",
"styleguide": "vue-styleguidist server",
"styleguide:build": "vue-styleguidist build",
"test": "ava",
"test:env": "sh scripts/on-dev.sh",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
Expand All @@ -52,7 +50,7 @@
"@feathersjs/client": "^3.5.3",
"@feathersjs/feathers": "^3.1.7",
"@feathersjs/socketio": "^3.2.2",
"@nuxtjs/dotenv": "~1.1.0",
"@nuxtjs/dotenv": "^1.1.1",
"@nuxtjs/pwa": "~2.0.5",
"axios": "^0.18.0",
"babel-eslint": "~8.2.5",
Expand Down
10 changes: 5 additions & 5 deletions plugins/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import authentication from '@feathersjs/authentication-client'
import urlHelper from '~/helpers/urls'
import Vue from 'vue'

export default ({app, store, redirect, router}) => {
export default ({app, env, store, redirect, router}) => {
const authKey = 'feathers-jwt'
const endpoint = urlHelper.buildEndpointURL(app.$env.API_HOST, { port: app.$env.API_PORT })
const endpoint = urlHelper.buildEndpointURL(env.API_HOST, { port: env.API_PORT })
const storage = {
getItem: (key) => {
const res = app.$cookies.get(key)
Expand All @@ -26,7 +26,7 @@ export default ({app, store, redirect, router}) => {
},
clear: () => {
const res = app.$cookies.removeAll()
if (process.env.NODE_ENV === 'development') {
if (env.NODE_ENV === 'development') {
console.log(`## STORAGE: clear()`, res)
}
return res
Expand Down Expand Up @@ -60,7 +60,7 @@ export default ({app, store, redirect, router}) => {
all: [
async (hook) => {
// hook.accessToken = await api.passport.getJWT()
if (process.env.NODE_ENV === 'development') {
if (env.NODE_ENV === 'development') {
console.log('# API:', `${hook.method} ${hook.path}`)
console.info('data', hook.data)
// console.log('# ' + hook.accessToken)
Expand All @@ -70,7 +70,7 @@ export default ({app, store, redirect, router}) => {
]
},
async error (ctx) {
if (process.env.NODE_ENV === 'development') {
if (env.NODE_ENV === 'development') {
console.log('####################')
console.error(ctx.error)
console.info('JWT TOKEN: ', app.$cookies.get(authKey))
Expand Down
3 changes: 1 addition & 2 deletions plugins/env.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Vue from 'vue'

export default async (context) => {
await context.store.dispatch('env/init', context)
context.app.$env = context.store.getters['env/all']
context.app.$env = context.env

Vue.use({
install (Vue, store) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { debounce, isEmpty } from 'lodash'

import vuexI18n from 'vuex-i18n/dist/vuex-i18n.umd.js'

export default ({ app, req, cookie, store }) => {
const doDebug = process.env.NODE_ENV !== 'production'
export default ({ app, env, req, cookie, store }) => {
const doDebug = env.NODE_ENV !== 'production'
const key = 'locale'

const changeHandler = debounce((mutation, store) => {
Expand Down
12 changes: 6 additions & 6 deletions plugins/raven-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import Vue from 'vue'
import Raven from 'raven-js'
import RavenVue from 'raven-js/plugins/vue'

export default ({app}) => {
if (process.browser && app.$env.SENTRY_DNS_PUBLIC) {
export default ({env}) => {
if (process.browser && env.SENTRY_DNS_PUBLIC) {
Raven
.config(app.$env.SENTRY_DNS_PUBLIC, {
release: app.$env.BUILD_DATE,
environment: app.$env.NODE_ENV,
.config(env.SENTRY_DNS_PUBLIC, {
release: env.BUILD_DATE,
environment: env.NODE_ENV,
tags: {
deployed: app.$env.DEPLOY_DATE,
deployed: env.DEPLOY_DATE,
client: true
}
})
Expand Down
15 changes: 5 additions & 10 deletions plugins/raven-server.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import Raven from 'raven'
import dotenv from 'dotenv'
import {readFileSync} from 'fs'
import {resolve} from 'path'

export default async function (app) {
const secrets = dotenv.parse(await readFileSync(resolve('./server/.env-secrets')))

if (!process.client && secrets.SENTRY_DNS_PRIVATE) {
if (!process.client && process.env.SENTRY_DNS_PRIVATE) {
// LOGGING IS ENABLED
console.log('SENTRY LOGGING IS ENABLED')
Raven.config(secrets.SENTRY_DNS_PRIVATE, {
release: app.$env.BUILD_COMMIT,
environment: app.$env.NODE_ENV,
Raven.config(process.env.SENTRY_DNS_PRIVATE, {
release: process.env.BUILD_COMMIT,
environment: process.env.NODE_ENV,
tags: {
deployed: app.$env.DEPLOY_DATE,
deployed: process.env.DEPLOY_DATE,
client: true
}
}).install()
Expand Down
14 changes: 0 additions & 14 deletions scripts/on-build.sh

This file was deleted.

4 changes: 0 additions & 4 deletions scripts/on-dev.sh

This file was deleted.

24 changes: 0 additions & 24 deletions scripts/on-start.sh

This file was deleted.

5 changes: 0 additions & 5 deletions scripts/run-local.sh

This file was deleted.

2 changes: 0 additions & 2 deletions server/.env-secrets.tmp

This file was deleted.

Loading