This commit is contained in:
Expand-sys 2021-06-24 12:18:55 +10:00
parent 6ba054de60
commit 70cd9f59a1
5 changed files with 78 additions and 2458 deletions

View file

@ -29,6 +29,7 @@ fastify.register(require("fastify-secure-session"), {
// options for setCookie, see https://github.com/fastify/fastify-cookie
secure: false,
httpOnly: true,
overwrite: true,
},
});
fastify.register(fastifyFlash);
@ -125,6 +126,10 @@ fastify.get(
console.log(err);
}
let balance = 0;
let graphdata = "";
let logsent = [];
let logrec = [];
if (admin != 1) {
balance = await client.balance(req.session.get("user"));
console.log(balance);
let logsent;
@ -137,21 +142,23 @@ fastify.get(
console.log(e);
}
console.log(logsent);
let logrec = logsent;
let graphlog = logsent;
logrec = logsent;
graphlog = logsent;
if (graphlog != null) {
graphlog = graphlog.reverse();
}
let graphdata = "";
graphdata = "";
let currentbal = balance;
if (graphlog) {
for (i = graphlog.length - 1; i > -1; i--) {
if (graphlog[i].from == req.session.get("user")) {
currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount);
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
graphdata =
graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
} else {
currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount);
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
graphdata =
graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
}
}
} else {
@ -172,7 +179,9 @@ fastify.get(
if (logrec == null) {
logrec = undefined;
} else {
logrec = await logrec.filter(({ to }) => to === req.session.get("user"));
logrec = await logrec.filter(
({ to }) => to === req.session.get("user")
);
}
if (logsent) {
for (i in logrec) {
@ -190,11 +199,13 @@ fastify.get(
if (logsent != null) {
logsent.reverse();
}
}
let maxgraph = balance + 1000;
console.log("begin render " + Date.now());
res.view("bankf", {
maxgraph: maxgraph,
graphdata: graphdata,
graphdata: graphdata || null,
logrec: logrec,
logsent: logsent,
user: req.session.get("user"),

2388
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -2,23 +2,13 @@
"dependencies": {
"@mgcrea/fastify-session": "^0.14.1",
"ccash-client-js": "^1.8.1",
"connect-flash": "^0.1.1",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-messages": "^1.0.1",
"express-session": "^1.17.1",
"express-validator": "5.3.1",
"fastify": "^3.18.0",
"fastify-auth": "^1.1.0",
"fastify-basic-auth": "^2.0.0",
"fastify-cookie": "^5.3.1",
"fastify-flash": "^2.0.2",
"fastify-formbody": "^5.0.0",
"fastify-jwt": "^3.0.0",
"fastify-jwt-webapp": "^0.11.1",
"fastify-plugin": "^3.0.0",
"fastify-secure-session": "^2.3.1",
"fastify-session": "^5.2.1",
"fastify-static": "^4.2.2",
"fastify-tls-keygen": "^1.1.0",
"got": "^11.8.2",

View file

@ -1,8 +1,6 @@
const root = process.env.PWD;
const path = require("path");
const pug = require("pug");
const flash = require("connect-flash");
const expressValidator = require("express-validator");
const { postUser } = require(`${root}/helpers/functions.js`);
const got = require("got");

View file

@ -1,9 +1,6 @@
const root = process.env.PWD;
const path = require("path");
var pug = require("pug");
const flash = require("connect-flash");
const expressValidator = require("express-validator");
const session = require("express-session");
const { postUser } = require(`${root}/helpers/functions.js`);
const { CCashClient } = require("ccash-client-js");