user to last request sent dev endpoint
This commit is contained in:
parent
89b1263e80
commit
3c52eb26e3
1 changed files with 29 additions and 0 deletions
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue