/var/www/qr4y.com/server/delivery/api/controllers/country_code
Edit: /var/www/qr4y.com/server/delivery/api/controllers/country_code/delete.js (746B)
const { NotFound } = require('../../responseModels/errors')
const { isNumber } = require('../../utils/validator.util')
const checkPermission = require('../../utils/checkPermission.util')
module.exports = function ({ db, logger }) {
return async (req, res, next) => {
logger.child({ path: req.path, request: req.body }).info()
try {
checkPermission(req, 'country_code_edit')
const { id } = req.body
const countryCode = await db.countryCode.findOne({
where: { id: id }
})
if (!countryCode) {
throw new NotFound({ lang: req.user?.languageCode })
}
await db.countryCode.destroy({ where: { id: id } })
return res.status(200).json({ status: 'success', id: countryCode.id })
} catch (err) {
next(err)
}
}
}