1 import * as express from 'express'
2 import { UserRight } from '../../../../shared/models/users'
3 import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares'
4 import { updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy'
5 import { ServerModel } from '../../../models/server/server'
7 const serverRedundancyRouter = express.Router()
9 serverRedundancyRouter.put('/redundancy/:host',
11 ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW),
12 asyncMiddleware(updateServerRedundancyValidator),
13 asyncMiddleware(updateRedundancy)
16 // ---------------------------------------------------------------------------
19 serverRedundancyRouter
22 // ---------------------------------------------------------------------------
24 async function updateRedundancy (req: express.Request, res: express.Response, next: express.NextFunction) {
25 const server = res.locals.server as ServerModel
27 server.redundancyAllowed = req.body.redundancyAllowed
31 return res.sendStatus(204)