Add Hosted Tables integration — configurable site URL syncs to auth
Registers hosted_tables in the integration schema with a single site_url config field. On save, syncHostedTables() PATCHes auth to update restaurant_bookings base_path and active state, so the portal app appears only when a URL is set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f5723d20c8
commit
1fde9f8613
2 changed files with 17 additions and 0 deletions
|
|
@ -37,6 +37,11 @@ export const INTEGRATIONS = {
|
|||
configFields: ['host', 'port', 'from', 'reply_to'],
|
||||
secretFields: ['user', 'pass'],
|
||||
},
|
||||
hosted_tables: {
|
||||
name: 'Hosted Tables',
|
||||
configFields: ['site_url'],
|
||||
secretFields: [],
|
||||
},
|
||||
}
|
||||
|
||||
export const MASKED = '••••••••'
|
||||
|
|
|
|||
|
|
@ -16,6 +16,17 @@ function bustAuthCache() {
|
|||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function syncHostedTables(siteUrl, enabled) {
|
||||
const secret = process.env.SETTINGS_SECRET || ''
|
||||
const active = enabled && siteUrl.trim().length > 0
|
||||
fetch(`${AUTH_URL}/api/auth/internal/apps/restaurant_bookings`, {
|
||||
method: 'PATCH',
|
||||
headers: { Authorization: `Bearer ${secret}`, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ base_path: siteUrl.trim() || '/bookings', active }),
|
||||
signal: AbortSignal.timeout(5000),
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function decryptSecrets(row) {
|
||||
if (!row.secrets) return {}
|
||||
try { return JSON.parse(decrypt(row.secrets)) } catch { return {} }
|
||||
|
|
@ -89,6 +100,7 @@ export async function integrationRoutes(app) {
|
|||
const { rows: [updated] } = await pool.query('SELECT * FROM integrations WHERE slug = $1', [slug])
|
||||
|
||||
if (slug === 'workforce' || slug === 'smtp') bustAuthCache()
|
||||
if (slug === 'hosted_tables') syncHostedTables(config.site_url ?? '', enabled)
|
||||
|
||||
return maskRow(updated)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue