Merge pull request #344 from shocknet/fix/try-catch

try catch
This commit is contained in:
CapDog 2021-04-21 17:19:03 -04:00 committed by GitHub
commit 45d59e5581

View file

@ -3158,8 +3158,9 @@ module.exports = async (
ap.get('/api/gun/otheruser/:publicKey/:type/:path', async (req, res) => {
const allowedTypes = ['once', 'load', 'open']
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
const { path, publicKey, type } = req.params
const { path /*:rawPath*/, publicKey, type } = req.params
console.log(path)
// const path = decodeURI(rawPath)
if (!publicKey || publicKey === 'undefined') {
res.status(400).json({
errorMessage: 'Invalid publicKey specified'
@ -3173,7 +3174,7 @@ module.exports = async (
})
return
}
try {
res.status(200).json({
data: await handleGunFetch({
path,
@ -3183,6 +3184,13 @@ module.exports = async (
publicKeyForDecryption
})
})
} catch (err) {
res
.status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500)
.json({
errorMessage: err.message
})
}
})
ap.post('/api/lnd/cb/:methodName', (req, res) => {