0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-02 17:12:45 +00:00

Merge pull request #2589 from jeddai/client-server-version-mismatch-middleware

adjust frontend error handling, add client/server mismatch middleware
This commit is contained in:
Trevor Buckner
2023-01-23 15:40:48 -05:00
committed by GitHub
16 changed files with 276 additions and 327 deletions

View File

@@ -338,6 +338,7 @@ If you believe you should have access to this brew, ask the file owner to invite
}
};
router.use('/api', require('./middleware/check-client-version.js'));
router.post('/api', asyncHandler(api.newBrew));
router.put('/api/:id', asyncHandler(api.getBrew('edit', true)), asyncHandler(api.updateBrew));
router.put('/api/update/:id', asyncHandler(api.getBrew('edit', true)), asyncHandler(api.updateBrew));

View File

@@ -0,0 +1,12 @@
module.exports = (req, res, next)=>{
const userVersion = req.get('Homebrewery-Version');
const version = require('../../package.json').version;
if(userVersion != version) {
return res.status(412).send({
message : `Client version ${userVersion} is out of date. Please save your changes elsewhere and refresh to pick up client version ${version}.`
});
}
next();
};