summaryrefslogtreecommitdiff
path: root/public/js/lib/config
diff options
context:
space:
mode:
authorWu Cheng-Han2017-03-20 01:39:09 +0800
committerWu Cheng-Han2017-03-20 01:39:09 +0800
commit448b0061945b65dc36c08eaf6752060600d5895d (patch)
tree9b7dee9a9617518404f5a02a014f535f59ac24e6 /public/js/lib/config
parentb07eeed0c5a3c8de28e27326967cea592071ca6a (diff)
Update to generate front-end constants on server startup
To avoid extra webpacking on changing configs and follow the 12 factor app
Diffstat (limited to '')
-rw-r--r--public/js/lib/config/index.js18
1 files changed, 7 insertions, 11 deletions
diff --git a/public/js/lib/config/index.js b/public/js/lib/config/index.js
index 1ea7a7ab..11e4389f 100644
--- a/public/js/lib/config/index.js
+++ b/public/js/lib/config/index.js
@@ -1,14 +1,10 @@
-import configJson from '../../../../config.json' // root path json config
+export const GOOGLE_API_KEY = window.GOOGLE_API_KEY || ''
+export const GOOGLE_CLIENT_ID = window.GOOGLE_CLIENT_ID || ''
+export const DROPBOX_APP_KEY = window.DROPBOX_APP_KEY || ''
-const config = process.env.NODE_ENV === 'production' ? configJson.production : configJson.development
-
-export const GOOGLE_API_KEY = (config.google && config.google.apiKey) || ''
-export const GOOGLE_CLIENT_ID = (config.google && config.google.clientID) || ''
-export const DROPBOX_APP_KEY = (config.dropbox && config.dropbox.appKey) || ''
-
-export const domain = config.domain || '' // domain name
-export const urlpath = config.urlpath || '' // sub url path, like: www.example.com/<urlpath>
-export const debug = config.debug || false
+export const domain = window.domain || '' // domain name
+export const urlpath = window.urlpath || '' // sub url path, like: www.example.com/<urlpath>
+export const debug = window.debug || false
export const port = window.location.port
export const serverurl = `${window.location.protocol}//${domain || window.location.hostname}${port ? ':' + port : ''}${urlpath ? '/' + urlpath : ''}`
@@ -16,4 +12,4 @@ window.serverurl = serverurl
export const noteid = urlpath ? window.location.pathname.slice(urlpath.length + 1, window.location.pathname.length).split('/')[1] : window.location.pathname.split('/')[1]
export const noteurl = `${serverurl}/${noteid}`
-export const version = '0.5.0'
+export const version = window.version