/
var
/
www
/
greso.tech
/
server
/
nsm
/
controllers
/
company
/
valuation
/
/var/www/greso.tech/server/nsm/controllers/company/valuation
mkdir
upload
Name
Size
Mode
Actions
create.js
946
0644
edit
dl
rm
delete.js
856
0644
edit
dl
rm
details.js
473
0644
edit
dl
rm
edit.js
1044
0644
edit
dl
rm
list.js
1103
0644
edit
dl
rm
Edit:
/var/www/greso.tech/server/nsm/controllers/company/valuation/edit.js
(1044B)
module.exports = function ({ db, logger }) { const { NotFound, BadRequest } = require('../../../responseModels/errors') const { isSet, isEmail, isPhone, isEmpty, minLength, isNumber } = require('../../../utils/validator.util') return async (req, res, next) => { logger.child({ path: req.path, request: req.query }).info() let t1 = performance.now() try { const { id, json } = req.body if (!isSet(id) || isEmpty(id)) { throw new BadRequest({ code: 400, lang: req.user?.languageCode }) } if (!isSet(json) || isEmpty(json) || !minLength(json, 1)) { throw new BadRequest({ code: 2005, lang: req.user?.languageCode }) } const valuation = await db.valuations.findOne({ where: { id: id } }) if (!valuation) { throw new NotFound({ lang: req.user?.languageCode }) } valuation.json = json await valuation.save() const time = performance.now() - t1 return res.status(200).json({ status: 'success', id: valuation.id, time }) } catch (err) { next(err) } } }
Save
cmd:
run