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) => { ap.get('/api/gun/otheruser/:publicKey/:type/:path', async (req, res) => {
const allowedTypes = ['once', 'load', 'open'] const allowedTypes = ['once', 'load', 'open']
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER) 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') { if (!publicKey || publicKey === 'undefined') {
res.status(400).json({ res.status(400).json({
errorMessage: 'Invalid publicKey specified' errorMessage: 'Invalid publicKey specified'
@ -3173,16 +3174,23 @@ module.exports = async (
}) })
return return
} }
try {
res.status(200).json({ res.status(200).json({
data: await handleGunFetch({ data: await handleGunFetch({
path, path,
startFromUserGraph: false, startFromUserGraph: false,
type, type,
publicKey, publicKey,
publicKeyForDecryption 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) => { ap.post('/api/lnd/cb/:methodName', (req, res) => {