Skip to content

Instantly share code, notes, and snippets.

@MartinMuzatko
Created January 28, 2019 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinMuzatko/7d8a331c56632c3a15baf00ab2163095 to your computer and use it in GitHub Desktop.
Save MartinMuzatko/7d8a331c56632c3a15baf00ab2163095 to your computer and use it in GitHub Desktop.
const { ConflictError, LockedError } = require('restify-errors');
const apps = require('./apps');
const { UpdateLockedError, UpdateDisabledError } = require('./exceptions');
module.exports = server => {
server.post('/Apps/update', async function (req, res, next) {
try {
let response = await apps.updateAll();
res.send(200, response);
next()
} catch (error) {
if (error instanceof UpdateLockedError) return next(new LockedError(error))
if (error instanceof UpdateDisabledError) return next(new ConflictError(error))
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment