const fs = require("fs") const express = require("express") const fetch = require("node-fetch") const geoip = require("geoip-ultralight") const JSONdb = require("simple-json-db") var conf = require("./config") const filestuff = require("./filestuff") var con = require("./console") var posts = require("./posts") var comments = require("./comments") const scheduler = require("./scheduler") const log = require("./logging") var admin = require("./admin") // init logging log.init( conf.logging, conf.logfile ) // general TODO: // config! ./config.js for some configuration in js just some form stuff // posts.rank timer config'n stuff const app = express() const port = 5500 // express static stuff sites: app.get("/", (req, res) => filestuff.readFS(req, res, "html/index.html", "text/html")) app.use("/static", express.static("html")) // config stuff: app.get("/config.js", (req, res) => { let c = { "ipget_endpoint_set": conf.ipget_endpoint_set, "site_name": conf.site_name, "search_enable": conf.search_enable, "index_post_sort": conf.index_post_sort, "commenting_enabled": conf.commenting_enabled } res.type("application/javascript") res.end(`conf = ${ JSON.stringify( c ) }\n/* This file is automatically generated from config.yaml */\n`) }) log.log("Dumping config:", log.d.datahorder) log.log(JSON.stringify(conf), log.d.datahorder) // meta-console commands: con.registercmd( "stop", () => shutdown() ) con.registercmd( "exit", () => shutdown() ) con.registercmd( "appeval", (arg) => {try {console.log(eval(arg.join(" ")))} catch {console.log("Couldn't execute!")}}) // comment command con.registercmd( "comment", (arg => { let t let body let time sw: switch (arg[0]) { case "get": if (!arg[1]) return console.log("Nothing to get!") if (!arg[2]) { console.log("No commentID, dumping all") let len = commentDB.get( arg[1] + "-len" ) let ret = [] for (let i = 0 ; i < len ; i++ ) { ret.push( commentDB.get( arg[1] + "-" + i ) ) } return console.log(ret) } else { console.log( commentDB.get( arg[1] + "-" + arg[2] ) ) } break case "push": if (!arg[1] || !arg[2] || !arg[3] || !arg[4]) { return console.log("Not all args specified!\nUsage: comment push