mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 03:27:05 -04:00
Update to generate front-end constants on server startup
To avoid extra webpacking on changing configs and follow the 12 factor app
This commit is contained in:
parent
b07eeed0c5
commit
448b006194
5 changed files with 34 additions and 12 deletions
16
app.js
16
app.js
|
@ -29,6 +29,22 @@ var auth = require('./lib/auth.js')
|
|||
var response = require('./lib/response.js')
|
||||
var models = require('./lib/models')
|
||||
|
||||
// generate front-end constants by template
|
||||
var constpath = path.join(__dirname, './public/js/lib/common/constant.ejs')
|
||||
var data = {
|
||||
domain: config.domain,
|
||||
urlpath: config.urlpath,
|
||||
debug: config.debug,
|
||||
version: config.version,
|
||||
GOOGLE_API_KEY: config.google && config.google.GOOGLE_API_KEY,
|
||||
GOOGLE_CLIENT_ID: config.google && config.google.GOOGLE_CLIENT_ID,
|
||||
DROPBOX_APP_KEY: config.dropbox && config.google.DROPBOX_APP_KEY
|
||||
}
|
||||
ejs.renderFile(constpath, data, {}, function (err, str) {
|
||||
if (err) throw new Error(err)
|
||||
fs.writeFileSync(path.join(__dirname, './public/build/constant.js'), str)
|
||||
})
|
||||
|
||||
// server setup
|
||||
var app = express()
|
||||
var server = null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue