mirror of
https://github.com/Expand-sys/ccashfrontend
synced 2025-12-18 15:42:14 +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
27
index.js
27
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,6 +126,10 @@ fastify.get(
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
let balance = 0;
|
let balance = 0;
|
||||||
|
let graphdata = "";
|
||||||
|
let logsent = [];
|
||||||
|
let logrec = [];
|
||||||
|
if (admin != 1) {
|
||||||
balance = await client.balance(req.session.get("user"));
|
balance = await client.balance(req.session.get("user"));
|
||||||
console.log(balance);
|
console.log(balance);
|
||||||
let logsent;
|
let logsent;
|
||||||
|
|
@ -137,21 +142,23 @@ fastify.get(
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
console.log(logsent);
|
console.log(logsent);
|
||||||
let logrec = logsent;
|
logrec = logsent;
|
||||||
let graphlog = logsent;
|
graphlog = logsent;
|
||||||
if (graphlog != null) {
|
if (graphlog != null) {
|
||||||
graphlog = graphlog.reverse();
|
graphlog = graphlog.reverse();
|
||||||
}
|
}
|
||||||
let graphdata = "";
|
graphdata = "";
|
||||||
let currentbal = balance;
|
let currentbal = balance;
|
||||||
if (graphlog) {
|
if (graphlog) {
|
||||||
for (i = graphlog.length - 1; i > -1; i--) {
|
for (i = graphlog.length - 1; i > -1; i--) {
|
||||||
if (graphlog[i].from == req.session.get("user")) {
|
if (graphlog[i].from == req.session.get("user")) {
|
||||||
currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount);
|
currentbal = parseInt(currentbal) + parseInt(graphlog[i].amount);
|
||||||
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
graphdata =
|
||||||
|
graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
||||||
} else {
|
} else {
|
||||||
currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount);
|
currentbal = parseInt(currentbal) - parseInt(graphlog[i].amount);
|
||||||
graphdata = graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
graphdata =
|
||||||
|
graphdata + ", [" + parseInt(i) + "," + currentbal + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -172,7 +179,9 @@ fastify.get(
|
||||||
if (logrec == null) {
|
if (logrec == null) {
|
||||||
logrec = undefined;
|
logrec = undefined;
|
||||||
} else {
|
} else {
|
||||||
logrec = await logrec.filter(({ to }) => to === req.session.get("user"));
|
logrec = await logrec.filter(
|
||||||
|
({ to }) => to === req.session.get("user")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (logsent) {
|
if (logsent) {
|
||||||
for (i in logrec) {
|
for (i in logrec) {
|
||||||
|
|
@ -190,11 +199,13 @@ fastify.get(
|
||||||
if (logsent != null) {
|
if (logsent != null) {
|
||||||
logsent.reverse();
|
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