mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-23 10:46:43 +02:00
- 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>
30 lines
1 KiB
TypeScript
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)
|
|
);
|
|
});
|
|
}
|