index html only on real routes otherwise redirect + better logging

This commit is contained in:
2022-11-07 17:24:36 +01:00
parent 5f6df46d60
commit 1452c0c143
7 changed files with 83 additions and 49 deletions
+3 -3
View File
@@ -8,16 +8,16 @@ async function withDatabase({ path, initialValue }, fn) {
try {
await access(path, constants.R_OK)
} catch (e) {
console.log(`Creating empty database into "${path}"`)
console.log(`[Database] Creating empty database into "${path}"`)
await writeFile(path, JSON.stringify(initialValue, null, 2))
}
console.log(`Loading database from "${path}"`)
console.log(`[Database] Loading database from "${path}"`)
const state = JSON.parse(await readFile(path, 'utf-8'))
const result = await fn(state)
console.log(`Saving database to "${path}"`)
console.log(`[Database] Saving database to "${path}"`)
await writeFile(path, JSON.stringify(state, null, 2))
return result