My question is if is it possible to achieve the following implementation in NodeJS without using any callback or asnyc/await or promises or synchrounous libraries in the caller file?
Caller File:
const isUnique = require("is-unique");
if(!isUnique({email:req.user.email})){
//call is-unique to check if unique, if not unique return 400
return res.status(400).json({"error":"Profile exist"})
}
Callee File:
// is-unique.js
const isUnique = (field) => {
//call an async function countRecordsInDatabase, check the result and return a boolean
const count = countRecordsInDatabaseAsync(field);
return (count <= 0);
}
module.exports = isUnique;
Thanks in advance and hope I have made the question short and sweet. :D