Bỏ qua

Linting Fixes Summary

Date: January 16, 2026 Issue: Pre-commit hook failing due to linting errors

Critical Error Fixed ✅

1. bodyParser Import Error (BLOCKING)

File: apps/payment-service/src/middleware/raw-body.middleware.ts

Error:

'json' not found in imported namespace 'bodyParser'

Fix:

  • Removed body-parser import (not needed)
  • Configured NestJS to preserve raw body via NestFactory.create({ rawBody: true }) in main.ts
  • Simplified middleware to pass-through (raw body handled by NestJS config)

Before:

import * as bodyParser from 'body-parser';
bodyParser.json({ verify: ... })

After:

// No body-parser import needed
// Raw body configured in main.ts

Warnings Fixed ✅

2. Missing Return Types

Files Fixed:

  • apps/payment-service/src/webhooks/stripe-webhook.controller.ts - Added Promise<{ received: boolean }>
  • apps/payment-service/src/webhooks/vnpay-webhook.controller.ts - Added return types to all methods
  • apps/payment-service/src/payments/payments.controller.ts - Added Promise<PaymentTransaction[]>
  • apps/payment-service/src/main.ts - Added Promise<void>
  • apps/payment-service/src/app.module.ts - Added void return type
  • apps/booking-service/src/events/payment.listener.ts - Added Promise<void> to all 4 handlers

3. Missing JSDoc Comments

Files Fixed:

  • apps/payment-service/src/middleware/raw-body.middleware.ts
  • apps/payment-service/src/app.module.ts
  • apps/payment-service/src/webhooks/stripe-webhook.controller.ts
  • apps/payment-service/src/webhooks/vnpay-webhook.controller.ts
  • apps/payment-service/src/migrations/1736960000000-CreatePaymentTables.ts
  • apps/payment-service/src/services/stripe.service.ts
  • apps/payment-service/src/services/vnpay.service.ts
  • apps/payment-service/src/services/payment.service.ts
  • apps/payment-service/src/payments/payments.service.ts
  • apps/payment-service/src/payments/payments.controller.ts
  • apps/booking-service/src/events/payment.listener.ts

4. Code Quality Improvements

Files Fixed:

  • apps/payment-service/src/main.ts:
  • Added void to bootstrap call
  • Added eslint-disable for console.log (acceptable in bootstrap)
  • Fixed import order warning

  • apps/payment-service/src/webhooks/vnpay-webhook.controller.ts:

  • Changed any to Record<string, string> for query/body parameters
  • Added proper return types

Remaining Warnings (Acceptable)

The following warnings remain but are acceptable and won't block commits:

  1. any types in webhook handlers - Required for dynamic webhook payloads from Stripe/VNPay
  2. Unsafe assignments - Necessary for webhook payload processing
  3. Missing JSDoc in test files - Test files are less strict
  4. Console statements - Acceptable in bootstrap/main files

These are within the max-warnings=9999 limit configured in the pre-commit hook.

Test Results

Payment Service Linting

yarn nx lint payment-service --fix
✅ 0 errors, 138 warnings (all acceptable)

Booking Service Linting

yarn nx lint booking-service --fix
✅ 0 errors, 88 warnings (all acceptable)

Files Modified

  1. apps/payment-service/src/middleware/raw-body.middleware.ts
  2. apps/payment-service/src/main.ts
  3. apps/payment-service/src/app.module.ts
  4. apps/payment-service/src/webhooks/stripe-webhook.controller.ts
  5. apps/payment-service/src/webhooks/vnpay-webhook.controller.ts
  6. apps/payment-service/src/payments/payments.controller.ts
  7. apps/payment-service/src/services/payment.service.ts
  8. apps/payment-service/src/services/stripe.service.ts
  9. apps/payment-service/src/services/vnpay.service.ts
  10. apps/payment-service/src/payments/payments.service.ts
  11. apps/payment-service/src/migrations/1736960000000-CreatePaymentTables.ts
  12. apps/booking-service/src/events/payment.listener.ts

Commit Status

Ready to Commit

The critical error has been fixed and all important warnings addressed. The commit should now pass the pre-commit hook.

To commit:

git commit -m "feat: phase 04 - implement payment integration api"

The pre-commit hook will run with max-warnings=9999, so the remaining warnings (mostly about any types in webhook handlers) are acceptable.