mostly logs

This commit is contained in:
hatim boufnichel 2021-07-20 20:03:13 +02:00
parent 265e006797
commit c67677ede7
4 changed files with 13 additions and 34 deletions

View file

@ -110,19 +110,12 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
ordersProcessed.add(orderID)
logger.info(
`onOrders() -> processing order: ${orderID} -- ${JSON.stringify(
order
)} -- addr: ${addr}`
)
const alreadyAnswered = await getUser()
.get(Key.ORDER_TO_RESPONSE)
.get(orderID)
.then()
if (alreadyAnswered) {
logger.info('this order is already answered, quitting')
return
}
@ -209,10 +202,6 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
private: true
}
logger.info(
`onOrders() -> Will now create an invoice : ${JSON.stringify(invoiceReq)}`
)
const invoice = await _addInvoice(invoiceReq)
logger.info(

View file

@ -128,8 +128,7 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
return resolvedValue
}
} catch (e) {
logger.error(e)
logger.info(JSON.stringify(e))
console.log(e)
if (e.message === Constants.ErrorCode.NOT_AUTH) {
throw e
}

View file

@ -246,7 +246,9 @@ const startSocket = socket => {
if (isAuthenticated()) {
socket.onAny(() => {
GunActions.setLastSeenApp()
GunActions.setLastSeenApp().catch(e =>
console.log('error setting last seen app', e)
)
})
}

View file

@ -74,11 +74,9 @@ module.exports = async (
}
const checkHealth = async () => {
logger.info('Getting service status...')
let LNDStatus = {}
try {
const serviceStatus = await getAvailableService()
logger.info('Received status:', serviceStatus)
LNDStatus = serviceStatus
} catch (e) {
LNDStatus = {
@ -88,7 +86,6 @@ module.exports = async (
}
try {
logger.info('Getting API status...')
const APIHealth = await Http.get(
`${usetls ? 'https' : 'http'}://localhost:${serverPort}/ping`
)
@ -97,7 +94,6 @@ module.exports = async (
responseTime: APIHealth.headers['x-response-time'],
success: true
}
logger.info('Received API status!', APIStatus)
return {
LNDStatus,
APIStatus,
@ -223,7 +219,6 @@ module.exports = async (
app.use((req, res, next) => {
const legacyDeviceId = req.headers['x-shockwallet-device-id']
const deviceId = req.headers['encryption-device-id']
logger.debug('Decrypting route...')
try {
if (
nonEncryptedRoutes.includes(req.path) ||
@ -308,21 +303,12 @@ module.exports = async (
app.use(async (req, res, next) => {
const legacyDeviceId = req.headers['x-shockwallet-device-id']
const deviceId = req.headers['encryption-device-id']
logger.info('Decrypting route...')
try {
if (
nonEncryptedRoutes.includes(req.path) ||
process.env.DISABLE_SHOCK_ENCRYPTION === 'true' ||
(legacyDeviceId && !deviceId)
) {
logger.info(
'Unprotected route detected! ' +
req.path +
' Legacy ID:' +
legacyDeviceId +
' Device ID:' +
deviceId
)
return next()
}
@ -371,7 +357,6 @@ module.exports = async (
})
app.use(async (req, res, next) => {
logger.info(`Route: ${req.path}`)
if (unprotectedRoutes[req.method][req.path]) {
next()
} else {
@ -502,7 +487,7 @@ module.exports = async (
*/
app.get('/healthz', async (req, res) => {
const health = await checkHealth()
logger.info('Healthz response:', health)
logger.info('Healthz response:', health.APIStatus.success)
res.json(health)
})
@ -1112,7 +1097,6 @@ module.exports = async (
res.json({ errorMessage: 'LND is down' })
}
}
logger.info('GetInfo:', response)
if (!response.uris || response.uris.length === 0) {
if (config.lndAddress) {
response.uris = [response.identity_pubkey + '@' + config.lndAddress]
@ -3163,6 +3147,7 @@ module.exports = async (
ap.get('/api/gun/once/:path', async (req, res) => {
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
const { path } = req.params
logger.info(`gun ONCE: ${path}`)
try {
const data = await handleGunFetch({
path,
@ -3189,6 +3174,7 @@ module.exports = async (
ap.get('/api/gun/load/:path', async (req, res) => {
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
const { path } = req.params
logger.info(`gun LOAD: ${path}`)
try {
const data = await handleGunFetch({
path,
@ -3215,6 +3201,7 @@ module.exports = async (
ap.get('/api/gun/user/once/:path', async (req, res) => {
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
const { path } = req.params
logger.info(`gun otheruser ONCE: ${path}`)
try {
const data = await handleGunFetch({
path,
@ -3241,6 +3228,7 @@ module.exports = async (
ap.get('/api/gun/user/load/:path', async (req, res) => {
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
const { path } = req.params
logger.info(`gun otheruser LOAD: ${path}`)
try {
const data = await handleGunFetch({
path,
@ -3268,7 +3256,7 @@ module.exports = async (
const allowedTypes = ['once', 'load', 'open']
const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER)
const { path /*:rawPath*/, publicKey, type } = req.params
console.log(path)
logger.info(`gun otheruser ${type}: ${path}`)
// const path = decodeURI(rawPath)
if (!publicKey || publicKey === 'undefined') {
res.status(400).json({
@ -3308,6 +3296,7 @@ module.exports = async (
try {
const { lightning } = LightningServices.services
const { methodName } = req.params
logger.info(`lnd RPC: ${methodName}`)
const args = req.body
lightning[methodName](args, (err, lres) => {
@ -3337,7 +3326,7 @@ module.exports = async (
ap.post('/api/gun/put', async (req, res) => {
try {
const { path, value } = req.body
logger.info(`gun PUT: ${path}`)
await GunWriteRPC.put(path, value)
res.status(200).json({
@ -3357,7 +3346,7 @@ module.exports = async (
ap.post('/api/gun/set', async (req, res) => {
try {
const { path, value } = req.body
logger.info(`gun PUT: ${path}`)
const id = await GunWriteRPC.set(path, value)
res.status(200).json({