14 Commits

Author SHA1 Message Date
dependabot[bot]
262783310a Bump node-fetch from 2.6.5 to 2.6.7
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.5 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.5...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-30 10:48:59 +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
TheGreyDiamond
2e1eec4b7a Merge pull request #2 from TheGreyDiamond/dependabot/npm_and_yarn/tar-6.1.11
Bump tar from 6.1.5 to 6.1.11
2021-09-01 08:17:33 +02:00
dependabot[bot]
7134466431 Bump tar from 6.1.5 to 6.1.11
Bumps [tar](https://github.com/npm/node-tar) from 6.1.5 to 6.1.11.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-tar/compare/v6.1.5...v6.1.11)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-31 23:31:45 +00:00
TheGreyDiamond
808fa94a1a Merge pull request #1 from TheGreyDiamond/dependabot/npm_and_yarn/tar-6.1.5
Bump tar from 6.1.0 to 6.1.5
2021-08-04 22:33:35 +02:00
dependabot[bot]
f2bef7aa43 Bump tar from 6.1.0 to 6.1.5
Bumps [tar](https://github.com/npm/node-tar) from 6.1.0 to 6.1.5.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-tar/compare/v6.1.0...v6.1.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-04 03:58:06 +00:00
TheGreyDiamond
3c0b455341 Update map.html 2021-07-11 21:47:32 +02:00
TheGreyDiamond
5a87784ceb Update map.html 2021-07-11 21:44:59 +02:00
TheGreyDiamond
e69e40fec8 Update README.md 2021-07-09 14:42:16 +02:00
TheGreyDiamond
eadf729190 Update README.md 2021-07-09 14:42:04 +02:00
TheGreyDiamond
1377ae15ba Update README.md 2021-07-06 21:10:47 +02:00
7 changed files with 3781 additions and 582 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

@@ -1,2 +1,20 @@
# Elevatormap Rewritten
The elevator map at thegreydiamond.de/elevatormap has been offline for some time now, as it was very ineffective and didn't accept user contributions. This is an attempted by the original author to rewrite the project in Node.js.
## Host your own
Requirements:
- Node
- MySQL Server (MariaDB)
- Accounts for Fontawesome & hCaptcha
Setup steps:
1. Setup DB access
2. Change config file to your needs
3. Install dependencies with `npm install`
4. Make .js file with `npm run makeJS` (skip if you want to test it)
5. Start it with `npm start` (or use pm2)
It will autogenerate all tables needed. And then startup.
ToDo:
- [ ] Allow user edits
- [ ] Allow moderation

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, () => {

4275
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",
"eta": "^1.12.3",
"express": "^4.17.1",
"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) {

View File

@@ -85,7 +85,8 @@ L.tileLayer(
{
attribution:
'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 3,
maxZoom: 100,
minZoom: 2,
id: "mapbox/streets-v11",
tileSize: 512,
zoomOffset: -1,