diff --git a/index.js b/index.js index 9b7899f..77f96fc 100644 --- a/index.js +++ b/index.js @@ -46,7 +46,7 @@ fastify.register(require("point-of-view"), { }); const api = `${process.env.BANKAPIURL}`; -console.log(api); + function papy() { const rndInt = Math.floor(Math.random() * 1337); let random = false; @@ -134,7 +134,7 @@ fastify.get( const user = req.session.get("user"); const password = req.session.get("password"); const auth = req.session.get("b64"); - balance = await got(`${api}/user/balance`, { + balance = await got(`${api}user/balance`, { headers: { Authorization: auth, Accept: "application/json", @@ -147,7 +147,7 @@ fastify.get( console.log(balance); console.log("start " + Date.now()); - let logsent = await got(`${api}/user/log`, { + let logsent = await got(`${api}user/log`, { headers: { Authorization: auth, Accept: "application/json", @@ -239,7 +239,7 @@ fastify.post( let result; let auth = req.session.get("b64"); try { - result = await got.post(`${api}/user/transfer`, { + result = await got.post(`${api}user/transfer`, { headers: { Authorization: auth, Accept: "application/json", @@ -277,7 +277,7 @@ fastify.post("/register", async function (req, res) { //let checkuser = await client.addUser(name, password); try { - let checkuser = await got.post(`${api}/user/register`, { + let checkuser = await got.post(`${api}user/register`, { headers: { Accept: "application/json", }, @@ -309,7 +309,7 @@ fastify.post("/login", async function (req, res) { auth = `Basic ${auth}`; let adminTest; try { - adminTest = await got.post(`${api}/admin/verify_account`, { + adminTest = await got.post(`${api}admin/verify_account`, { headers: { Authorization: auth, Accept: "application/json", @@ -330,7 +330,7 @@ fastify.post("/login", async function (req, res) { let verified; //verified = await client.verifyPassword(name, password); try { - verified = await got.post(`${api}/user/verify_password`, { + verified = await got.post(`${api}user/verify_password`, { headers: { Authorization: auth, Accept: "application/json", diff --git a/routes/admin.js b/routes/admin.js index a938cb9..e663003 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -53,7 +53,7 @@ module.exports = function (fastify, opts, done) { } let post; try { - post = await got.post(`${api}/admin/user/register`, { + post = await got.post(`${api}admin/user/register`, { headers: { Authorization: req.session.get("b64"), Accept: "application/json", @@ -88,7 +88,7 @@ module.exports = function (fastify, opts, done) { req.session.set("errors", ""); let responsecode; try { - balance = await got(`${api}/user/balance`, { + balance = await got(`${api}user/balance`, { headers: { Authorization: req.session.get("b64"), Accept: "application/json", @@ -125,7 +125,7 @@ module.exports = function (fastify, opts, done) { req.session.successes = []; req.session.errors = []; try { - patch = await got.patch(`${api}/admin/set_balance`, { + patch = await got.patch(`${api}admin/set_balance`, { headers: { Authorization: req.session.get("b64"), Accept: "application/json", @@ -160,7 +160,7 @@ module.exports = function (fastify, opts, done) { req.session.errors = []; try { - patch = await got.post(`${api}/admin/impact_balance`, { + patch = await got.post(`${api}admin/impact_balance`, { headers: { Authorization: req.session.get("b64"), Accept: "application/json", @@ -192,7 +192,7 @@ module.exports = function (fastify, opts, done) { if (new_pass == password2) { try { - patch = await got.patch(`${api}/user/change_password`, { + patch = await got.patch(`${api}user/change_password`, { headers: { Authorization: req.session.get("b64"), Accept: "application/json", @@ -227,7 +227,7 @@ module.exports = function (fastify, opts, done) { if (attempt != req.session.get("adminp")) try { - let deleteUser = await got.delete(`${api}/admin/user/delete`, { + let deleteUser = await got.delete(`${api}admin/user/delete`, { headers: { Authorization: req.session.get("b64"), Accept: "application/json", diff --git a/routes/settings.js b/routes/settings.js index be97af0..aa49a31 100644 --- a/routes/settings.js +++ b/routes/settings.js @@ -64,7 +64,7 @@ module.exports = function (fastify, opts, done) { res.redirect("/settings"); } else { try { - patch = await got.patch(`${api}/user/change_password`, { + patch = await got.patch(`${api}user/change_password`, { headers: { Authorization: auth, Accept: "application/json", @@ -116,7 +116,7 @@ module.exports = function (fastify, opts, done) { let auth = btoa(`${name}:${password}`); auth = `Basic ${auth}`; try { - del = await got.delete(`${api}/user/delete`, { + del = await got.delete(`${api}user/delete`, { headers: { Authorization: auth, Accept: "application/json",