Clean up changes

Seperated all routes into seperate files for neatness, and I've made the comments.json store only the comments, comments_counter is in the new data.json file which also stores the hitcount.

Signed-off-by: max <deadvey@localhost.localdomain>
This commit is contained in:
max
2025-09-24 10:02:28 +01:00
parent 0541b704db
commit 93c5f13750
11 changed files with 464 additions and 400 deletions

View File

@@ -25,7 +25,14 @@ export function initialise() {
}
catch (error) {
console.log("Creating comments file")
fs.writeFileSync(`../data/comments.json`, `{\n"comments": [],\n"counter": 0}`)
fs.writeFileSync(`../data/comments.json`, `[]`)
}
try {
const comments = require("../data/data.json");
}
catch (error) {
console.log("Creating generic data file")
fs.writeFileSync(`../data/data.json`, `{"hitcount": 0, "comment_counter": 0}`)
}
try {
const config = require("../config.json");
@@ -37,15 +44,7 @@ export function initialise() {
console.log("Error copying file")
})
}
try {
fs.readFileSync("../data/hitcount.txt")
}
catch (error) {
console.log("Creating hitcount file")
fs.writeFileSync("../data/hitcount.txt", "0", (err) => {
console.log("Error creating hitcount.txt")
})
}
console.log("Successfully initialised")
process.exit(0)
}