How to use the celebrate.Joi.boolean function in celebrate

To help you get started, we’ve selected a few celebrate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hack4impact-uiuc / life-after-hate / backend / routes / api / users.js View on Github external
success: true
    });
  })
);

// create new user
router.post(
  "/",
  requireAdminStatus,
  celebrate({
    body: Joi.object().keys({
      firstName: Joi.string().required(),
      lastName: Joi.string().required(),
      oauthId: Joi.string().required(),
      propicUrl: Joi.string(),
      isApproved: Joi.boolean().default(false),
      role: Joi.string().required(),
      location: Joi.string().required(),
      email: Joi.string().required()
    })
  }),
  errorWrap(async (req, res) => {
    const data = req.body;
    const newUser = new User({
      firstName: data.firstName,
      lastName: data.lastName,
      oauthId: data.oauthId,
      propicUrl: data.propicUrl,
      role: data.role,
      location: data.location,
      email: data.email
    });
github hack4impact-uiuc / life-after-hate / backend / routes / api / users.js View on Github external
};
    res.status(ret.code).json(ret);
  })
);

// approve user
router.put(
  "/:user_id/approve",
  requireAdminStatus,
  celebrate({
    body: Joi.object().keys({
      firstName: Joi.string(),
      lastName: Joi.string(),
      oauthId: Joi.string(),
      propicUrl: Joi.string(),
      isApproved: Joi.boolean(),
      role: Joi.string(),
      location: Joi.string(),
      email: Joi.string()
    })
  }),
  errorWrap(async (req, res) => {
    const userId = req.params.user_id;

    const user = await User.findByIdAndUpdate(
      userId,
      { $set: { isApproved: true } },
      { new: true }
    );
    const ret = user
      ? {
          code: 200,