Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.

Commit 0706c36

Browse files
committed
chore: debug logs
1 parent 244fcb1 commit 0706c36

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

apps/api/.eslintrc.cjs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,27 @@ module.exports = {
4949
'no-var': 'error',
5050
'prefer-const': 'error',
5151
'prefer-arrow-callback': 'error',
52-
52+
5353
'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
54-
54+
5555
'sonarjs/no-duplicate-string': 'off',
5656
'sonarjs/cognitive-complexity': 'off',
5757
'sonarjs/no-identical-functions': 'off',
58-
58+
5959
'import/first': 'error',
6060
'import/newline-after-import': 'error',
6161
'import/no-duplicates': 'error',
6262
'import/order': [
6363
'error',
6464
{
65-
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
65+
groups: [
66+
'builtin',
67+
'external',
68+
'internal',
69+
'parent',
70+
'sibling',
71+
'index',
72+
],
6673
alphabetize: {
6774
order: 'asc',
6875
caseInsensitive: true,
@@ -80,7 +87,7 @@ module.exports = {
8087
],
8188
},
8289
],
83-
90+
8491
'no-autofix/jsdoc/require-jsdoc': 'off',
8592

8693
'prefer-arrow/prefer-arrow-functions': [
@@ -94,6 +101,7 @@ module.exports = {
94101
},
95102
settings: {
96103
'import/core-modules': [
104+
'node:perf_hooks',
97105
'node:process',
98106
'node:async_hooks',
99107
'node:console',
@@ -115,9 +123,7 @@ module.exports = {
115123
],
116124
'import/resolver': {
117125
alias: {
118-
map: [
119-
['#src', './src'],
120-
],
126+
map: [['#src', './src']],
121127
extensions: ['.js', '.json'],
122128
},
123129
},

apps/api/src/routes/auth/get.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { performance } from 'node:perf_hooks'
2+
13
import LNMarketsAPI from '#src/classes/lnmarkets-api.js'
24

35
export default async (req, res, next) => {
@@ -6,8 +8,11 @@ export default async (req, res, next) => {
68

79
parts.shift()
810

11+
const start = performance.now()
912
const { token } = await LNMarketsAPI.authenticate({ withJWT: true })
13+
const afterAuth = performance.now()
1014

15+
console.log({ auth: `${(afterAuth - start).toFixed(6)} ms` })
1116
res.json({ hostname: parts.join('.'), token })
1217
} catch (error) {
1318
next(error)

apps/api/src/routes/user/deposit/post.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { performance } from 'node:perf_hooks'
2+
13
import LND from '#src/classes/lnd.js'
24
import LNMarketsAPI from '#src/classes/lnmarkets-api.js'
35
import HttpError from '#src/helpers/errors.js'
@@ -6,11 +8,12 @@ export default async (req, res, next) => {
68
try {
79
const { amount } = req.body
810

11+
const start = performance.now()
912
const { depositId: id, paymentRequest: request } =
1013
await LNMarketsAPI.deposit({ amount })
11-
14+
const afterApiCall = performance.now()
1215
const { tokens } = await LND.decodePaymentRequest({ request })
13-
16+
const afterDecodePayment = performance.now()
1417
if (amount !== tokens) {
1518
throw new HttpError(
1619
400,
@@ -20,7 +23,13 @@ export default async (req, res, next) => {
2023
}
2124

2225
const { secret } = await LND.pay({ request, max_paths: 4 })
26+
const afterPay = performance.now()
2327

28+
console.log({
29+
request: `${(afterApiCall - start).toFixed(6)} ms`,
30+
decode: `${(afterDecodePayment - afterApiCall).toFixed(6)} ms`,
31+
pay: `${(afterPay - afterDecodePayment).toFixed(6)} ms`,
32+
})
2433
res.json({ secret, id })
2534
} catch (error) {
2635
if (Array.isArray(error)) {

apps/api/src/routes/user/withdraw/post.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1+
import { performance } from 'node:perf_hooks'
2+
13
import LND from '#src/classes/lnd.js'
24
import LNMarketsAPI from '#src/classes/lnmarkets-api.js'
35

46
export default async (req, res, next) => {
57
try {
68
const { amount } = req.body
7-
9+
const start = performance.now()
810
const { request: invoice } = await LND.createInvoice({
911
description: 'LN Markets Withdraw',
1012
tokens: amount,
1113
})
12-
14+
const afterInvoice = performance.now()
1315
const {
1416
paymentsecret: secret,
1517
paymenthash: payment,
1618
id,
1719
fee,
1820
} = await LNMarketsAPI.withdraw({ amount, invoice })
19-
21+
const afterWithdraw = performance.now()
22+
console.log({
23+
invoice: `${(afterInvoice - start).toFixed(6)} ms`,
24+
pay: `${(afterWithdraw - afterInvoice).toFixed(6)} ms`,
25+
})
2026
res.json({ secret, id, payment, fee })
2127
} catch (error) {
2228
next(error)

0 commit comments

Comments
 (0)