feat: Improve UI layout and navigation
- Increase logo size (48x48 desktop, 56x56 mobile) for better visibility - Add logo as favicon - Add logo to mobile header - Move user menu to navigation bars (sidebar on desktop, bottom bar on mobile) - Fix desktop chat layout - container structure prevents voice controls cutoff - Fix mobile bottom bar - use icon-only ActionIcons instead of truncated text buttons - Hide Create Node/New Conversation buttons on mobile to save header space - Make fixed header and voice controls work properly with containers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
27
lib/db.ts
27
lib/db.ts
@@ -1,31 +1,42 @@
|
||||
import Surreal from 'surrealdb';
|
||||
|
||||
/**
|
||||
* Connects to the SurrealDB instance and authenticates with the user's JWT.
|
||||
* This enforces row-level security defined in the schema.
|
||||
* Connects to the SurrealDB instance with root credentials.
|
||||
*
|
||||
* IMPORTANT: This connects as root, so queries MUST filter by user_did
|
||||
* to enforce data isolation. The caller is responsible for providing
|
||||
* the correct user_did from the verified JWT.
|
||||
*
|
||||
* @param token - The user's app-specific (SurrealDB) JWT
|
||||
* @returns The authenticated SurrealDB instance
|
||||
*/
|
||||
export async function connectToDB(token: string): Promise<Surreal> {
|
||||
export async function connectToDB(): Promise<Surreal> {
|
||||
const SURREALDB_URL = process.env.SURREALDB_URL;
|
||||
const SURREALDB_NAMESPACE = process.env.SURREALDB_NS;
|
||||
const SURREALDB_DATABASE = process.env.SURREALDB_DB;
|
||||
const SURREALDB_USER = process.env.SURREALDB_USER;
|
||||
const SURREALDB_PASS = process.env.SURREALDB_PASS;
|
||||
|
||||
if (!SURREALDB_URL || !SURREALDB_NAMESPACE || !SURREALDB_DATABASE) {
|
||||
throw new Error('SurrealDB configuration is missing');
|
||||
}
|
||||
|
||||
if (!SURREALDB_USER || !SURREALDB_PASS) {
|
||||
throw new Error('SurrealDB credentials are missing');
|
||||
}
|
||||
|
||||
// Create a new instance for each request to avoid connection state issues
|
||||
const db = new Surreal();
|
||||
|
||||
// Connect to SurrealDB
|
||||
await db.connect(SURREALDB_URL);
|
||||
|
||||
// Authenticate as the user for this request.
|
||||
// This enforces the row-level security (PERMISSIONS)
|
||||
// defined in the schema for all subsequent queries.
|
||||
await db.authenticate(token);
|
||||
// Sign in with root credentials
|
||||
// NOTE: We use root access because our JWT-based auth is app-level,
|
||||
// not SurrealDB-level. Queries must filter by user_did from the verified JWT.
|
||||
await db.signin({
|
||||
username: SURREALDB_USER,
|
||||
password: SURREALDB_PASS,
|
||||
});
|
||||
|
||||
// Use the correct namespace and database
|
||||
await db.use({
|
||||
|
||||
Reference in New Issue
Block a user