user to last request sent dev endpoint

This commit is contained in:
Daniel Lugo 2020-07-24 12:44:21 -04:00
parent 89b1263e80
commit 3c52eb26e3

View file

@ -2355,6 +2355,35 @@ module.exports = async (
})
}
})
ap.get(`/api/gun/dev/userToLastReqSent`, async (req, res) => {
try {
const {tryAndWait} = require('../services/gunDB/contact-api/utils')
const data = await tryAndWait((_, u) =>
new Promise((res) => u.get(Key.USER_TO_LAST_REQUEST_SENT).load(res))
, v => {
if (typeof v !== 'object') {
return true
}
if (v === null) {
return true
}
// load sometimes returns an empty set on the first try
return size(v) === 0
})
return res.status(200).json({
data
})
} catch (err) {
return res.status(500).json({
errorMessage: err.message
})
}
})
/**
* Return app so that it can be used by express.
*/