10 Commits

Author SHA1 Message Date
TheGreyDiamond
6bec74b064 Merge pull request #9 from TheGreyDiamond/dependabot/npm_and_yarn/eta-2.0.0
Bump eta from 1.12.3 to 2.0.0
2023-02-01 08:29:02 +01:00
dependabot[bot]
e6218c049c Bump eta from 1.12.3 to 2.0.0
Bumps [eta](https://github.com/eta-dev/eta) from 1.12.3 to 2.0.0.
- [Release notes](https://github.com/eta-dev/eta/releases)
- [Commits](https://github.com/eta-dev/eta/compare/v1.12.3...v2.0.0)

---
updated-dependencies:
- dependency-name: eta
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-31 22:46:31 +00:00
TheGreyDiamond
17d3617b90 Merge pull request #8 from TheGreyDiamond/dependabot/npm_and_yarn/qs-and-body-parser-and-express-6.11.0
Bump qs, body-parser and express
2022-12-09 17:51:24 +01:00
dependabot[bot]
8ac66cf71f Bump qs, body-parser and express
Bumps [qs](https://github.com/ljharb/qs) to 6.11.0 and updates ancestor dependencies [qs](https://github.com/ljharb/qs), [body-parser](https://github.com/expressjs/body-parser) and [express](https://github.com/expressjs/express). These dependencies need to be updated together.


Updates `qs` from 6.7.0 to 6.11.0
- [Release notes](https://github.com/ljharb/qs/releases)
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.7.0...v6.11.0)

Updates `body-parser` from 1.19.0 to 1.20.1
- [Release notes](https://github.com/expressjs/body-parser/releases)
- [Changelog](https://github.com/expressjs/body-parser/blob/master/HISTORY.md)
- [Commits](https://github.com/expressjs/body-parser/compare/1.19.0...1.20.1)

Updates `express` from 4.17.1 to 4.18.2
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.17.1...4.18.2)

---
updated-dependencies:
- dependency-name: qs
  dependency-type: indirect
- dependency-name: body-parser
  dependency-type: direct:production
- dependency-name: express
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-08 11:46:13 +00:00
TheGreyDiamond
da91e4210c Merge pull request #7 from TheGreyDiamond/dependabot/npm_and_yarn/minimatch-3.1.2
Bump minimatch from 3.0.4 to 3.1.2
2022-11-12 13:15:47 +01:00
dependabot[bot]
e73b02ec22 Bump minimatch from 3.0.4 to 3.1.2
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-11 15:29:55 +00:00
TheGreyDiamond
fe5090a382 Merge pull request #4 from TheGreyDiamond/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-03-30 12:48:30 +02:00
dependabot[bot]
4e576841f8 Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-30 02:33:35 +00:00
TheGreyDiamond
467e635145 Merge pull request #3 from TheGreyDiamond/refactor
General code maintanace
2021-10-13 14:27:59 +02:00
TheGreyDiamond
81b9d0b26f Removed unused lines, Fixed up some linting errors, more code documentation, updated some dep versions, and fixed error in package.json 2021-10-13 14:23:01 +02:00
5 changed files with 4047 additions and 693 deletions

View File

@@ -10,7 +10,8 @@
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-var-requires": 0
"@typescript-eslint/no-var-requires": 0,
"no-control-regex": 0
}
}

View File

@@ -5,7 +5,6 @@ const Eta = require("eta");
const winston = require("winston");
const mysql = require("mysql");
const bodyParser = require("body-parser");
// const csp = require(`helmet`);
const session = require("express-session");
const nodemailer = require("nodemailer");
@@ -32,34 +31,12 @@ logger.add(
const app = express();
/*
app.use(csp.contentSecurityPolicy({
useDefaults: true,
contentSecurityPolicy: false,
crossOriginEmbedderPolicy: false,
directives: {
"default-src": [`'self'`],
"img-src": [`'self'`],
scriptSrc: [`'self'`, `https://hcaptcha.com`, `https://*.hcaptcha.com`, `https://*.fontawesome.com`, "unsafe-inline", "unsafe-eval","'unsafe-inline'"],
"script-src-attr": [`'self'`, `https://hcaptcha.com`, `https://*.hcaptcha.com`, `https://*.fontawesome.com`, "unsafe-inline", "unsafe-eval"],
"frame-src": [`'self'`, `https://hcaptcha.com`, `https://*.hcaptcha.com`],
"style-src": [`'self'`, `https://hcaptcha.com`, `https://*.hcaptcha.com`, `https://*.fontawesome.com`, `'unsafe-inline'`],
"connect-src": [`'self'`, `https://hcaptcha.com`, `https://*.hcaptcha.com`, `https://*.fontawesome.com`],
"font-src": [`'self'`, `https://*.fontawesome.com`],
},
}))
*/
const startUpTime = Math.floor(new Date().getTime() / 1000);
// Skeleton Variables
let fontawesomeKey = "";
let mapboxAccessToken = "";
let mysqlData = { "user": "", "password": "", "database": "", "allowCreation": false };
let hCaptcha = { "sitekey": "", "secret": "" };
let mailConf = { "host": "", "port": 0, "username": "", "password": "" };
let serverAdress = "";
let cookieSecret = ""
@@ -94,12 +71,14 @@ try {
);
}
// Express (server) preperation
app.use(express.static("static"));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(session({ secret: cookieSecret }));
app.use(function (req, res, next) {
// PreShow Errorpage handler
const pathesWhichRequireDB = ["map", "login", "register"];
const pathesWhichRequireLogin = ["createElevator"];
const path = req.path
@@ -169,9 +148,9 @@ app.use(function (req, res, next) {
} else {
console.log("Stopped further exec of route")
}
})
// Mail preperation
const transport = nodemailer.createTransport({
host: mailConf.host,
port: mailConf.port,
@@ -179,15 +158,12 @@ const transport = nodemailer.createTransport({
secure: false,
debug: true,
disableFileAccess: true,
//authMethod: "START TLS",
auth: {
user: mailConf.username,
pass: mailConf.password,
},
});
//let transporter = nodemailer.createTransport(transport)
//console.log(transport.host)
logger.info("Testing SMTP connection");
transport.verify(function (error) {
if (error) {
@@ -197,9 +173,6 @@ transport.verify(function (error) {
}
});
app.use(session({ secret: cookieSecret }));
// Basic defines for html
const metainfo = {
author: "TheGreydiamond",
@@ -220,8 +193,6 @@ let con = mysql.createConnection({
database: mysqlData.database,
});
function checkIfMySQLStructureIsReady() {
if (mysqlIsUpAndOkay) {
// Only if MySQL is ready
@@ -288,7 +259,7 @@ con.connect(function (err) {
});
// Routes
app.get("/", function (req, res) {
app.get("/", function (req, res) { // Index page
const data = fs.readFileSync("templates/index.html", "utf8");
res.send(
Eta.render(data, {
@@ -300,7 +271,7 @@ app.get("/", function (req, res) {
);
});
app.get("/map", function (req, res) {
app.get("/map", function (req, res) { // Map page showing all elevators
const data = fs.readFileSync("templates/map.html", "utf8");
res.send(
Eta.render(data, {
@@ -314,7 +285,7 @@ app.get("/map", function (req, res) {
});
app.get("/createElevator", function (req, res) {
app.get("/createElevator", function (req, res) { // Page to create a new elvator
const data = fs.readFileSync("templates/createElevator.html", "utf8");
res.send(
Eta.render(data, {
@@ -331,9 +302,9 @@ require('./routes/api.route.ts')(app, con, mysqlIsUpAndOkay, logger, metainfo);
require('./routes/debug.route.ts')(app, con, logger, metainfo);
require('./routes/auth.route.ts')(app, con, logger, metainfo, jsonConfigGlobal);
// Some loops for handeling stuff
// Some loops for handeling stuff,
setInterval(() => {
if (mysqlIsUpAndOkay == false) {
if (mysqlIsUpAndOkay == false) { // SQL reconnect
logger.warn("Retrying to connect to MySQL");
con = mysql.createConnection({
host: "localhost",
@@ -353,7 +324,7 @@ setInterval(() => {
}
});
}
}, 60000);
}, 60*1000); // Every minute
// App start
app.listen(port, () => {

4669
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -17,19 +17,19 @@
"url": "git+https://github.com/TheGreyDiamond/elevatormapRewritten.git"
},
"author": "TheGreydiamond",
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/TheGreyDiamond/elevatormapRewritten/issues"
},
"homepage": "https://github.com/TheGreyDiamond/elevatormapRewritten#readme",
"homepage": "https://github.com/TheGreyDiamond/elevatormapRewritten",
"dependencies": {
"bcrypt": "^5.0.1",
"body-parser": "^1.19.0",
"eta": "^1.12.2",
"express": "^4.17.1",
"body-parser": "^1.20.1",
"eta": "^2.0.0",
"express": "^4.18.2",
"express-session": "^1.17.2",
"greeting-time": "^1.0.0",
"hcaptcha": "0.0.2",
"hcaptcha": "0.1.0",
"helmet": "^4.6.0",
"multer": "^1.4.2",
"mysql": "^2.18.1",
@@ -38,9 +38,9 @@
},
"devDependencies": {
"@types/node": "^16.0.0",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"eslint": "^7.26.0",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.32.0",
"eslint-config-strongloop": "^2.1.0",
"typescript": "^4.2.4"
}

View File

@@ -58,7 +58,6 @@ module.exports = function (app, con, mysqlIsUpAndOkay, logger) {
app.get("/api/resolveNameById", function (req, res) {
if (req.query.id != undefined && req.query.id != "") {
const sql = "SELECT username FROM users WHERE id=?";
con.query(sql, [req.query.id], function (err, result) {
if (err) {