mirror of
https://github.com/screentinker/screentinker.git
synced 2026-08-16 23:33:10 -06:00
c
This commit is contained in:
parent
c9adb31882
commit
6cf86533e4
|
|
@ -343,4 +343,6 @@ module.exports = {
|
||||||
bunnyStorageEndpoint: process.env.VITE_BUNNY_STORAGE_ENDPOINT || '',
|
bunnyStorageEndpoint: process.env.VITE_BUNNY_STORAGE_ENDPOINT || '',
|
||||||
bunnyApiKey: process.env.VITE_BUNNY_API_KEY || '',
|
bunnyApiKey: process.env.VITE_BUNNY_API_KEY || '',
|
||||||
bunnyPullZone: process.env.VITE_BUNNY_PULL_ZONE || '',
|
bunnyPullZone: process.env.VITE_BUNNY_PULL_ZONE || '',
|
||||||
|
bunnyDbUrl: process.env.BUNNY_DATABASE_URL || '',
|
||||||
|
bunnyDbAuthToken: process.env.BUNNY_DATABASE_AUTH_TOKEN || '',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const Database = require('better-sqlite3');
|
const Database = require('libsql');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
|
|
@ -7,7 +7,15 @@ const { chunkedDelete, yieldTick, currentBand } = require('../lib/chunked-prune'
|
||||||
const dbDir = path.dirname(config.dbPath);
|
const dbDir = path.dirname(config.dbPath);
|
||||||
if (!fs.existsSync(dbDir)) fs.mkdirSync(dbDir, { recursive: true });
|
if (!fs.existsSync(dbDir)) fs.mkdirSync(dbDir, { recursive: true });
|
||||||
|
|
||||||
const db = new Database(config.dbPath);
|
const dbOptions = {};
|
||||||
|
if (config.bunnyDbUrl && config.bunnyDbAuthToken) {
|
||||||
|
dbOptions.syncUrl = config.bunnyDbUrl;
|
||||||
|
dbOptions.authToken = config.bunnyDbAuthToken;
|
||||||
|
}
|
||||||
|
const db = new Database(config.dbPath, dbOptions);
|
||||||
|
if (dbOptions.syncUrl) {
|
||||||
|
db.sync(); // Initial sync
|
||||||
|
}
|
||||||
|
|
||||||
// Enable WAL mode and foreign keys
|
// Enable WAL mode and foreign keys
|
||||||
db.pragma('journal_mode = WAL');
|
db.pragma('journal_mode = WAL');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue