From 5053b37adf8df70d026064c48e9ae123c760ef52 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Sat, 4 Jul 2026 13:13:20 +0000 Subject: [PATCH] Add internal GET endpoint for global_config keys Allows other services (e.g. room-planner) to read shared config stored in settings_db without cross-database queries. Auth via SETTINGS_SECRET bearer token, same pattern as /internal/integration. Co-Authored-By: Claude Sonnet 4.6 --- src/routes/integrations.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/routes/integrations.js b/src/routes/integrations.js index 7d12b64..aefc330 100644 --- a/src/routes/integrations.js +++ b/src/routes/integrations.js @@ -159,6 +159,18 @@ export async function integrationRoutes(app) { return value }) + // GET /settings/api/internal/global-config/:key — service-to-service read of global_config + // Authenticated by SETTINGS_SECRET bearer token; returns the value JSON for the given key. + app.get('/internal/global-config/:key', async (req, reply) => { + const token = (req.headers.authorization || '').replace(/^Bearer\s+/i, '') + if (!token || token !== process.env.SETTINGS_SECRET) { + return reply.status(401).send({ error: 'Unauthorized' }) + } + const { rows: [row] } = await pool.query('SELECT value FROM global_config WHERE key = $1', [req.params.key]) + if (!row) return reply.status(404).send({ error: 'Not found' }) + return { value: row.value } + }) + // GET /settings/api/internal/integration/:slug — service-to-service, no user session required // Authenticated by SETTINGS_SECRET bearer token; returns unmasked credentials. app.get('/internal/integration/:slug', async (req, reply) => {