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 <noreply@anthropic.com>
This commit is contained in:
parent
9eaf05a4aa
commit
5053b37adf
1 changed files with 12 additions and 0 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue