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)

24 lines (21 loc) 556 B
const { buildErrObject } = require('../../middleware/utils') /** * Checks is password matches * @param {string} password - password * @param {Object} user - user object * @returns {boolean} */ const checkPassword = (password = '', user = {}) => { return new Promise((resolve, reject) => { user.comparePassword(password, (err, isMatch) => { if (err) { return reject(buildErrObject(422, err.message)) } if (!isMatch) { resolve(false) } resolve(true) }) }) } module.exports = { checkPassword }