How to use the ioredis.ReplyError function in ioredis

To help you get started, we’ve selected a few ioredis 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 u-wave / core / src / apis / v1 / authenticate.js View on Github external
.post((req, res) => {
    if (!req.body.email) return res.status(422).json('email not set');

    Authentication.findOne({ 'email': req.body.email })
    .then(() => {
      return randomBytes(64);
    })
    .then(buf => {
      const random = buf.toString('hex');
      // save reset code for a day
      req.uwave.redis.set(`reset:${user.req.body.email}`, random, `NX EXPIRE ${24*60*60}`);
      res.status(200).json(random);
    })
    .catch(redis.ReplyError, e => {
      log(`couldn't set reset link. Err: ${e}`);
      res.status(410).json('could not generate reset code');
    })
    .catch(e => {
      log(`error occured while generating reset code. Err: ${e}`);
      res.status(500).json('internal server error, please try again later');
    });
  })

ioredis

A robust, performance-focused and full-featured Redis client for Node.js.

MIT
Latest version published 7 months ago

Package Health Score

88 / 100
Full package analysis