/** * Load entity and append it to req * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @param {String} id - id of entity */ const load = (req, res, next, id) => BusinessUser.get(id) .then((doc) => { req[EFIELD] = doc; // eslint-disable-line no-param-reassign debug('LOAD entity %O', doc); return next(); }) .catch(e => next(e))
/** * Update entity by id * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @property {string} req.body.username - The username of user. */ const update = async (req, res, next) => { try { const doc = req[EFIELD]; await doc.update(req.body, { new: true }); req[EFIELD] = await User.get(doc.id); log.info('entity updated %s', doc.id); return next(); } catch (err) { return next(err); } }
// await storageCtrl.addImagesReferences(savedDoc._doc, possibleImageUrlsFields); /** * Update entity by id * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @property {string} req.body.name - The name of category * @property {string} req.body.description - The description of category */ const update = async (req, res, next) => { try { const doc = req[EFIELD]; await doc.update(req.body, { new: true }); await helpers.storage.updateReferencesToImages(doc._doc, req.body, possibleImageUrlsFields); req[EFIELD] = await Business.get(doc.id); log.info('entity updated %s', doc.id); return next(); } catch (err) { return next(err); } }
/** * Update entity by id * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @property {string} req.body.name - The name of category * @property {string} req.body.description - The description of category */ const update = async (req, res, next) => { try { const doc = req[EFIELD]; await doc.update(req.body, { new: true }); log.info('entity updated %s', doc.id); req[EFIELD] = await Offer.get(doc.id); await helpers.storage.updateReferencesToImages(doc._doc, req.body, possibleImageUrlsFields); if (req.body.locations) { await OfferLocation.updateByOffer(req[EFIELD]); } return next(); } catch (err) { return next(err); } }
/** * Update entity by id * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @property {string} req.body.username - The username of businessUser. */ const update = async (req, res, next) => { try { const doc = req[EFIELD]; await doc.update(req.body, { new: true }); req[EFIELD] = await BusinessUser.get(doc.id); log.info('entity updated %s', doc); return next(); } catch (err) { return next(err); } }
/** * Load entity and append it to req * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @param {String} id - id of entity */ const load = (req, res, next, id) => Category.get(id) .then((doc) => { req[EFIELD] = doc; // eslint-disable-line no-param-reassign debug('LOAD entity %O', doc); return next(); }) .catch(e => next(e))
/** * Load entity and append it to req * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @param {String} id - id of entity */ const load = (req, res, next, id) => Offer.get(id) .then((doc) => { req[EFIELD] = doc; // eslint-disable-line no-param-reassign debug('LOAD entity %O', doc); return next(); }) .catch(e => next(e))
/** * Load entity and append it to req * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @param {String} id - id of entity */ const load = (req, res, next, id) => Business.get(id) .then((doc) => { req[EFIELD] = doc; // eslint-disable-line no-param-reassign debug('LOAD entity %O', doc); return next(); }) .catch(e => next(e))
/** * Load entity and append it to req * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @param {String} id - id of entity */ const load = (req, res, next, id) => User.get(id) .then((doc) => { req[EFIELD] = doc; // eslint-disable-line no-param-reassign debug('LOAD entity %O', doc); return next(); }) .catch(e => next(e))
/** * Update user's email * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @property {string} req.body.email - The email of user. */ const updateEmail = async (req, res, next) => { try { const doc = req[EFIELD]; await doc.update(req.body, { new: true }); req[EFIELD] = await BusinessUser.get(doc.id); log.info('entity email updated %s', doc.id); return next(); } catch (err) { return next(err); } }
/** * Update user's email * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @property {string} req.body.email - The email of user. */ const updateEmail = async (req, res, next) => { try { const doc = req[EFIELD]; await doc.update(req.body, { new: true }); req[EFIELD] = await User.get(doc.id); log.info('entity email updated %s', doc.id); return next(); } catch (err) { return next(err); } }
/** * Update entity by id * @param {Express.Request} req request object * @param {Express.Response} res response object * @param {Express.Next} next next middleware * @property {string} req.body.name - The name of category * @property {string} req.body.description - The description of category */ const update = async (req, res, next) => { try { const doc = req[EFIELD]; await doc.update(req.body, { new: true }); req[EFIELD] = await Category.get(doc.id); log.info('entity updated %s', doc.id); return next(); } catch (err) { return next(err); } }