UNPKG

node-express-mongodb-jwt-rest-api-skeleton

Version:

Node.js express.js MongoDB JWT REST API - This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API)

28 lines (25 loc) 662 B
const ForgotPassword = require('../../../models/forgotPassword') const { itemNotFound } = require('../../../middleware/utils') /** * Checks if a forgot password verification exists * @param {string} id - verification id */ const findForgotPassword = (id = '') => { return new Promise((resolve, reject) => { ForgotPassword.findOne( { verification: id, used: false }, async (err, item) => { try { await itemNotFound(err, item, 'NOT_FOUND_OR_ALREADY_USED') resolve(item) } catch (error) { reject(error) } } ) }) } module.exports = { findForgotPassword }