managarten/services/mana-user/src/routes/settings.ts
Till JS ef19018e71 feat(infra): add mana-sync and mana-notify-go to docker-compose
- mana-sync on port 3051 (Go sync server for local-first apps)
- mana-notify-go on port 3040 (Go notification service)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 22:35:05 +01:00

30 lines
1 KiB
TypeScript

import { Hono } from 'hono';
import type { SettingsService } from '../services/settings';
import type { AuthUser } from '../middleware/jwt-auth';
export function createSettingsRoutes(settingsService: SettingsService) {
return new Hono<{ Variables: { user: AuthUser } }>()
.get('/', async (c) => {
const user = c.get('user');
return c.json(await settingsService.getSettings(user.userId));
})
.put('/global', async (c) => {
const user = c.get('user');
const body = await c.req.json();
return c.json(await settingsService.updateGlobalSettings(user.userId, body));
})
.put('/app/:appId', async (c) => {
const user = c.get('user');
const body = await c.req.json();
return c.json(
await settingsService.updateAppOverride(user.userId, c.req.param('appId'), body)
);
})
.put('/device/:deviceId', async (c) => {
const user = c.get('user');
const body = await c.req.json();
return c.json(
await settingsService.updateDeviceSettings(user.userId, c.req.param('deviceId'), body)
);
});
}