index html only on real routes otherwise redirect + better logging
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user