mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 12:19:40 +02:00
Introduces a new shared package containing transport-agnostic business logic services for Matrix bots and the Gateway. This enables: - Individual bots to import shared services - A unified Gateway bot to combine all features - Code reuse without duplication Services included: - TodoService: Task management with projects, priorities, dates - CalendarService: Events, calendars, reminders - AiService: Ollama LLM integration, chat sessions, vision - ClockService: Timers, alarms, world clocks (API client) - Placeholder modules for Nutrition, Quotes, Stats, Docs Key features: - Pluggable storage providers (file-based, in-memory, custom) - German natural language input parsing - NestJS module system with dependency injection - Fully testable in isolation https://claude.ai/code/session_015bwcqVRiFmSydYTjvDJGTc
45 lines
1 KiB
TypeScript
45 lines
1 KiB
TypeScript
import { Module, DynamicModule } from '@nestjs/common';
|
|
import { ClockService } from './clock.service';
|
|
import { ClockServiceConfig } from './types';
|
|
|
|
export interface ClockModuleOptions extends Partial<ClockServiceConfig> {}
|
|
|
|
@Module({})
|
|
export class ClockModule {
|
|
/**
|
|
* Register with default configuration (uses environment variables)
|
|
*/
|
|
static register(options?: ClockModuleOptions): DynamicModule {
|
|
return {
|
|
module: ClockModule,
|
|
providers: [
|
|
{
|
|
provide: 'CLOCK_SERVICE_CONFIG',
|
|
useValue: options ?? {},
|
|
},
|
|
{
|
|
provide: ClockService,
|
|
useFactory: (config: Partial<ClockServiceConfig>) => new ClockService(config),
|
|
inject: ['CLOCK_SERVICE_CONFIG'],
|
|
},
|
|
],
|
|
exports: [ClockService],
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Register with explicit configuration
|
|
*/
|
|
static forRoot(config: ClockServiceConfig): DynamicModule {
|
|
return {
|
|
module: ClockModule,
|
|
providers: [
|
|
{
|
|
provide: ClockService,
|
|
useFactory: () => new ClockService(config),
|
|
},
|
|
],
|
|
exports: [ClockService],
|
|
};
|
|
}
|
|
}
|