commit
5df46f085c
1 changed files with 56 additions and 12 deletions
|
|
@ -3116,53 +3116,97 @@ module.exports = async (
|
||||||
ap.get('/api/gun/once/:path', async (req, res) => {
|
ap.get('/api/gun/once/:path', async (req, res) => {
|
||||||
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
||||||
const { path } = req.params
|
const { path } = req.params
|
||||||
res.status(200).json({
|
try {
|
||||||
data: await handleGunFetch({
|
const data = await handleGunFetch({
|
||||||
path,
|
path,
|
||||||
startFromUserGraph: false,
|
startFromUserGraph: false,
|
||||||
type: 'once',
|
type: 'once',
|
||||||
publicKeyForDecryption
|
publicKeyForDecryption
|
||||||
})
|
})
|
||||||
})
|
res.status(200).json({
|
||||||
|
data
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
logger.error('error in rpc once')
|
||||||
|
logger.error(err)
|
||||||
|
res
|
||||||
|
.status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500)
|
||||||
|
.json({
|
||||||
|
errorMessage: err.message
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ap.get('/api/gun/load/:path', async (req, res) => {
|
ap.get('/api/gun/load/:path', async (req, res) => {
|
||||||
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
||||||
const { path } = req.params
|
const { path } = req.params
|
||||||
res.status(200).json({
|
try {
|
||||||
data: await handleGunFetch({
|
const data = await handleGunFetch({
|
||||||
path,
|
path,
|
||||||
startFromUserGraph: false,
|
startFromUserGraph: false,
|
||||||
type: 'load',
|
type: 'load',
|
||||||
publicKeyForDecryption
|
publicKeyForDecryption
|
||||||
})
|
})
|
||||||
})
|
res.status(200).json({
|
||||||
|
data
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
logger.error('error in rpc load')
|
||||||
|
logger.error(err)
|
||||||
|
res
|
||||||
|
.status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500)
|
||||||
|
.json({
|
||||||
|
errorMessage: err.message
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ap.get('/api/gun/user/once/:path', async (req, res) => {
|
ap.get('/api/gun/user/once/:path', async (req, res) => {
|
||||||
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
||||||
const { path } = req.params
|
const { path } = req.params
|
||||||
res.status(200).json({
|
try {
|
||||||
data: await handleGunFetch({
|
const data = await handleGunFetch({
|
||||||
path,
|
path,
|
||||||
startFromUserGraph: true,
|
startFromUserGraph: true,
|
||||||
type: 'once',
|
type: 'once',
|
||||||
publicKeyForDecryption
|
publicKeyForDecryption
|
||||||
})
|
})
|
||||||
})
|
res.status(200).json({
|
||||||
|
data
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
logger.error('error in rpc once user')
|
||||||
|
logger.error(err)
|
||||||
|
res
|
||||||
|
.status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500)
|
||||||
|
.json({
|
||||||
|
errorMessage: err.message
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ap.get('/api/gun/user/load/:path', async (req, res) => {
|
ap.get('/api/gun/user/load/:path', async (req, res) => {
|
||||||
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
|
||||||
const { path } = req.params
|
const { path } = req.params
|
||||||
res.status(200).json({
|
try {
|
||||||
data: await handleGunFetch({
|
const data = await handleGunFetch({
|
||||||
path,
|
path,
|
||||||
startFromUserGraph: true,
|
startFromUserGraph: true,
|
||||||
type: 'load',
|
type: 'load',
|
||||||
publicKeyForDecryption
|
publicKeyForDecryption
|
||||||
})
|
})
|
||||||
})
|
res.status(200).json({
|
||||||
|
data
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
logger.error('error in rpc load user')
|
||||||
|
logger.error(err)
|
||||||
|
res
|
||||||
|
.status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500)
|
||||||
|
.json({
|
||||||
|
errorMessage: err.message
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ap.get('/api/gun/otheruser/:publicKey/:type/:path', async (req, res) => {
|
ap.get('/api/gun/otheruser/:publicKey/:type/:path', async (req, res) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue