Fix weather module DI (MeshService export + value import) and pass WEATHER_CRON through compose (#25)
CI / build + unit (push) Successful in 31s

This commit was merged in pull request #25.
This commit is contained in:
2026-09-25 10:01:38 +02:00
parent 261f7ed18c
commit 5e03546f40
6 changed files with 27 additions and 2 deletions
+1
View File
@@ -23,5 +23,6 @@ function openMessageDb(): DatabaseSync {
useFactory: () => new MeshService(openMessageDb()),
},
],
exports: [MeshService],
})
export class MeshModule {}
+17
View File
@@ -0,0 +1,17 @@
import { Test } from '@nestjs/testing';
import { describe, expect, it } from 'vitest';
import { MeshService } from '../mesh/mesh.service.js';
import { WeatherModule } from './weather.module.js';
import { WeatherService } from './weather.service.js';
describe('DI wiring (module graph)', () => {
// compile() instantiates providers but does not run lifecycle hooks, so no TCP connection is opened.
it('resolves WeatherService with MeshService provided by MeshModule', async () => {
process.env.MESH_DB_PATH = ':memory:'; // keep openMessageDb from touching the repo's ./data
const moduleRef = await Test.createTestingModule({
imports: [WeatherModule],
}).compile();
expect(moduleRef.get(WeatherService)).toBeInstanceOf(WeatherService);
expect(moduleRef.get(MeshService)).toBeInstanceOf(MeshService);
});
});
+1 -1
View File
@@ -1,7 +1,7 @@
import { Injectable, Logger } from '@nestjs/common';
import { Cron } from '@nestjs/schedule';
import { BROADCAST_ADDR } from '../mesh/codec.js';
import type { MeshService } from '../mesh/mesh.service.js';
import { MeshService } from '../mesh/mesh.service.js';
/** Open-Meteo `current` block fields we use (free API, no key). */
export interface CurrentWeather {