Created
January 28, 2019 10:36
-
-
Save MartinMuzatko/7d8a331c56632c3a15baf00ab2163095 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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