Files
hearth/package/routine-server/README.md
T
yukkop 60d2e5d80f
runner nix smoke / nix label and flake smoke (push) Canceled after 0s
encryption
2026-10-15 00:40:41 +00:00

78 lines
2.2 KiB
Markdown

# routine-server
Small PostgreSQL-backed HTTP service for one-off tasks and daily, weekly, or
monthly routine tasks. The server generates future task occurrences and can
send due reminders through the Telegram Bot API.
The server stores an obligatory public title and an optional client-encrypted
payload. It never receives an age identity and Telegram always uses the public
title.
## Configuration
| Variable | Default | Purpose |
| --- | --- | --- |
| `ROUTINE_BIND` | `127.0.0.1:8090` | HTTP listen address |
| `ROUTINE_DATABASE_URL` | local `routine-server` database | PostgreSQL/libpq connection string |
| `ROUTINE_API_TOKEN` | unset | Optional bearer token for every route except `/health` |
| `ROUTINE_GENERATION_DAYS` | `62` | Number of future days to materialize |
| `ROUTINE_WORKER_INTERVAL_SECONDS` | `60` | Generation/reminder polling interval |
| `ROUTINE_TELEGRAM_BOT_TOKEN` | unset | Telegram bot token |
| `ROUTINE_TELEGRAM_CHAT_ID` | unset | Telegram target chat |
Telegram delivery is enabled only when both Telegram variables are present.
Times use the service's local timezone and `HH:MM` format.
## API
Create a weekly routine:
```sh
curl -X POST http://127.0.0.1:8090/v1/routines \
-H 'Content-Type: application/json' \
-d '{
"public_title": "Exercise",
"section": "evening",
"priority": "should",
"schedule": {"kind": "weekly", "weekdays": [1, 3, 5]},
"reminder_time": "18:00"
}'
```
Create a monthly routine that moves day 31 to a shorter month's final day:
```json
{
"public_title": "Review finances",
"section": "work",
"priority": "must",
"schedule": {
"kind": "monthly",
"days": [31],
"clamp_to_last_day": true
}
}
```
Routes:
```text
GET /health
GET /v1/tasks?date=YYYY-MM-DD
GET /v1/tasks/archived
POST /v1/tasks
POST /v1/tasks/{id}/complete
POST /v1/tasks/{id}/archive
POST /v1/tasks/{id}/restore
POST /v1/tasks/{id}/reschedule
DELETE /v1/tasks/{id} (archived tasks only)
GET /v1/routines
POST /v1/routines
```
Weekly days use ISO numbers: Monday is `1`, Sunday is `7`.
When private data is present, `encrypted_payload`, `encryption_version`, and
`content_id` must all be set. `encrypted_payload` is an ASCII-armored age file
containing the client's versioned JSON document.