prepping for docker
7
Dockerfile
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
FROM node:16
|
||||
RUN apt install python g++ make
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN npm install
|
||||
CMD ["node", "index.js"]
|
||||
44
index.js
|
|
@ -17,7 +17,9 @@ const mongoose = require("mongoose");
|
|||
const { CCashClient } = require("ccash-client-js");
|
||||
dotenv.config();
|
||||
const { postUser } = require("./helpers/functions.js");
|
||||
const client = new CCashClient(process.env.BANKAPIURL);
|
||||
if (process.env.BANKAPIURL) {
|
||||
const client = new CCashClient(process.env.BANKAPIURL);
|
||||
}
|
||||
|
||||
app.set("views", path.join(__dirname, "views"));
|
||||
app.set("view engine", "pug");
|
||||
|
|
@ -35,22 +37,6 @@ app.use(function (req, res, next) {
|
|||
next();
|
||||
});
|
||||
app.set("trust proxy", 1); // trust first proxy
|
||||
let secure = false;
|
||||
if (
|
||||
process.env.SECURE == "true" ||
|
||||
process.env.SECURE == "True" ||
|
||||
process.env.SECURE == "TRUE"
|
||||
) {
|
||||
secure = true;
|
||||
}
|
||||
let setup = false;
|
||||
if (
|
||||
process.env.SETUP == "true" ||
|
||||
process.env.SETUP == "True" ||
|
||||
process.env.SETUP == "TRUE"
|
||||
) {
|
||||
setup = true;
|
||||
}
|
||||
app.use(
|
||||
session({
|
||||
secret: "fuck shit cunt",
|
||||
|
|
@ -59,7 +45,7 @@ app.use(
|
|||
checkPeriod: 86400000, // prune expired entries every 24h
|
||||
}),
|
||||
saveUninitialized: true,
|
||||
cookie: { secure: secure, maxAge: 86400000 },
|
||||
cookie: { secure: process.env.SECURE, maxAge: 86400000 },
|
||||
})
|
||||
);
|
||||
app.use(
|
||||
|
|
@ -90,7 +76,29 @@ function papy() {
|
|||
return random;
|
||||
}
|
||||
|
||||
app.post("/setup", async function (req, res) {
|
||||
const { url, secure } = req.body;
|
||||
if (secure) {
|
||||
process.env.SECURE = true;
|
||||
}
|
||||
process.env.BANKAPIURL = url;
|
||||
fs.writeFileSync(
|
||||
".env",
|
||||
"BANKAPIURL=" +
|
||||
process.env.BANKAPIURL +
|
||||
"\n" +
|
||||
"SECURE=" +
|
||||
process.env.SECURE +
|
||||
"\nSETUP=true"
|
||||
);
|
||||
fs.mkdirSync("tmp");
|
||||
fs.writeFileSync("tmp/restart.txt");
|
||||
});
|
||||
|
||||
app.get("/", async function (req, res) {
|
||||
if (setup == false || !setup) {
|
||||
res.render("setup");
|
||||
}
|
||||
let checkalive;
|
||||
try {
|
||||
checkalive = await client.help();
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 80 B |
|
Before Width: | Height: | Size: 454 B |
|
Before Width: | Height: | Size: 1,009 B |
|
Before Width: | Height: | Size: 943 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 593 B |
|
Before Width: | Height: | Size: 180 B |
|
Before Width: | Height: | Size: 908 B |
|
Before Width: | Height: | Size: 172 B |
|
Before Width: | Height: | Size: 172 B |
|
Before Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 586 B |
|
Before Width: | Height: | Size: 2 KiB |
|
Before Width: | Height: | Size: 1 KiB |
|
Before Width: | Height: | Size: 209 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 482 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 558 B |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 937 B |
|
Before Width: | Height: | Size: 918 B |
|
Before Width: | Height: | Size: 802 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 530 B |
|
Before Width: | Height: | Size: 548 B |
|
Before Width: | Height: | Size: 563 B |
|
Before Width: | Height: | Size: 541 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 981 B |
|
Before Width: | Height: | Size: 412 B |
|
Before Width: | Height: | Size: 432 B |
|
Before Width: | Height: | Size: 449 B |
|
Before Width: | Height: | Size: 433 B |
|
Before Width: | Height: | Size: 997 B |
|
Before Width: | Height: | Size: 802 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 871 B |
|
Before Width: | Height: | Size: 145 B |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 707 B |
|
Before Width: | Height: | Size: 491 B |
|
Before Width: | Height: | Size: 974 B |
|
Before Width: | Height: | Size: 561 B |
|
Before Width: | Height: | Size: 634 B |
|
Before Width: | Height: | Size: 518 B |
|
Before Width: | Height: | Size: 320 B |
|
Before Width: | Height: | Size: 187 B |
|
Before Width: | Height: | Size: 422 B |
|
Before Width: | Height: | Size: 726 B |
|
Before Width: | Height: | Size: 934 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 364 B |
|
Before Width: | Height: | Size: 311 B |
|
Before Width: | Height: | Size: 561 B |
|
Before Width: | Height: | Size: 414 B |
|
Before Width: | Height: | Size: 385 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 796 B |
|
Before Width: | Height: | Size: 830 B |
|
Before Width: | Height: | Size: 680 B |
|
Before Width: | Height: | Size: 785 B |
|
Before Width: | Height: | Size: 287 B |
|
Before Width: | Height: | Size: 736 B |
|
Before Width: | Height: | Size: 978 B |
|
Before Width: | Height: | Size: 1 KiB |
|
Before Width: | Height: | Size: 1 KiB |
|
Before Width: | Height: | Size: 826 B |
|
Before Width: | Height: | Size: 856 B |
|
Before Width: | Height: | Size: 843 B |
|
Before Width: | Height: | Size: 1 KiB |
|
Before Width: | Height: | Size: 723 B |
|
Before Width: | Height: | Size: 1 KiB |
|
Before Width: | Height: | Size: 878 B |
|
Before Width: | Height: | Size: 1.1 KiB |