Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit fe9fd19

Browse files
committed
feat(database): Update default theme and init function
- Updated the default theme variables in the database initialization to improve the initial user experience. - Minor formatting and consistency improvements in database initialization logic.
1 parent 5e0ede5 commit fe9fd19

1 file changed

Lines changed: 70 additions & 64 deletions

File tree

src/core/database/database.ts

Lines changed: 70 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ const uid = userInfo().uid;
1313
export let db: Database;
1414

1515
try {
16-
const databasePath = path.join(dataFolder, "dockstatapi.db");
17-
console.log("Database path:", databasePath);
18-
console.log(`Running as: ${username} (${uid}:${gid})`);
16+
const databasePath = path.join(dataFolder, "dockstatapi.db");
17+
console.log("Database path:", databasePath);
18+
console.log(`Running as: ${username} (${uid}:${gid})`);
1919

20-
if (!existsSync(dataFolder)) {
21-
await mkdir(dataFolder, { recursive: true, mode: 0o777 });
22-
console.log("Created data directory:", dataFolder);
23-
}
20+
if (!existsSync(dataFolder)) {
21+
await mkdir(dataFolder, { recursive: true, mode: 0o777 });
22+
console.log("Created data directory:", dataFolder);
23+
}
2424

25-
db = new Database(databasePath, { create: true });
26-
console.log("Database opened successfully");
25+
db = new Database(databasePath, { create: true });
26+
console.log("Database opened successfully");
2727

28-
db.exec("PRAGMA journal_mode = WAL;");
28+
db.exec("PRAGMA journal_mode = WAL;");
2929
} catch (error) {
30-
console.error(`Cannot start DockStatAPI: ${error}`);
31-
process.exit(500);
30+
console.error(`Cannot start DockStatAPI: ${error}`);
31+
process.exit(500);
3232
}
3333

3434
export function init() {
35-
db.exec(`
35+
db.exec(`
3636
CREATE TABLE IF NOT EXISTS backend_log_entries (
3737
timestamp STRING NOT NULL,
3838
level TEXT NOT NULL,
@@ -105,62 +105,68 @@ export function init() {
105105
)
106106
`);
107107

108-
const themeRows = db
109-
.prepare("SELECT COUNT(*) AS count FROM themes")
110-
.get() as { count: number };
108+
const themeRows = db
109+
.prepare("SELECT COUNT(*) AS count FROM themes")
110+
.get() as { count: number };
111111

112-
const defaultCss = `
112+
const defaultCss = `
113113
.root,
114114
#root,
115115
#docs-root {
116-
--accent: #818cf8;
117-
--secondary-accent: #a5b4fc;
118-
--text-primary: #f3f4f6;
119-
--text-secondary: #d1d5db;
120-
--text-muted: #9ca3af;
121-
--border: #4b5563;
122-
--muted-bg: #18212f;
123-
--gradient-from: #1f2937;
124-
--gradient-to: #111827;
116+
--accent: #818cf9;
117+
--muted-bg: #0f172a;
118+
--gradient-from: #1e293b;
119+
--gradient-to: #334155;
120+
--border: #334155;
121+
--border-accent: rgba(129, 140, 249, 0.3);
122+
--text-primary: #f8fafc;
123+
--text-secondary: #94a3b8;
124+
--text-tertiary: #64748b;
125+
--state-success: #4ade80;
126+
--state-warning: #facc15;
127+
--state-error: #f87171;
128+
--state-info: #38bdf8;
129+
--shadow-glow: 0 0 15px rgba(129, 140, 249, 0.5);
130+
--background-gradient: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
125131
}
126-
`;
127-
128-
if (themeRows.count === 0) {
129-
db.prepare(
130-
"INSERT INTO themes (name, creator, vars, tags) VALUES (?,?,?,?)",
131-
).run("default", "Its4Nik", defaultCss, "[default]");
132-
}
133-
134-
const configRow = db
135-
.prepare("SELECT COUNT(*) AS count FROM config")
136-
.get() as { count: number };
137-
138-
if (configRow.count === 0) {
139-
db.prepare(
140-
"INSERT INTO config (keep_data_for, fetching_interval) VALUES (7, 5)",
141-
).run();
142-
}
143-
144-
const hostRow = db
145-
.prepare("SELECT COUNT(*) AS count FROM docker_hosts")
146-
.get() as { count: number };
147-
148-
if (hostRow.count === 0) {
149-
db.prepare(
150-
"INSERT INTO docker_hosts (name, hostAddress, secure) VALUES (?, ?, ?)",
151-
).run("Localhost", "localhost:2375", false);
152-
}
153-
154-
const storeRow = db
155-
.prepare("SELECT COUNT(*) AS count FROM store_repos")
156-
.get() as { count: number };
157-
158-
if (storeRow.count === 0) {
159-
db.prepare("INSERT INTO store_repos (slug, base) VALUES (?, ?)").run(
160-
"DockStacks",
161-
"https://raw.githubusercontent.com/Its4Nik/DockStacks/refs/heads/main/Index.json",
162-
);
163-
}
132+
`;
133+
134+
if (themeRows.count === 0) {
135+
db.prepare(
136+
"INSERT INTO themes (name, creator, vars, tags) VALUES (?,?,?,?)",
137+
).run("default", "Its4Nik", defaultCss, "[default]");
138+
}
139+
140+
const configRow = db
141+
.prepare("SELECT COUNT(*) AS count FROM config")
142+
.get() as { count: number };
143+
144+
if (configRow.count === 0) {
145+
db.prepare(
146+
"INSERT INTO config (keep_data_for, fetching_interval) VALUES (7, 5)",
147+
).run();
148+
}
149+
150+
const hostRow = db
151+
.prepare("SELECT COUNT(*) AS count FROM docker_hosts")
152+
.get() as { count: number };
153+
154+
if (hostRow.count === 0) {
155+
db.prepare(
156+
"INSERT INTO docker_hosts (name, hostAddress, secure) VALUES (?, ?, ?)",
157+
).run("Localhost", "localhost:2375", false);
158+
}
159+
160+
const storeRow = db
161+
.prepare("SELECT COUNT(*) AS count FROM store_repos")
162+
.get() as { count: number };
163+
164+
if (storeRow.count === 0) {
165+
db.prepare("INSERT INTO store_repos (slug, base) VALUES (?, ?)").run(
166+
"DockStacks",
167+
"https://raw.githubusercontent.com/Its4Nik/DockStacks/refs/heads/main/Index.json",
168+
);
169+
}
164170
}
165171

166172
init();

0 commit comments

Comments
 (0)