/var/www/qr4y.com/server/delivery/api/controllers/country_code
Edit: /var/www/qr4y.com/server/delivery/api/controllers/country_code/list.js (957B)
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.query }).info()
try {
const countryCodes = await db.countryCode.findAll({
order: [
["name", "ASC" ]
]
})
if (countryCodes.length == 0 || !countryCodes) {
throw new NotFound({ lang: req.user?.languageCode })
}
return res.status(200).json(
countryCodes.map((countryCode) => {
const {
id,
name,
code,
dialCode,
latitude,
longtitude,
currency,
tips
} = countryCode
return {
id,
name,
code,
dialCode,
latitude,
longtitude,
currency,
tips
}
})
)
} catch (err) {
next(err)
}
}
}