mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-30 18:46:00 +00:00
fixes after merge
This commit is contained in:
+58
-1
@@ -34,6 +34,8 @@ import oidcRoutes from './routes/oidc';
|
|||||||
import vacayRoutes from './routes/vacay';
|
import vacayRoutes from './routes/vacay';
|
||||||
import atlasRoutes from './routes/atlas';
|
import atlasRoutes from './routes/atlas';
|
||||||
import immichRoutes from './routes/immich';
|
import immichRoutes from './routes/immich';
|
||||||
|
import synologyRoutes from './routes/synology';
|
||||||
|
import memoriesRoutes from './routes/memories';
|
||||||
import notificationRoutes from './routes/notifications';
|
import notificationRoutes from './routes/notifications';
|
||||||
import shareRoutes from './routes/share';
|
import shareRoutes from './routes/share';
|
||||||
import { mcpHandler } from './mcp';
|
import { mcpHandler } from './mcp';
|
||||||
@@ -193,13 +195,68 @@ export function createApp(): express.Application {
|
|||||||
// Addons list endpoint
|
// Addons list endpoint
|
||||||
app.get('/api/addons', authenticate, (_req: Request, res: Response) => {
|
app.get('/api/addons', authenticate, (_req: Request, res: Response) => {
|
||||||
const addons = db.prepare('SELECT id, name, type, icon, enabled FROM addons WHERE enabled = 1 ORDER BY sort_order').all() as Pick<Addon, 'id' | 'name' | 'type' | 'icon' | 'enabled'>[];
|
const addons = db.prepare('SELECT id, name, type, icon, enabled FROM addons WHERE enabled = 1 ORDER BY sort_order').all() as Pick<Addon, 'id' | 'name' | 'type' | 'icon' | 'enabled'>[];
|
||||||
res.json({ addons: addons.map(a => ({ ...a, enabled: !!a.enabled })) });
|
const providers = db.prepare(`
|
||||||
|
SELECT id, name, icon, enabled, config, sort_order
|
||||||
|
FROM photo_providers
|
||||||
|
WHERE enabled = 1
|
||||||
|
ORDER BY sort_order, id
|
||||||
|
`).all() as Array<{ id: string; name: string; icon: string; enabled: number; config: string; sort_order: number }>;
|
||||||
|
const fields = db.prepare(`
|
||||||
|
SELECT provider_id, field_key, label, input_type, placeholder, required, secret, settings_key, payload_key, sort_order
|
||||||
|
FROM photo_provider_fields
|
||||||
|
ORDER BY sort_order, id
|
||||||
|
`).all() as Array<{
|
||||||
|
provider_id: string;
|
||||||
|
field_key: string;
|
||||||
|
label: string;
|
||||||
|
input_type: string;
|
||||||
|
placeholder?: string | null;
|
||||||
|
required: number;
|
||||||
|
secret: number;
|
||||||
|
settings_key?: string | null;
|
||||||
|
payload_key?: string | null;
|
||||||
|
sort_order: number;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
const fieldsByProvider = new Map<string, typeof fields>();
|
||||||
|
for (const field of fields) {
|
||||||
|
const arr = fieldsByProvider.get(field.provider_id) || [];
|
||||||
|
arr.push(field);
|
||||||
|
fieldsByProvider.set(field.provider_id, arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
addons: [
|
||||||
|
...addons.map(a => ({ ...a, enabled: !!a.enabled })),
|
||||||
|
...providers.map(p => ({
|
||||||
|
id: p.id,
|
||||||
|
name: p.name,
|
||||||
|
type: 'photo_provider',
|
||||||
|
icon: p.icon,
|
||||||
|
enabled: !!p.enabled,
|
||||||
|
config: JSON.parse(p.config || '{}'),
|
||||||
|
fields: (fieldsByProvider.get(p.id) || []).map(f => ({
|
||||||
|
key: f.field_key,
|
||||||
|
label: f.label,
|
||||||
|
input_type: f.input_type,
|
||||||
|
placeholder: f.placeholder || '',
|
||||||
|
required: !!f.required,
|
||||||
|
secret: !!f.secret,
|
||||||
|
settings_key: f.settings_key || null,
|
||||||
|
payload_key: f.payload_key || null,
|
||||||
|
sort_order: f.sort_order,
|
||||||
|
})),
|
||||||
|
})),
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Addon routes
|
// Addon routes
|
||||||
app.use('/api/addons/vacay', vacayRoutes);
|
app.use('/api/addons/vacay', vacayRoutes);
|
||||||
app.use('/api/addons/atlas', atlasRoutes);
|
app.use('/api/addons/atlas', atlasRoutes);
|
||||||
|
app.use('/api/integrations/memories', memoriesRoutes);
|
||||||
app.use('/api/integrations/immich', immichRoutes);
|
app.use('/api/integrations/immich', immichRoutes);
|
||||||
|
app.use('/api/integrations/synologyphotos', synologyRoutes);
|
||||||
app.use('/api/maps', mapsRoutes);
|
app.use('/api/maps', mapsRoutes);
|
||||||
app.use('/api/weather', weatherRoutes);
|
app.use('/api/weather', weatherRoutes);
|
||||||
app.use('/api/settings', settingsRoutes);
|
app.use('/api/settings', settingsRoutes);
|
||||||
|
|||||||
@@ -31,9 +31,13 @@ function parseNumberBodyField(value: unknown, fallback: number): number {
|
|||||||
return Number.isFinite(parsed) ? parsed : fallback;
|
return Number.isFinite(parsed) ? parsed : fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
router.get('/settings', authenticate, (req: Request, res: Response) => {
|
router.get('/settings', authenticate, async (req: Request, res: Response) => {
|
||||||
const authReq = req as AuthRequest;
|
const authReq = req as AuthRequest;
|
||||||
res.json(getSynologySettings(authReq.user.id));
|
try {
|
||||||
|
res.json(await getSynologySettings(authReq.user.id));
|
||||||
|
} catch (err: unknown) {
|
||||||
|
handleSynologyError(res, err, 'Failed to load settings');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.put('/settings', authenticate, async (req: Request, res: Response) => {
|
router.put('/settings', authenticate, async (req: Request, res: Response) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user