minor: new nav system (#5)
All checks were successful
ci/woodpecker/push/push Pipeline was successful

Co-authored-by: Madison Grubb <madison@elastiflow.com>
Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
2026-02-15 04:04:54 +00:00
parent 9261ba92bf
commit 0aab29ea72
27 changed files with 1198 additions and 688 deletions

View File

@@ -1,4 +1,4 @@
import { join } from 'node:path'
import { join, dirname } from 'node:path'
import { mkdirSync, existsSync } from 'node:fs'
import { createRequire } from 'node:module'
import { promisify } from 'node:util'
@@ -7,7 +7,7 @@ import { bootstrapAdmin } from './bootstrap.js'
const require = createRequire(import.meta.url)
const sqlite3 = require('sqlite3')
const SCHEMA_VERSION = 2
const SCHEMA_VERSION = 3
const DB_BUSY_TIMEOUT_MS = 5000
let dbInstance = null
@@ -68,6 +68,12 @@ const getDbPath = () => {
return join(dir, 'kestrelos.db')
}
export const getAvatarsDir = () => {
const dir = join(dirname(getDbPath()), 'avatars')
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
return dir
}
const getSchemaVersion = async (get) => {
try {
const row = await get('SELECT version FROM schema_version ORDER BY version DESC LIMIT 1')
@@ -99,6 +105,12 @@ const migrateToV2 = async (run, all) => {
}
}
const migrateToV3 = async (run, all) => {
const info = await all('PRAGMA table_info(users)')
if (info.some(c => c.name === 'avatar_path')) return
await run('ALTER TABLE users ADD COLUMN avatar_path TEXT')
}
const runMigrations = async (run, all, get) => {
const version = await getSchemaVersion(get)
if (version >= SCHEMA_VERSION) return
@@ -106,6 +118,10 @@ const runMigrations = async (run, all, get) => {
await migrateToV2(run, all)
await setSchemaVersion(run, 2)
}
if (version < 3) {
await migrateToV3(run, all)
await setSchemaVersion(run, 3)
}
}
const initDb = async (db, run, all, get) => {