From 31e0400472436ce68be493e1dc1b69b13bb2810f Mon Sep 17 00:00:00 2001 From: Mehrshad Date: Wed, 27 Dec 2023 15:13:56 +0330 Subject: [PATCH] fix: apply new logger import syntax --- app.js | 2 +- bot/commands.js | 2 +- bot/messages.ts | 2 +- bot/modules/community/commands.js | 2 +- bot/modules/community/messages.js | 2 +- bot/modules/community/scenes.js | 2 +- bot/modules/dispute/commands.js | 2 +- bot/modules/dispute/messages.js | 2 +- bot/modules/language/commands.js | 2 +- bot/modules/language/messages.js | 2 +- bot/modules/nostr/commands.js | 2 +- bot/modules/nostr/index.js | 2 +- bot/modules/orders/commands.js | 2 +- bot/modules/orders/index.js | 2 +- bot/modules/orders/messages.js | 2 +- bot/modules/orders/scenes.js | 2 +- bot/modules/orders/takeOrder.js | 2 +- bot/ordersActions.js | 2 +- bot/scenes.js | 2 +- bot/start.ts | 2 +- bot/validations.js | 2 +- db_connect.js | 2 +- jobs/calculate_community_earnings.js | 2 +- jobs/cancel_orders.js | 2 +- jobs/communities.js | 2 +- jobs/delete_published_orders.js | 2 +- jobs/node_info.js | 2 +- jobs/pending_payments.ts | 2 +- ln/connect.js | 2 +- ln/hold_invoice.js | 2 +- ln/info.js | 2 +- ln/pay_request.js | 2 +- ln/resubscribe_invoices.js | 2 +- ln/subscribe_invoice.js | 2 +- ln/subscribe_probe.js | 2 +- lnurl/lnurl-pay.js | 2 +- util/index.js | 2 +- 37 files changed, 37 insertions(+), 37 deletions(-) diff --git a/app.js b/app.js index 2fbc6604..177ccd8d 100644 --- a/app.js +++ b/app.js @@ -3,7 +3,7 @@ const { SocksProxyAgent } = require('socks-proxy-agent'); const { start } = require('./bot'); const mongoConnect = require('./db_connect'); const { resubscribeInvoices } = require('./ln'); -const logger = require('./logger'); +const { logger } = require('./logger'); const { delay } = require('./util'); (async () => { diff --git a/bot/commands.js b/bot/commands.js index acfe66e7..175eae1a 100644 --- a/bot/commands.js +++ b/bot/commands.js @@ -19,7 +19,7 @@ const { const ordersActions = require('./ordersActions'); const { resolvLightningAddress } = require('../lnurl/lnurl-pay'); -const logger = require('../logger'); +const { logger } = require('../logger'); const waitPayment = async (ctx, bot, buyer, seller, order, buyerInvoice) => { try { diff --git a/bot/messages.ts b/bot/messages.ts index 8bdf299c..72041899 100644 --- a/bot/messages.ts +++ b/bot/messages.ts @@ -12,7 +12,7 @@ const { decimalRound, getUserAge, } = require('../util'); -const logger = require('../logger'); +const { logger } = require('../logger'); import { MainContext } from './start'; import { UserDocument } from '../models/user' import { IOrder } from '../models/order' diff --git a/bot/modules/community/commands.js b/bot/modules/community/commands.js index 83e29a68..1876914b 100644 --- a/bot/modules/community/commands.js +++ b/bot/modules/community/commands.js @@ -1,6 +1,6 @@ /* eslint-disable no-underscore-dangle */ // @ts-check -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const { showUserCommunitiesMessage } = require('./messages'); const { Community, Order } = require('../../../models'); const { validateParams, validateObjectId } = require('../../validations'); diff --git a/bot/modules/community/messages.js b/bot/modules/community/messages.js index 61b398f9..85d3bfc4 100644 --- a/bot/modules/community/messages.js +++ b/bot/modules/community/messages.js @@ -1,4 +1,4 @@ -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const { Community, PendingPayment } = require('../../../models'); exports.createCommunityWizardStatus = (i18n, state) => { diff --git a/bot/modules/community/scenes.js b/bot/modules/community/scenes.js index 612d2b86..81eb5f6b 100644 --- a/bot/modules/community/scenes.js +++ b/bot/modules/community/scenes.js @@ -1,5 +1,5 @@ const { Scenes } = require('telegraf'); -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const { Community, User, PendingPayment } = require('../../../models'); const { isPendingPayment } = require('../../../ln'); const { isGroupAdmin, itemsFromMessage } = require('../../../util'); diff --git a/bot/modules/dispute/commands.js b/bot/modules/dispute/commands.js index 01ec8a6b..54b8cefd 100644 --- a/bot/modules/dispute/commands.js +++ b/bot/modules/dispute/commands.js @@ -6,7 +6,7 @@ const { } = require('../../validations'); const messages = require('./messages'); const globalMessages = require('../../messages'); -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const dispute = async ctx => { try { diff --git a/bot/modules/dispute/messages.js b/bot/modules/dispute/messages.js index 7999eb5b..40dc36bf 100644 --- a/bot/modules/dispute/messages.js +++ b/bot/modules/dispute/messages.js @@ -1,5 +1,5 @@ const { getDisputeChannel, getDetailedOrder } = require('../../../util'); -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); exports.beginDispute = async (ctx, initiator, order, buyer, seller) => { try { diff --git a/bot/modules/language/commands.js b/bot/modules/language/commands.js index c58e403c..0ce55db1 100644 --- a/bot/modules/language/commands.js +++ b/bot/modules/language/commands.js @@ -1,7 +1,7 @@ const path = require('path'); const fs = require('fs'); const { getLanguageFlag } = require('../../../util'); -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const { showFlagsMessage } = require('./messages'); exports.setlang = async ctx => { diff --git a/bot/modules/language/messages.js b/bot/modules/language/messages.js index a0a10c4b..870abade 100644 --- a/bot/modules/language/messages.js +++ b/bot/modules/language/messages.js @@ -1,4 +1,4 @@ -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); exports.showFlagsMessage = async (ctx, flags, code) => { try { diff --git a/bot/modules/nostr/commands.js b/bot/modules/nostr/commands.js index 0f3d8db7..0861bdf5 100644 --- a/bot/modules/nostr/commands.js +++ b/bot/modules/nostr/commands.js @@ -1,5 +1,5 @@ const Nostr = require('nostr-tools'); -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const Config = require('./config'); exports.info = async ctx => { diff --git a/bot/modules/nostr/index.js b/bot/modules/nostr/index.js index d1fac01b..d3bad273 100644 --- a/bot/modules/nostr/index.js +++ b/bot/modules/nostr/index.js @@ -1,6 +1,6 @@ // @ts-check require('websocket-polyfill'); -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const Config = require('./config'); const { orderCreated } = require('./events'); const Commands = require('./commands'); diff --git a/bot/modules/orders/commands.js b/bot/modules/orders/commands.js index c04b4c82..1e9f4c63 100644 --- a/bot/modules/orders/commands.js +++ b/bot/modules/orders/commands.js @@ -1,5 +1,5 @@ // @ts-check -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const { Community, Order } = require('../../../models'); const { isFloat } = require('../../../util'); const { diff --git a/bot/modules/orders/index.js b/bot/modules/orders/index.js index 42dabe52..bdf75edd 100644 --- a/bot/modules/orders/index.js +++ b/bot/modules/orders/index.js @@ -1,6 +1,6 @@ // @ts-check const { userMiddleware } = require('../../middleware/user'); -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const ordersActions = require('../../ordersActions'); const commands = require('./commands'); diff --git a/bot/modules/orders/messages.js b/bot/modules/orders/messages.js index e113b149..908eb6ec 100644 --- a/bot/modules/orders/messages.js +++ b/bot/modules/orders/messages.js @@ -3,7 +3,7 @@ const { sanitizeMD, getTimeToExpirationOrder, } = require('../../../util'); -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); exports.listOrdersResponse = async (orders, i18n) => { const tasks = orders.map(async order => { diff --git a/bot/modules/orders/scenes.js b/bot/modules/orders/scenes.js index 15c7e0bd..349622c5 100644 --- a/bot/modules/orders/scenes.js +++ b/bot/modules/orders/scenes.js @@ -1,5 +1,5 @@ const { Scenes, Markup } = require('telegraf'); -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const { getCurrency } = require('../../../util'); const ordersActions = require('../../ordersActions'); const { diff --git a/bot/modules/orders/takeOrder.js b/bot/modules/orders/takeOrder.js index 5e73a746..23c47b9d 100644 --- a/bot/modules/orders/takeOrder.js +++ b/bot/modules/orders/takeOrder.js @@ -1,5 +1,5 @@ // @ts-check -const logger = require('../../../logger'); +const { logger } = require('../../../logger'); const { Order } = require('../../../models'); const { deleteOrderFromChannel } = require('../../../util'); const messages = require('../../messages'); diff --git a/bot/ordersActions.js b/bot/ordersActions.js index 28360123..d36ebab5 100644 --- a/bot/ordersActions.js +++ b/bot/ordersActions.js @@ -10,7 +10,7 @@ const { getFee, getUserAge, } = require('../util'); -const logger = require('../logger'); +const { logger } = require('../logger'); const OrderEvents = require('./modules/events/orders'); diff --git a/bot/scenes.js b/bot/scenes.js index a4eb7559..86c1c6ce 100644 --- a/bot/scenes.js +++ b/bot/scenes.js @@ -5,7 +5,7 @@ const { waitPayment, addInvoice, showHoldInvoice } = require('./commands'); const { getCurrency, getUserI18nContext } = require('../util'); const messages = require('./messages'); const { isPendingPayment } = require('../ln'); -const logger = require('../logger'); +const { logger } = require('../logger'); const addInvoiceWizard = new Scenes.WizardScene( 'ADD_INVOICE_WIZARD_SCENE_ID', diff --git a/bot/start.ts b/bot/start.ts index e6f598e8..78869d74 100644 --- a/bot/start.ts +++ b/bot/start.ts @@ -66,7 +66,7 @@ const { deleteCommunity, nodeInfo, } = require('../jobs'); -const logger = require('../logger'); +const { logger } = require('../logger'); export interface MainContext extends Context { match: Array | null; diff --git a/bot/validations.js b/bot/validations.js index a3288bd2..72894533 100644 --- a/bot/validations.js +++ b/bot/validations.js @@ -4,7 +4,7 @@ const messages = require('./messages'); const { Order, User, Community } = require('../models'); const { isIso4217, isDisputeSolver } = require('../util'); const { existLightningAddress } = require('../lnurl/lnurl-pay'); -const logger = require('../logger'); +const { logger } = require('../logger'); // We look in database if the telegram user exists, // if not, it creates a new user diff --git a/db_connect.js b/db_connect.js index e38fbd10..aa441d08 100644 --- a/db_connect.js +++ b/db_connect.js @@ -1,5 +1,5 @@ const mongoose = require('mongoose'); -const logger = require('./logger'); +const { logger } = require('./logger'); // connect to database const credentials = process.env.DB_USER diff --git a/jobs/calculate_community_earnings.js b/jobs/calculate_community_earnings.js index 56151d48..87eb3e28 100644 --- a/jobs/calculate_community_earnings.js +++ b/jobs/calculate_community_earnings.js @@ -1,5 +1,5 @@ const { Order, Community } = require('../models'); -const logger = require('../logger'); +const { logger } = require('../logger'); const calculateEarnings = async () => { try { diff --git a/jobs/cancel_orders.js b/jobs/cancel_orders.js index 00cef019..ff56771f 100644 --- a/jobs/cancel_orders.js +++ b/jobs/cancel_orders.js @@ -2,7 +2,7 @@ const { User, Order } = require('../models'); const { cancelShowHoldInvoice, cancelAddInvoice } = require('../bot/commands'); const messages = require('../bot/messages'); const { getUserI18nContext, holdInvoiceExpirationInSecs } = require('../util'); -const logger = require('../logger'); +const { logger } = require('../logger'); const cancelOrders = async bot => { try { diff --git a/jobs/communities.js b/jobs/communities.js index e9ddb503..4d28409e 100644 --- a/jobs/communities.js +++ b/jobs/communities.js @@ -1,5 +1,5 @@ const { Order, Community } = require('../models'); -const logger = require('../logger'); +const { logger } = require('../logger'); const deleteCommunity = async bot => { try { diff --git a/jobs/delete_published_orders.js b/jobs/delete_published_orders.js index b4e284ae..bec2af2f 100644 --- a/jobs/delete_published_orders.js +++ b/jobs/delete_published_orders.js @@ -1,6 +1,6 @@ const { Order } = require('../models'); const { deleteOrderFromChannel } = require('../util'); -const logger = require('../logger'); +const { logger } = require('../logger'); const deleteOrders = async bot => { try { diff --git a/jobs/node_info.js b/jobs/node_info.js index bad5d904..bd3cd19f 100644 --- a/jobs/node_info.js +++ b/jobs/node_info.js @@ -1,6 +1,6 @@ const { Config } = require('../models'); const { getInfo } = require('../ln'); -const logger = require('../logger'); +const { logger } = require('../logger'); const info = async bot => { try { diff --git a/jobs/pending_payments.ts b/jobs/pending_payments.ts index 80b79135..60e376a5 100644 --- a/jobs/pending_payments.ts +++ b/jobs/pending_payments.ts @@ -2,7 +2,7 @@ const { payRequest, isPendingPayment } = require('../ln'); const { PendingPayment, Order, User, Community } = require('../models'); const messages = require('../bot/messages'); const { getUserI18nContext } = require('../util'); -const logger = require('../logger'); +const { logger } = require('../logger'); import { Telegraf } from 'telegraf'; import { I18nContext } from '@grammyjs/i18n'; import { MainContext } from '../bot/start'; diff --git a/ln/connect.js b/ln/connect.js index 167d5445..473c814d 100644 --- a/ln/connect.js +++ b/ln/connect.js @@ -1,7 +1,7 @@ const fs = require('fs'); const path = require('path'); const lightning = require('lightning'); -const logger = require('../logger'); +const { logger } = require('../logger'); const { authenticatedLndGrpc } = lightning; diff --git a/ln/hold_invoice.js b/ln/hold_invoice.js index 1a36c39c..493e3fef 100644 --- a/ln/hold_invoice.js +++ b/ln/hold_invoice.js @@ -1,7 +1,7 @@ const { createHash, randomBytes } = require('crypto'); const lightning = require('lightning'); const lnd = require('./connect'); -const logger = require('../logger'); +const { logger } = require('../logger'); const createHoldInvoice = async ({ description, amount }) => { try { diff --git a/ln/info.js b/ln/info.js index da731135..df2ebe5c 100644 --- a/ln/info.js +++ b/ln/info.js @@ -1,6 +1,6 @@ const lightning = require('lightning'); const lnd = require('./connect'); -const logger = require('../logger'); +const { logger } = require('../logger'); const getInfo = async () => { try { diff --git a/ln/pay_request.js b/ln/pay_request.js index 59fe6d38..df0b00f6 100644 --- a/ln/pay_request.js +++ b/ln/pay_request.js @@ -8,7 +8,7 @@ const { User, PendingPayment } = require('../models'); const lnd = require('./connect'); const { handleReputationItems, getUserI18nContext } = require('../util'); const messages = require('../bot/messages'); -const logger = require('../logger'); +const { logger } = require('../logger'); const payRequest = async ({ request, amount }) => { try { diff --git a/ln/resubscribe_invoices.js b/ln/resubscribe_invoices.js index 21517520..bf39231b 100644 --- a/ln/resubscribe_invoices.js +++ b/ln/resubscribe_invoices.js @@ -2,7 +2,7 @@ const { getInvoices } = require('lightning'); const lnd = require('./connect'); const { subscribeInvoice } = require('./subscribe_invoice'); const { Order } = require('../models'); -const logger = require('../logger'); +const { logger } = require('../logger'); const resubscribeInvoices = async bot => { try { diff --git a/ln/subscribe_invoice.js b/ln/subscribe_invoice.js index a214a5ed..21302cec 100644 --- a/ln/subscribe_invoice.js +++ b/ln/subscribe_invoice.js @@ -5,7 +5,7 @@ const lnd = require('./connect'); const messages = require('../bot/messages'); const ordersActions = require('../bot/ordersActions'); const { getUserI18nContext, getEmojiRate, decimalRound } = require('../util'); -const logger = require('../logger'); +const { logger } = require('../logger'); const subscribeInvoice = async (bot, id, resub) => { try { diff --git a/ln/subscribe_probe.js b/ln/subscribe_probe.js index 3bdc8fe7..4dc798bb 100644 --- a/ln/subscribe_probe.js +++ b/ln/subscribe_probe.js @@ -1,6 +1,6 @@ const { subscribeToProbeForRoute } = require('lightning'); const lnd = require('./connect'); -const logger = require('../logger'); +const { logger } = require('../logger'); const subscribeProbe = async (destination, tokens) => { try { diff --git a/lnurl/lnurl-pay.js b/lnurl/lnurl-pay.js index fdfe50c9..e684a2d6 100644 --- a/lnurl/lnurl-pay.js +++ b/lnurl/lnurl-pay.js @@ -1,5 +1,5 @@ const axios = require('axios').default; -const logger = require('../logger'); +const { logger } = require('../logger'); // { // pr: String, // bech32-serialized lightning invoice diff --git a/util/index.js b/util/index.js index 8cb13f63..819d053f 100644 --- a/util/index.js +++ b/util/index.js @@ -3,7 +3,7 @@ const { I18n } = require('@grammyjs/i18n'); const currencies = require('./fiat.json'); const languages = require('./languages.json'); const { Order, Community } = require('../models'); -const logger = require('../logger'); +const { logger } = require('../logger'); // ISO 4217, all ISO currency codes are 3 letters but users can trade shitcoins const isIso4217 = code => {