Skip to content

chore: refactor code structure for improved readability and maintenability#4

Merged
erickarugu merged 20 commits into
mainfrom
chore/initial-setup
Dec 4, 2025
Merged

chore: refactor code structure for improved readability and maintenability#4
erickarugu merged 20 commits into
mainfrom
chore/initial-setup

Conversation

@erickarugu

@erickarugu erickarugu commented Dec 3, 2025

Copy link
Copy Markdown
Owner

Description

Type of Change

  • 🚀 New feature (non-breaking change which adds functionality)
  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🔧 Chore (maintenance, dependencies, refactoring)
  • ⚡ Performance improvement
  • 🧪 Test coverage

Related Issue

Closes #

Changes Made

Testing

  • Unit tests added/updated
  • E2E tests added/updated
  • Manual testing performed
  • All existing tests pass

Test Instructions

Database Changes

  • Migration files included
  • Schema changes documented
  • Backwards compatible
  • N/A - No database changes

API Changes

  • New endpoints added
  • Existing endpoints modified
  • Breaking API changes
  • Swagger documentation updated
  • N/A - No API changes

Security Considerations

  • Input validation implemented
  • Authentication/Authorization checks added
  • Sensitive data properly handled
  • No security concerns
  • N/A

Checklist

  • Code follows project style guidelines (ESLint/Prettier)
  • Self-review of code completed
  • Code is well-commented where necessary
  • No console.log statements
  • Changes generate no new warnings/errors
  • Tests added/updated and passing
  • Documentation updated (if needed)
  • Branch naming follows convention (type/description)

Screenshots/Videos

Additional Notes

Deployment Notes

  • Environment variables updated in .env.example
  • No deployment concerns
  • Special deployment steps required (describe below)

Reviewer Notes:

Copilot AI review requested due to automatic review settings December 3, 2025 16:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the codebase to improve readability and maintainability (note: PR title has a typo - "maintenability" should be "maintainability"). The changes add infrastructure for production readiness including health checks, metrics monitoring, error handling, and improved build processes.

Key Changes:

  • Added health check infrastructure with database and optional Redis monitoring using @nestjs/terminus
  • Integrated Prometheus metrics collection via @willsoto/nestjs-prometheus
  • Implemented global HTTP exception filter for standardized error responses
  • Enhanced Docker configuration with OCI labels and health checks
  • Added migration management scripts and lint-staged pre-commit hooks

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
package.json Added new dependencies (terminus, prometheus, ioredis, rimraf, lint-staged), migration scripts, lint-staged configuration, and prebuild script
pnpm-lock.yaml Updated lockfile with new dependencies and their transitive dependencies
libs/shared/src/http/http-exception.filter.ts New global exception filter for standardizing error responses across the application
libs/shared/src/index.ts Export new HTTP exception filter
libs/shared/src/config/index.ts Added optional REDIS_URL environment variable to schema
libs/core/src/prometheus/prometheus.module.ts New module configuring Prometheus metrics with default metrics enabled at /metrics endpoint
libs/core/src/index.ts Export new Prometheus module
libs/core/src/core.module.ts Import and register Prometheus module
apps/anchorpay/src/main.ts Added global exception filter, enabled URI-based versioning, and imported versioning types
apps/anchorpay/src/health/redis-health.indicator.ts New health indicator for Redis connectivity checks
apps/anchorpay/src/health/health.module.ts Added TerminusModule and RedisHealthIndicator provider
apps/anchorpay/src/health/health.controller.ts Refactored to use @nestjs/terminus for database and conditional Redis health checks
Dockerfile Added OCI metadata labels and health check configuration
.husky/pre-commit Added shebang and lint-staged execution
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/shared/src/http/http-exception.filter.ts
Comment thread apps/anchorpay/src/health/redis-health.indicator.ts
Comment thread apps/anchorpay/src/health/redis-health.indicator.ts
Comment thread apps/anchorpay/src/main.ts Outdated
Comment thread apps/anchorpay/src/main.ts Outdated
Comment thread apps/anchorpay/src/health/health.controller.ts
Comment thread package.json Outdated
Comment thread libs/core/src/prometheus/prometheus.module.ts
Comment thread package.json Outdated
Comment thread package.json Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 7 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/core/src/prometheus/prometheus-auth.guard.ts
Comment thread libs/shared/src/http/http-exception.filter.ts Outdated
Comment thread apps/anchorpay/src/health/redis-health.indicator.ts Outdated
Comment thread Dockerfile
Comment thread libs/core/src/prometheus/prometheus.module.ts Outdated
Comment thread package.json
Comment thread libs/core/src/prometheus/prometheus-auth.guard.ts Outdated
erickarugu and others added 3 commits December 4, 2025 11:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 9 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/core/src/prometheus/prometheus-auth.guard.ts
Comment thread apps/anchorpay/src/health/health.controller.ts
Comment thread libs/core/src/prometheus/prometheus.module.ts Outdated
Comment thread libs/core/src/prometheus/prometheus-auth.guard.ts
Comment thread apps/anchorpay/src/health/redis-health.indicator.ts Outdated
Comment thread libs/shared/src/http/http-exception.filter.ts
Comment thread apps/anchorpay/src/health/redis-health.indicator.ts
Comment thread libs/core/src/index.ts
Comment thread libs/core/src/prometheus/prometheus-auth.guard.ts Outdated

Copilot AI commented Dec 4, 2025

Copy link
Copy Markdown

@erickarugu I've opened a new pull request, #6, to work on those changes. Once the pull request is ready, I'll request review from you.

erickarugu and others added 6 commits December 4, 2025 11:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@erickarugu erickarugu merged commit aa1788c into main Dec 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants