Skip to content

Commit

Permalink
Handle settings changes without restart
Browse files Browse the repository at this point in the history
Prior to this change, edited settings on the /admin/settings page
required a restart for the edit to take effect. This even causes the
settings page itself to not reflect the updated settings once you
navigate away from it or refresh. This change triggers the config to
reload when the settings are modified, which causes the impacted
templates to be recomputed.
  • Loading branch information
benjamincburns authored and mrvautin committed Sep 2, 2018
1 parent 70127ee commit 9b0f7a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ app.use((req, res, next) => {
next();
});

// update config when modified
app.use((req, res, next) => {
next();
if (res.configDirty) {
config = common.getConfig();
app.config = config;
}
});

// Ran on all routes
app.use((req, res, next) => {
res.setHeader('Cache-Control', 'no-cache, no-store');
Expand Down
1 change: 1 addition & 0 deletions routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ router.post('/admin/settings/update', common.restrict, common.checkAccess, (req,
let result = common.updateConfig(req.body);
if(result === true){
res.status(200).json({message: 'Settings successfully updated'});
res.configDirty = true;
return;
}
res.status(400).json({message: 'Permission denied'});
Expand Down

0 comments on commit 9b0f7a0

Please sign in to comment.