From 6c48bc9d60f16f72320bb8d48ed8a104d120fd2d Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Wed, 15 Apr 2020 02:03:38 +1200 Subject: [PATCH] Hopefully support Heroku --- Procfile | 1 + src/lib/constants.js | 9 +++++++-- src/site/assistant.js | 2 +- src/site/server.js | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 Procfile diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..c76e14e --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: npm run $(test "$BIBLIOGRAM_ENTRY" = 'assistant' && echo 'assistant' || echo 'start') diff --git a/src/lib/constants.js b/src/lib/constants.js index 346e799..3e76488 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -127,6 +127,11 @@ let constants = { // Override values from config and export the result const md = require("mixin-deep") -const config = require("../../config") -constants = md(constants, config) +if (process.env.BIBLIOGRAM_CONFIG) { // presence of environment variable BIBLIOGRAM_CONFIG overrides /config.js + const config = JSON.parse(process.env.BIBLIOGRAM_CONFIG) + constants = md(constants, config) +} else { + const config = require("../../config") + constants = md(constants, config) +} module.exports = constants diff --git a/src/site/assistant.js b/src/site/assistant.js index 294b1c6..22ec9a0 100644 --- a/src/site/assistant.js +++ b/src/site/assistant.js @@ -5,7 +5,7 @@ const constants = require("../lib/constants") const passthrough = require("./passthrough") const pinski = new Pinski({ - port: constants.port, + port: +process.env.PORT || constants.port, relativeRoot: __dirname }) diff --git a/src/site/server.js b/src/site/server.js index 741b5fc..8931819 100644 --- a/src/site/server.js +++ b/src/site/server.js @@ -5,7 +5,7 @@ const constants = require("../lib/constants") const passthrough = require("./passthrough") const pinski = new Pinski({ - port: constants.port, + port: +process.env.PORT || constants.port, relativeRoot: __dirname, basicCacheControl: { exts: ["ttf", "woff2", "png", "jpg", "jpeg", "svg", "gif", "webmanifest", "ico"],