- backend/src/auth.js: extract caps from JWT (planner/settings), hasCap/requireCap
- backend/src/routes/config.js: gate categories + test-connection on requireCap('settings')
- frontend/src/types.ts: add caps[] to User, export can() helper
- frontend/src/App.tsx: gate /settings route on can(user, 'settings')
- frontend/src/components/Layout.tsx: gate nav item on can(user, 'settings')
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
23 lines
906 B
JavaScript
23 lines
906 B
JavaScript
#!/usr/bin/env node
|
|
// Run from hk-planner/ dir: DATABASE_URL=... node seed-app.js
|
|
import pg from 'pg'
|
|
|
|
const { Pool } = pg
|
|
const pool = new Pool({ connectionString: process.env.DATABASE_URL })
|
|
|
|
await pool.query(`
|
|
INSERT INTO apps (slug, name, description, base_path, icon, theme_color, category, internal_host, internal_port)
|
|
VALUES ('hk-planner', 'HK Planner', 'Housekeeping workload and hours planning', '/hk-planner', 'CalendarClock', '#2d6a4f', 'Housekeeping', '10.10.10.118', 3080)
|
|
ON CONFLICT (slug) DO UPDATE SET
|
|
name = EXCLUDED.name,
|
|
description = EXCLUDED.description,
|
|
base_path = EXCLUDED.base_path,
|
|
icon = EXCLUDED.icon,
|
|
theme_color = EXCLUDED.theme_color,
|
|
category = EXCLUDED.category,
|
|
internal_host = EXCLUDED.internal_host,
|
|
internal_port = EXCLUDED.internal_port
|
|
`)
|
|
|
|
console.log('hk-planner app seeded.')
|
|
await pool.end()
|