|
|
|
@ -1,9 +1,13 @@
|
|
|
|
import { Database } from 'bun:sqlite';
|
|
|
|
import { Database } from 'bun:sqlite';
|
|
|
|
import { normalizeWhatsAppId } from './utils/whatsapp'; // Import the utility
|
|
|
|
import { normalizeWhatsAppId } from './utils/whatsapp';
|
|
|
|
|
|
|
|
import { mkdirSync } from 'fs';
|
|
|
|
|
|
|
|
import { join } from 'path';
|
|
|
|
|
|
|
|
|
|
|
|
// Function to get a database instance. Defaults to 'tasks.db'
|
|
|
|
// Function to get a database instance. Defaults to 'data/tasks.db'
|
|
|
|
export function getDb(filename: string = 'tasks.db'): Database {
|
|
|
|
export function getDb(filename: string = 'tasks.db'): Database {
|
|
|
|
return new Database(filename);
|
|
|
|
// Create data directory if it doesn't exist
|
|
|
|
|
|
|
|
mkdirSync('data', { recursive: true });
|
|
|
|
|
|
|
|
return new Database(join('data', filename));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Default export for the main application database
|
|
|
|
// Default export for the main application database
|
|
|
|
|