Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.2 KB
Raw Blame
import { SqliteMaintenance } from '../../db/engine/sqlite/sqlite-maintenance';
import { MaintenanceRepository } from '../../db/repositories/MaintenanceRepository';
import { EntityManager } from '@mikro-orm/core';
import { Module } from '@nestjs/common';

/**
 * Provides `MaintenanceRepository`, the home of the few whole-database
 * statements no entity can express (the readiness ping, the plugin-table
 * erasure), and `SqliteMaintenance`, the SQLite file's own (the WAL
 * checkpoint, `VACUUM INTO`).
 *
 * Factories over the context-resolving global `EntityManager`, the same one
 * Nest injects into every service, so each resolves the request or
 * transaction fork that is active when a method runs. The class itself stays
 * free of Nest, like every other file under `db/`.
 */
@Module({
  providers: [
    {
      provide: MaintenanceRepository,
      useFactory: (em: EntityManager) => new MaintenanceRepository(em),
      inject: [EntityManager],
    },
    {
      provide: SqliteMaintenance,
      useFactory: (em: EntityManager) => new SqliteMaintenance(em),
      inject: [EntityManager],
    },
  ],
  exports: [MaintenanceRepository, SqliteMaintenance],
})
export class MaintenanceModule {}