Spaces:
Sleeping
Sleeping
| const colourService = require('../services/colour.service'); | |
| exports.list = async (req, res, next) => { | |
| try { res.json(await colourService.list(req.query)); } | |
| catch (error) { next(error); } | |
| }; | |
| exports.create = async (req, res, next) => { | |
| try { res.status(201).json({ colour: await colourService.create(req.body, req.admin._id, req.ip) }); } | |
| catch (error) { next(error); } | |
| }; | |
| exports.update = async (req, res, next) => { | |
| try { res.json({ colour: await colourService.update(req.params.id, req.body, req.admin._id, req.ip) }); } | |
| catch (error) { next(error); } | |
| }; | |
| exports.toggleActive = async (req, res, next) => { | |
| try { res.json({ colour: await colourService.toggleActive(req.params.id, req.admin._id, req.ip) }); } | |
| catch (error) { next(error); } | |
| }; | |
| exports.bulkImport = async (req, res, next) => { | |
| try { | |
| const results = await colourService.bulkImport(req.body.colours, req.admin._id, req.ip); | |
| res.json({ message: `Imported ${results.created} colours.`, results }); | |
| } catch (error) { next(error); } | |
| }; | |
| exports.listCollections = async (req, res, next) => { | |
| try { res.json({ collections: await colourService.listCollections() }); } | |
| catch (error) { next(error); } | |
| }; | |
| exports.createCollection = async (req, res, next) => { | |
| try { res.status(201).json({ collection: await colourService.createCollection(req.body, req.admin._id, req.ip) }); } | |
| catch (error) { next(error); } | |
| }; | |
| exports.updateCollection = async (req, res, next) => { | |
| try { res.json({ collection: await colourService.updateCollection(req.params.id, req.body, req.admin._id, req.ip) }); } | |
| catch (error) { next(error); } | |
| }; | |