38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { Controller, Get, Param, Post } from '@nestjs/common';
|
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { CadenceTimerService } from './cadence-timer.service';
|
|
import type {
|
|
CadencePreset,
|
|
CadenceTimerStatus,
|
|
CadenceSchedule,
|
|
} from '@life-platform/shared';
|
|
|
|
@ApiTags('Cadence Timers')
|
|
@Controller('scheduling/cadence-timers')
|
|
export class CadenceTimerController {
|
|
constructor(private readonly cadenceTimerService: CadenceTimerService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List all available cadence timers' })
|
|
listPresets(): Promise<CadencePreset[]> {
|
|
return this.cadenceTimerService.listPresets();
|
|
}
|
|
|
|
@Get(':slug/status')
|
|
@ApiOperation({ summary: 'Get current status of a cadence timer (cooldown remaining, last action, etc.)' })
|
|
getStatus(@Param('slug') slug: string): Promise<CadenceTimerStatus> {
|
|
return this.cadenceTimerService.getStatus(slug);
|
|
}
|
|
|
|
@Get(':slug/schedule')
|
|
@ApiOperation({ summary: 'Get optimized day schedule for a cadence timer based on bedtime' })
|
|
getSchedule(@Param('slug') slug: string): Promise<CadenceSchedule> {
|
|
return this.cadenceTimerService.getSchedule(slug);
|
|
}
|
|
|
|
@Post(':slug/checkin')
|
|
@ApiOperation({ summary: 'Log a cadence check-in — dismisses previous reminder and creates a new one at cooldown expiry' })
|
|
checkin(@Param('slug') slug: string): Promise<CadenceTimerStatus> {
|
|
return this.cadenceTimerService.checkin(slug);
|
|
}
|
|
}
|