1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-18 19:19:36 +02:00
flame/controllers/apps/reorderApps.js

28 lines
650 B
JavaScript

const asyncWrapper = require('../../middleware/asyncWrapper');
const App = require('../../models/App');
const ErrorResponse = require('../../utils/ErrorResponse');
// @desc Reorder apps
// @route PUT /api/apps/0/reorder
// @access Public
const reorderApps = asyncWrapper(async (req, res, next) => {
if (!req.isAuthenticated) {
return next(new ErrorResponse('Unauthorized', 401));
}
req.body.apps.forEach(async ({ id, orderId }) => {
await App.update(
{ orderId },
{
where: { id },
}
);
});
res.status(200).json({
success: true,
data: {},
});
});
module.exports = reorderApps;