From 929159a0f47c144e46cb78ef97217f6110e29870 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 8 Jan 2021 14:49:04 +0530 Subject: [PATCH] implement server offline mode (no ws) --- lib/env.js | 4 ++++ package.json | 1 + server.js | 1 + 3 files changed, 6 insertions(+) diff --git a/lib/env.js b/lib/env.js index 322f629c6..97d3893f9 100644 --- a/lib/env.js +++ b/lib/env.js @@ -14,6 +14,7 @@ const Util = require("./common-util"); module.exports.create = function (config) { const Env = { + OFFLINE_MODE: false, FRESH_KEY: '', FRESH_MODE: true, DEV_MODE: false, @@ -117,6 +118,9 @@ module.exports.create = function (config) { //console.log("FRESH MODE ENABLED"); Env.FRESH_KEY = +new Date(); } + + // Offline mode is mostly for development. It lets us test clientside cache and offline support + if (process.env.OFFLINE) { Env.OFFLINE_MODE = true; } }()); Env.checkCache = function (channel) { diff --git a/package.json b/package.json index 86c7fc67b..0d52d70fe 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "start": "node server.js", "dev": "DEV=1 node server.js", "fresh": "FRESH=1 node server.js", + "offline": "FRESH=1 OFFLINE=1 node server.js", "package": "PACKAGE=1 node server.js", "lint": "jshint --config .jshintrc --exclude-path .jshintignore . && ./node_modules/lesshint/bin/lesshint -c ./.lesshintrc ./customize.dist/src/less2/", "lint:js": "jshint --config .jshintrc --exclude-path .jshintignore .", diff --git a/server.js b/server.js index 3869af509..9e26500ad 100644 --- a/server.js +++ b/server.js @@ -313,6 +313,7 @@ nThen(function (w) { Env.Log = _log; config.log = _log; + if (Env.OFFLINE_MODE) { return; } if (config.externalWebsocketURL) { return; } require("./lib/api").create(Env);