/var/www/p4ela.kz/server/delivery/api/controllers/account
Edit: /var/www/p4ela.kz/server/delivery/api/controllers/account/details.js (919B)
const { NotFound, BadRequest } = require('../../responseModels/errors')
const { isSet, isEmpty } = 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.params }).info()
let t1 = performance.now()
try {
const { uid } = req.params
if (!isSet(uid) || isEmpty(uid))
throw new BadRequest({ code: 1027, lang: req.user?.languageCode })
const account = await db.account.findOne({
where: { uid },
include: [
{
model: db.accountHistory,
order: [['createdAt', 'DESC']],
limit: 3
}
]
})
if (!account) throw new NotFound({ code: 1030, lang: req.user?.languageCode })
const time = performance.now() - t1
return res.status(200).json(account)
} catch (err) {
next(err)
}
}
}