Spaces:
Sleeping
Sleeping
File size: 835 Bytes
10821c7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | const marketService = require('../services/market.service');
exports.list = async (req, res, next) => {
try { res.json({ markets: await marketService.list() }); }
catch (error) { next(error); }
};
exports.getById = async (req, res, next) => {
try { res.json({ market: await marketService.getById(req.params.id) }); }
catch (error) { next(error); }
};
exports.update = async (req, res, next) => {
try { res.json({ market: await marketService.update(req.params.id, req.body, req.admin._id, req.ip) }); }
catch (error) { next(error); }
};
exports.toggleActive = async (req, res, next) => {
try {
const market = await marketService.toggleActive(req.params.id, req.admin._id, req.ip);
res.json({ market, message: `Market ${market.isActive ? 'activated' : 'deactivated'}.` });
} catch (error) { next(error); }
};
|