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

View file

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

View file

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