From 0ccf0d4b0f7cac0eeba347f09adf7ac8b36c7fdc Mon Sep 17 00:00:00 2001 From: asyncnomi Date: Sun, 11 Dec 2022 15:08:47 +0000 Subject: [PATCH] Update 'index.js' --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e20f8ff..e60d0f3 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,11 @@ const fs = require('fs'); const path = require('path') var LdapAuth = require('ldapauth-fork'); +var prankPath = "prankdata.txt"; +if (!fs.existsSync(prankPath)) { + fs.writeFileSync(prankPath, "{}"); +} + let PrankData = JSON.parse(fs.readFileSync("prankdata.txt")); let AdminUsersUid = ["asyncnomi", "johan", "enthalpine", "fas", "arina", "billy", "remi", "pierre", "", "", "", ""]; let UsersToken = {}; @@ -241,7 +246,7 @@ fastify.post('/getPrank', async (request, reply) => { function saveData() { - fs.writeFileSync('prankdata.txt', JSON.stringify(PrankData)); + fs.writeFileSync(prankPath, JSON.stringify(PrankData)); } function authenticate(user, pwd) { @@ -342,7 +347,7 @@ function makeid(length) { const start = async () => { try { - await fastify.listen({ port: 3000 }) + await fastify.listen({ port: 80 }) } catch (err) { fastify.log.error(err) LDAP.close(function(err) {