From 84f53c40b8b27076a9015bc06b785d25c9f1d9c1 Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Wed, 19 Jun 2024 12:55:18 -0500 Subject: [PATCH] Socials --- .gitignore | 1 + index.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index ceaea36..c2ff27d 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,4 @@ dist .yarn/install-state.gz .pnp.* +config \ No newline at end of file diff --git a/index.js b/index.js index 4d3d8ec..a9006e3 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,21 @@ var pfpSeason = "default" var violetSpins = 0 +var configPath = path.join(__dirname, "config") +if (!fs.existsSync(configPath)) { + fs.mkdirSync(configPath) +} + +var configs = ["socials.json"] + +for (var i = 0; i < configs.length; i++) { + var file = configs[i] + var filePath = path.join(configPath, file) + if (!fs.existsSync(filePath)) { + fs.writeFileSync(filePath, "{}") + } +} + function randomFileInDir(directory) { var dir = fs.readdirSync(directory) return path.join(directory, dir[Math.floor(Math.random() * dir.length)]) @@ -56,6 +71,10 @@ app.get("/v1/spins", (req, res) => { res.send(violetSpins.toString()) }) +app.get("/v1/socials", (req, res) => { + res.sendFile(path.join(configPath, "socials.json")) +}) + // app.listen(PORT, () => { // console.log("API is now listening on port 8080!") // })