managarten/services/mana-mail/src/routes/threads.ts
Till JS a3de6b3d81 feat(mail): add mana-mail service and frontend module (Phase 1 MVP)
Backend: Hono/Bun service on port 3042 with JMAP client for Stalwart,
account provisioning (@mana.how addresses on user registration),
thread/message/send/label API endpoints, and JWT + service-key auth.

Frontend: Mail module with 3-column inbox UI (mailboxes, thread list,
detail/compose), local-first encrypted drafts in Dexie, and API-driven
thread fetching. Scoped CSS with theme tokens.

Integration: Dexie v11 schema, mail pgSchema in mana_platform,
mana-auth fire-and-forget hook for account provisioning,
getManaMailUrl() in API config, app registry + branding update.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 20:35:54 +02:00

25 lines
911 B
TypeScript

/**
* Thread routes — inbox and thread detail (JWT auth).
*/
import { Hono } from 'hono';
import type { MailService } from '../services/mail-service';
import type { AuthUser } from '../middleware/jwt-auth';
export function createThreadRoutes(mailService: MailService) {
return new Hono<{ Variables: { user: AuthUser } }>()
.get('/threads', async (c) => {
const user = c.get('user');
const mailboxId = c.req.query('mailboxId');
const limit = parseInt(c.req.query('limit') || '50', 10);
const offset = parseInt(c.req.query('offset') || '0', 10);
const result = await mailService.getThreads(user.userId, { mailboxId, limit, offset });
return c.json(result);
})
.get('/threads/:threadId', async (c) => {
const user = c.get('user');
const threadId = c.req.param('threadId');
const thread = await mailService.getThread(user.userId, threadId);
return c.json(thread);
});
}