Skip to content

Commit 4ed3e35

Browse files
committed
fix: remove logger util
1 parent 76ed777 commit 4ed3e35

File tree

8 files changed

+30
-343
lines changed

8 files changed

+30
-343
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thecodeorigin/nuxt",
33
"type": "module",
4-
"version": "2.7.6",
4+
"version": "2.7.7",
55
"publishConfig": {
66
"registry": "https://registry.npmjs.org",
77
"access": "public"

server/api/firebase.post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default defineEventHandler(async (event) => {
4747
}
4848
}
4949
catch (error: any) {
50-
logger.error('[Firebase API] Error sending notification:', error)
50+
console.error('[Firebase API] Error sending notification:', error)
5151

5252
throw parseError(error)
5353
}

server/api/payments/payos/webhook.post.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,38 @@ export default defineEventHandler(async (event) => {
44
try {
55
const body = await readBody(event)
66

7-
logger.log('[PayOS Webhook] Received webhook data:', body)
7+
console.log('[PayOS Webhook] Received webhook data:', body)
88

99
const webhookData = getPayOSAdmin().verifyPaymentWebhookData(body)
1010

1111
if (!webhookData) {
12-
logger.error('[PayOS Webhook] Invalid webhook data received:', body)
12+
console.error('[PayOS Webhook] Invalid webhook data received:', body)
1313
throw createError({
1414
statusCode: 400,
1515
message: ErrorMessage.INVALID_WEBHOOK_BODY,
1616
data: body,
1717
})
1818
}
1919

20-
logger.log('[PayOS Webhook] Verified webhook data:', webhookData)
20+
console.log('[PayOS Webhook] Verified webhook data:', webhookData)
2121
const transactionStatus = webhookData.code === '00' ? PaymentStatus.RESOLVED : PaymentStatus.FAILED
2222

2323
const { updatePaymentStatus, updateProviderTransactionStatus, getProviderTransactionByOrderCode } = usePayment()
2424

2525
const paymentTransactionOfProvider = await getProviderTransactionByOrderCode(String(webhookData.orderCode))
2626

2727
if (!paymentTransactionOfProvider?.payment.order.package) {
28-
logger.warn(`[PayOS Webhook] Transaction not found or invalid: orderCode=${webhookData.orderCode}`)
28+
console.warn(`[PayOS Webhook] Transaction not found or invalid: orderCode=${webhookData.orderCode}`)
2929
return { success: true }
3030
}
3131

32-
logger.log(`[PayOS Webhook] Processing transaction: orderCode=${webhookData.orderCode}, status=${transactionStatus}`)
32+
console.log(`[PayOS Webhook] Processing transaction: orderCode=${webhookData.orderCode}, status=${transactionStatus}`)
3333

3434
const priceDiscount = Number(paymentTransactionOfProvider.payment.order.package.price_discount)
3535
const price = Number(paymentTransactionOfProvider.payment.order.package.price)
3636

3737
if (priceDiscount !== Number(webhookData.amount) && price !== Number(webhookData.amount)) {
38-
logger.error(`[PayOS Webhook] Amount mismatch, transaction [${paymentTransactionOfProvider.id}]: expected=${price}, received=${webhookData.amount}`)
38+
console.error(`[PayOS Webhook] Amount mismatch, transaction [${paymentTransactionOfProvider.id}]: expected=${price}, received=${webhookData.amount}`)
3939

4040
throw createError({
4141
statusCode: 400,
@@ -48,33 +48,33 @@ export default defineEventHandler(async (event) => {
4848

4949
// The userId is already the UUID from our database since we've updated
5050
// our schemas to use UUID references between tables
51-
logger.log(`[PayOS Webhook] Adding credits: userId=${userId}, amount=${creditAmount}`)
51+
console.log(`[PayOS Webhook] Adding credits: userId=${userId}, amount=${creditAmount}`)
5252

5353
await addCreditToUser(userId, creditAmount)
5454

55-
logger.log(`[PayOS Webhook] Credits added successfully: userId=${userId}, amount=${creditAmount}`)
55+
console.log(`[PayOS Webhook] Credits added successfully: userId=${userId}, amount=${creditAmount}`)
5656

5757
if (!paymentTransactionOfProvider?.payment.order.package) {
58-
logger.error(`[PayOS Webhook] No product found for transaction: ${webhookData.orderCode}`)
58+
console.error(`[PayOS Webhook] No product found for transaction: ${webhookData.orderCode}`)
5959
throw createError({
6060
statusCode: 400,
6161
message: 'No product found for this transaction!',
6262
})
6363
}
6464

65-
logger.log(`[PayOS Webhook] Updating transaction ${paymentTransactionOfProvider.id} to status: ${transactionStatus}`)
65+
console.log(`[PayOS Webhook] Updating transaction ${paymentTransactionOfProvider.id} to status: ${transactionStatus}`)
6666

6767
await updateProviderTransactionStatus(paymentTransactionOfProvider.id, transactionStatus, webhookData.transactionDateTime)
6868

6969
await updatePaymentStatus(paymentTransactionOfProvider.payment.id, transactionStatus)
7070

71-
logger.log(`[PayOS Webhook] Transaction updated successfully: id=${paymentTransactionOfProvider.id}, status=${transactionStatus}`)
71+
console.log(`[PayOS Webhook] Transaction updated successfully: id=${paymentTransactionOfProvider.id}, status=${transactionStatus}`)
7272

73-
logger.log('[PayOS Webhook] Webhook processing completed successfully')
73+
console.log('[PayOS Webhook] Webhook processing completed successfully')
7474
return { success: true }
7575
}
7676
catch (error: any) {
77-
logger.error('[PayOS Webhook] Error processing webhook:', error)
77+
console.error('[PayOS Webhook] Error processing webhook:', error)
7878

7979
throw parseError(error)
8080
}

server/api/payments/sepay/webhook.post.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ export default defineEventHandler(async (event) => {
2222
)
2323

2424
if (process.env.SEPAY_WEBHOOK_SIGNING_KEY !== getHeader(event, 'Authorization')?.match(/Apikey (.*)/)?.[1]) {
25-
logger.error('[SePay Webhook] Invalid webhook authentication')
25+
console.error('[SePay Webhook] Invalid webhook authentication')
2626
throw createError({
2727
statusCode: 401,
2828
message: 'Invalid webhook authentication',
2929
})
3030
}
3131

32-
logger.log('[SePay Webhook] Verified webhook data:', body)
32+
console.log('[SePay Webhook] Verified webhook data:', body)
3333

3434
// SePay Webhook always success (if not, it will not call this endpoint anyway)
3535

@@ -41,11 +41,11 @@ export default defineEventHandler(async (event) => {
4141
const paymentTransactionOfProvider = await getProviderTransactionByOrderCode(String(orderCode))
4242

4343
if (!paymentTransactionOfProvider?.payment.order.package) {
44-
logger.warn(`[SePay Webhook] Transaction not found or invalid: code=${orderCode}`)
44+
console.warn(`[SePay Webhook] Transaction not found or invalid: code=${orderCode}`)
4545
return { success: true }
4646
}
4747

48-
logger.log(`[SePay Webhook] Processing transaction: code=${orderCode}, status=${transactionStatus}`)
48+
console.log(`[SePay Webhook] Processing transaction: code=${orderCode}, status=${transactionStatus}`)
4949

5050
const userId = paymentTransactionOfProvider.payment.order.user_id
5151

@@ -61,7 +61,7 @@ export default defineEventHandler(async (event) => {
6161
)
6262

6363
if (price !== Number(body.transferAmount)) {
64-
logger.error(`[SePay Webhook] Amount mismatch, transaction [${paymentTransactionOfProvider.id}]: expected=${price}, received=${body.transferAmount}`)
64+
console.error(`[SePay Webhook] Amount mismatch, transaction [${paymentTransactionOfProvider.id}]: expected=${price}, received=${body.transferAmount}`)
6565

6666
throw createError({
6767
statusCode: 400,
@@ -73,21 +73,21 @@ export default defineEventHandler(async (event) => {
7373

7474
// The userId is already the UUID from our database since we've updated
7575
// our schemas to use UUID references between tables
76-
logger.log(`[SePay Webhook] Adding credits: userId=${userId}, amount=${creditAmount}`)
76+
console.log(`[SePay Webhook] Adding credits: userId=${userId}, amount=${creditAmount}`)
7777

7878
await addCreditToUser(userId, creditAmount)
7979

80-
logger.log(`[SePay Webhook] Credits added successfully: userId=${userId}, amount=${creditAmount}`)
80+
console.log(`[SePay Webhook] Credits added successfully: userId=${userId}, amount=${creditAmount}`)
8181

8282
if (!paymentTransactionOfProvider?.payment.order.package) {
83-
logger.error(`[SePay Webhook] No product found for transaction: ${orderCode}`)
83+
console.error(`[SePay Webhook] No product found for transaction: ${orderCode}`)
8484
throw createError({
8585
statusCode: 400,
8686
message: 'No product found for this transaction!',
8787
})
8888
}
8989

90-
logger.log(`[SePay Webhook] Updating transaction ${paymentTransactionOfProvider.id} to status: ${transactionStatus}`)
90+
console.log(`[SePay Webhook] Updating transaction ${paymentTransactionOfProvider.id} to status: ${transactionStatus}`)
9191

9292
await updateProviderTransactionStatus(paymentTransactionOfProvider.id, transactionStatus, body.transactionDate!)
9393

@@ -103,13 +103,13 @@ export default defineEventHandler(async (event) => {
103103
)
104104
}
105105

106-
logger.log(`[SePay Webhook] Transaction updated successfully: id=${paymentTransactionOfProvider.id}, status=${transactionStatus}`)
106+
console.log(`[SePay Webhook] Transaction updated successfully: id=${paymentTransactionOfProvider.id}, status=${transactionStatus}`)
107107

108-
logger.log('[SePay Webhook] Webhook processing completed successfully')
108+
console.log('[SePay Webhook] Webhook processing completed successfully')
109109
return { success: true }
110110
}
111111
catch (error: any) {
112-
logger.error('[SePay Webhook] Error processing webhook:', error)
112+
console.error('[SePay Webhook] Error processing webhook:', error)
113113

114114
throw parseError(error)
115115
}

server/api/scopes.get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
55
return await getUserScopes()
66
}
77
catch (error: any) {
8-
logger.error('[Scopes API] Error fetching scopes:', error)
8+
console.error('[Scopes API] Error fetching scopes:', error)
99

1010
throw parseError(error)
1111
}

0 commit comments

Comments
 (0)