mirror of
https://github.com/Expand-sys/ccashfrontend
synced 2025-12-17 07:12:12 +11:00
changes for reduction of nodemodules
This commit is contained in:
parent
6a8c4f9331
commit
a66f6f2be8
3 changed files with 73 additions and 68 deletions
135
index.js
135
index.js
|
|
@ -29,6 +29,7 @@ fastify.register(require("fastify-secure-session"), {
|
||||||
// options for setCookie, see https://github.com/fastify/fastify-cookie
|
// options for setCookie, see https://github.com/fastify/fastify-cookie
|
||||||
secure: false,
|
secure: false,
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
|
overwrite: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
fastify.register(fastifyFlash);
|
fastify.register(fastifyFlash);
|
||||||
|
|
@ -125,76 +126,86 @@ fastify.get(
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
let balance = 0;
|
let balance = 0;
|
||||||
balance = await client.balance(req.session.get("user"));
|
|
||||||
console.log(balance);
|
|
||||||
let logsent;
|
|
||||||
console.log("start " + Date.now());
|
|
||||||
try {
|
|
||||||
const user = req.session.get("user");
|
|
||||||
const password = req.session.get("password");
|
|
||||||
logsent = await client.log(user, password);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
console.log(logsent);
|
|
||||||
let logrec = logsent;
|
|
||||||
let graphlog = logsent;
|
|
||||||
if (graphlog != null) {
|
|
||||||
graphlog = graphlog.reverse();
|
|
||||||
}
|
|
||||||
let graphdata = "";
|
let graphdata = "";
|
||||||
let currentbal = balance;
|
let logsent = [];
|
||||||
if (graphlog) {
|
let logrec = [];
|
||||||
for (i = graphlog.length - 1; i > -1; i--) {
|
if (admin != 1) {
|
||||||
if (graphlog[i].from == req.session.get("user")) {
|
balance = await client.balance(req.session.get("user"));
|
||||||
currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount);
|
console.log(balance);
|
||||||
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
let logsent;
|
||||||
} else {
|
console.log("start " + Date.now());
|
||||||
currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount);
|
try {
|
||||||
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
const user = req.session.get("user");
|
||||||
|
const password = req.session.get("password");
|
||||||
|
logsent = await client.log(user, password);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
console.log(logsent);
|
||||||
|
logrec = logsent;
|
||||||
|
graphlog = logsent;
|
||||||
|
if (graphlog != null) {
|
||||||
|
graphlog = graphlog.reverse();
|
||||||
|
}
|
||||||
|
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 + "]";
|
||||||
|
} else {
|
||||||
|
currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount);
|
||||||
|
graphdata =
|
||||||
|
graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
graphlog = undefined;
|
||||||
|
}
|
||||||
|
if (graphdata != "") {
|
||||||
|
graphdata =
|
||||||
|
", [" + parseInt(graphlog.length) + "," + balance + "]" + graphdata;
|
||||||
|
graphdata = '["transaction", "balance"]' + graphdata;
|
||||||
|
}
|
||||||
|
if (logsent == null) {
|
||||||
|
logsent = undefined;
|
||||||
|
} else {
|
||||||
|
logsent = await logsent.filter(
|
||||||
|
({ from }) => from === req.session.get("user")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (logrec == null) {
|
||||||
|
logrec = undefined;
|
||||||
|
} else {
|
||||||
|
logrec = await logrec.filter(
|
||||||
|
({ to }) => to === req.session.get("user")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (logsent) {
|
||||||
|
for (i in logrec) {
|
||||||
|
logrec[i].time = new Date(logrec[i].time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
if (logrec) {
|
||||||
graphlog = undefined;
|
for (i in logsent) {
|
||||||
}
|
logsent[i].time = new Date(logsent[i].time);
|
||||||
if (graphdata != "") {
|
}
|
||||||
graphdata =
|
}
|
||||||
", [" + parseInt(graphlog.length) + "," + balance + "]" + graphdata;
|
if (logrec != null) {
|
||||||
graphdata = '["transaction", "balance"]' + graphdata;
|
logrec.reverse();
|
||||||
}
|
}
|
||||||
if (logsent == null) {
|
if (logsent != null) {
|
||||||
logsent = undefined;
|
logsent.reverse();
|
||||||
} else {
|
|
||||||
logsent = await logsent.filter(
|
|
||||||
({ from }) => from === req.session.get("user")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (logrec == null) {
|
|
||||||
logrec = undefined;
|
|
||||||
} else {
|
|
||||||
logrec = await logrec.filter(({ to }) => to === req.session.get("user"));
|
|
||||||
}
|
|
||||||
if (logsent) {
|
|
||||||
for (i in logrec) {
|
|
||||||
logrec[i].time = new Date(logrec[i].time);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (logrec) {
|
|
||||||
for (i in logsent) {
|
|
||||||
logsent[i].time = new Date(logsent[i].time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (logrec != null) {
|
|
||||||
logrec.reverse();
|
|
||||||
}
|
|
||||||
if (logsent != null) {
|
|
||||||
logsent.reverse();
|
|
||||||
}
|
|
||||||
let maxgraph = balance + 1000;
|
let maxgraph = balance + 1000;
|
||||||
console.log("begin render " + Date.now());
|
console.log("begin render " + Date.now());
|
||||||
res.view("bankf", {
|
res.view("bankf", {
|
||||||
maxgraph: maxgraph,
|
maxgraph: maxgraph,
|
||||||
graphdata: graphdata,
|
graphdata: graphdata || null,
|
||||||
logrec: logrec,
|
logrec: logrec,
|
||||||
logsent: logsent,
|
logsent: logsent,
|
||||||
user: req.session.get("user"),
|
user: req.session.get("user"),
|
||||||
|
|
@ -343,7 +354,7 @@ process.on("SIGINT", function () {
|
||||||
process.exit();
|
process.exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.listen(process.env.PORT || 3000, function (err, address) {
|
fastify.listen(process.env.PORT || 3000, "0.0.0.0", function (err, address) {
|
||||||
if (err) {
|
if (err) {
|
||||||
fastify.log.error(err);
|
fastify.log.error(err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
const root = process.env.PWD;
|
const root = process.env.PWD;
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const pug = require("pug");
|
const pug = require("pug");
|
||||||
const flash = require("connect-flash");
|
|
||||||
const expressValidator = require("express-validator");
|
|
||||||
const { postUser } = require(`${root}/helpers/functions.js`);
|
const { postUser } = require(`${root}/helpers/functions.js`);
|
||||||
const got = require("got");
|
const got = require("got");
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const mongoose = require("mongoose");
|
|
||||||
|
|
||||||
const { CCashClient } = require("ccash-client-js");
|
const { CCashClient } = require("ccash-client-js");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
const root = process.env.PWD;
|
const root = process.env.PWD;
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
var pug = require("pug");
|
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 { postUser } = require(`${root}/helpers/functions.js`);
|
||||||
const { CCashClient } = require("ccash-client-js");
|
const { CCashClient } = require("ccash-client-js");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue