// Don't read this
module.exports = (fs, app, express, fetch, cmdUsers, dirname) => {
  
  app.use(express.static(dirname + '/public'));
var botcode = fs.readFileSync("./index.js").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
var highlight = fs.readFileSync("./filesetup/highlight.txt");
fs.writeFileSync("./filesetup/code.html", highlight + fs.readFileSync("./filesetup/headers.txt") + botcode + "\<\/" + "code><" + "/pre>")
botcode = fs.readFileSync("./codes/getsrc.js").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
fs.writeFileSync("./filesetup/src.html", highlight +  botcode + "\<\/" + "code><" + "/pre>")
botcode = fs.readFileSync("./codes/bf.js").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
fs.writeFileSync("./filesetup/bf.html", highlight +  botcode + "\<\/" + "code><" + "/pre>")
botcode = fs.readFileSync("./codes/src.js").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
fs.writeFileSync("./filesetup/src_board.html", highlight +  botcode + "\<\/" + "code><" + "/pre>")
botcode = fs.readFileSync("./filesetup/filesetup.js").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
fs.writeFileSync("./filesetup/filesetup.html", highlight +  botcode + "\<\/" + "code><" + "/pre>")
botcode = fs.readFileSync("./codes/runcode.js").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
fs.writeFileSync("./filesetup/runcode.html", highlight +  botcode + "\<\/" + "code><" + "/pre>")
botcode = fs.readFileSync("./codes/kb2cb.py").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
fs.writeFileSync("./filesetup/py.html", highlight.toString().replace("class=\"js\"", "class = \"py\"") +  botcode + "\<\/" + "code><" + "/pre>")
botcode = fs.readFileSync("./codes/twitter.js").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
fs.writeFileSync("./filesetup/twitter.html", highlight.toString() +  botcode + "\<\/" + "code><" + "/pre>")
botcode = fs.readFileSync("./codes/status.json").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
fs.writeFileSync("./filesetup/status.html", highlight.toString() +  botcode + "\<\/" + "code><" + "/pre>")
botcode = fs.readFileSync("./codes/cpp.js").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
fs.writeFileSync("./filesetup/cpp.html", highlight.toString() +  botcode + "\<\/" + "code><" + "/pre>")
botcode = fs.readFileSync("./main.sh").toString().replace(/\u003E/g, ">").replace(/\u003C/g, "<")
fs.writeFileSync("./filesetup/sh.html", highlight.toString() + "</code><code class='sh'>" + botcode + "</pre></code>")

app.get('/', function(req, res) {
    res.sendFile(__dirname + '/code.html');
});
app.get("/cmdusers", (req, res) => {
  res.send(JSON.stringify(cmdUsers))
})
app.get('/src', (req, res) => {
    res.sendFile(__dirname + "/src.html");
})
app.get('/bf', (req, res) => {
    res.sendFile(__dirname + "/bf.html");
})
app.get('/srcboard', (req, res) => {
    res.sendFile(__dirname + "/src_board.html");
})
app.get('/bash', (req, res) => {
    res.sendFile(__dirname + "/bash.html");
})
app.get('/py', (req, res) => {
    res.sendFile(__dirname + "/py.html");
})
app.get('/filesetup', (req, res) => {
    res.sendFile(__dirname + "/filesetup.html");
})
app.get('/twitter', (req, res) => {
    res.sendFile(__dirname + "/twitter.html");
})
//Komali deteriorates into madness with arg names
app.get('/codeblock', (a,b) => { 
  b.sendFile(__dirname + "/codeblock.html");
})
app.get("/statuses", (_,__) => { 
  __.sendFile(__dirname + "/status.html");
})
app.get("/code", (_,__) => {
  __.sendFile(__dirname + "/runcode.html");
})
app.get("/cpp", (_,__) => {
  __.sendFile(__dirname + "/cpp.html");
})
app.get("/sh", (res,req) => {
  req.sendFile(__dirname + "/sh.html");
})
}