From 5fad7eb8cbd8ec876c70045367c585d73abf420c Mon Sep 17 00:00:00 2001 From: Aelita4 Date: Mon, 22 Aug 2022 11:28:10 +0200 Subject: [PATCH] Code cleanup --- src/index.ts | 4 ++-- src/routes/addIP.ts | 1 - src/routes/removeIP.ts | 4 ---- src/routes/root.ts | 1 - views/pages/index.ejs | 8 +------- 5 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/index.ts b/src/index.ts index 48c5382..600ca8c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ -import express, { Request, Response } from 'express'; +import express from 'express'; import Ping from 'ping'; -import { existsSync, readdirSync, writeFileSync, readFileSync } from 'fs'; +import { readdirSync } from 'fs'; import sessions from "express-session" import cookieParser from "cookie-parser" import mysql from 'mysql' diff --git a/src/routes/addIP.ts b/src/routes/addIP.ts index 1a912bf..e1dcf3e 100644 --- a/src/routes/addIP.ts +++ b/src/routes/addIP.ts @@ -1,5 +1,4 @@ import { Request, Response } from 'express'; -import { existsSync, writeFileSync, readFileSync } from 'fs' import { connection } from '../index.js'; export default { diff --git a/src/routes/removeIP.ts b/src/routes/removeIP.ts index 4b30f4d..94ace76 100644 --- a/src/routes/removeIP.ts +++ b/src/routes/removeIP.ts @@ -1,5 +1,4 @@ import { Request, Response } from 'express'; -import { existsSync, writeFileSync, readFileSync } from 'fs' import { connection } from '../index.js'; export default { @@ -20,8 +19,5 @@ export default { }); } }); - - /*res.setHeader('Content-Type', 'application/json'); - res.end(JSON.stringify({ status: "OK" }));*/ } } \ No newline at end of file diff --git a/src/routes/root.ts b/src/routes/root.ts index 40755fe..71ea569 100644 --- a/src/routes/root.ts +++ b/src/routes/root.ts @@ -1,5 +1,4 @@ import { Request, Response } from 'express'; -import { readFileSync } from 'fs'; import { getIP } from '../index.js'; export default { diff --git a/views/pages/index.ejs b/views/pages/index.ejs index 15d1d27..01f5c95 100644 --- a/views/pages/index.ejs +++ b/views/pages/index.ejs @@ -12,13 +12,7 @@ addrElement.innerHTML += '
' + ip + '
PINGING...
' const b = document.getElementById(ip + "_status"); await fetch('http://localhost:8080/addIP/' + ip) - window.location.reload(true); - /*await fetch('http://localhost:8080/ping/' + ip) - .then((response) => response.json()) - .then((data) => { - b.innerHTML = data.alive ? 'UP (' + data.numeric_host + ") " + data.time + 'ms' : 'DOWN' + ((data.host == "unknown") ? " (UNKNOWN HOST)" : (" (" + data.numeric_host + ")")) + '' - });*/ - + window.location.reload(true); } async function removeIP(ip) {