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) => {