Skip to content

[REF] Remove TypeORM, Implement Drizzle Health Indicator #6

Description

@oomokaro1

[REF] Remove TypeORM, Implement Drizzle Health Indicator

Priority: Medium

Difficulty: Medium
Estimated Effort: 1-2 days
Relevant Packages: OrbitStream_backend/
Labels: refactor, enhancement, priority:medium

Requirements

1. Remove TypeORM

  • Remove TypeOrmModule.forRoot() from app.module.ts
  • Remove TypeOrmModule import from app.module.ts
  • Remove @nestjs/typeorm and typeorm from package.json dependencies
  • Verify no other file imports from TypeORM
  • Run npm install to clean up node_modules

2. Drizzle Health Indicator

Create a DrizzleHealthIndicator that implements @nestjs/terminus HealthIndicator interface:

// src/monitoring/drizzle-health.indicator.ts
import { HealthIndicator, HealthIndicatorResult } from '@nestjs/terminus';
import { db } from '../db/index';

export class DrizzleHealthIndicator extends HealthIndicator {
  async pingCheck(key: string): Promise<HealthIndicatorResult> {
    try {
      // Execute a simple query to verify Drizzle connection
      await db.execute(sql`SELECT 1`);
      return this.getStatus(key, true);
    } catch (error) {
      return this.getStatus(key, false, { message: error.message });
    }
  }
}

3. Update Health Controller

  • Replace TypeOrmHealthIndicator with DrizzleHealthIndicator in health.controller.ts
  • Update constructor injection
  • Verify the health endpoint returns correct status

4. Testing

  • Unit test DrizzleHealthIndicator: mock db.execute, test success and failure cases
  • Integration test: verify GET /health returns {"status":"ok"} when DB is connected
  • Integration test: verify GET /health returns {"status":"error"} when DB is unreachable
  • Verify no TypeORM references remain in the codebase

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions