From f6061d65a0c9d48445e264748216607cf1753d1b Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 25 Sep 2022 13:00:51 +0600 Subject: ssl cert and https port are no longer required --- index.ts | 10 ++-------- src/Main.ts | 31 +------------------------------ 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/index.ts b/index.ts index 96e4a97..55868cd 100644 --- a/index.ts +++ b/index.ts @@ -28,14 +28,8 @@ if (cli.init) { ClientSecret: "", RedirectURI: "" }, - Certificate: { - Key: "", - Cert: "", - Ca: "" - }, - Ports: { - HTTP: "80", - HTTPS: "443" + Server: { + Port: "8033" } } diff --git a/src/Main.ts b/src/Main.ts index b218739..90f8d40 100644 --- a/src/Main.ts +++ b/src/Main.ts @@ -17,9 +17,6 @@ import express from "express"; import cookieParser from "cookie-parser"; import bodyParser from "body-parser"; -import http from "http"; -import https from "https"; - import { Logger } from "tslog"; import ProfileRouter from "./routers/Profile"; @@ -34,9 +31,6 @@ function Main(dirPath: string, cfg: {[key: string]: any}, cli_options?: {[key: s const App: express.Express = express(); const prisma: PrismaClient = new PrismaClient(); - var httpc: http.Server | null = null; - var httpsc: https.Server | null = null; - App.set("view engine", "ejs"); App.set("views", `${dirPath}/static/ejs`); @@ -50,32 +44,9 @@ function Main(dirPath: string, cfg: {[key: string]: any}, cli_options?: {[key: s App.use(express.static(`${dirPath}/static`)); if (cli_options) { - httpc = http.createServer(App); - httpc.listen(parseInt(cfg.Ports.HTTP), () => { + App.listen(parseInt(cfg.Ports.HTTP), () => { log.info("Image hoster is running on port", cfg.Ports.HTTP); }); - - if (!cli_options.noSsl) { - if ( - cfg.Certificate.Key == "" || - cfg.Certificate.Cert == "" || - cfg.Certificate.Ca == "" - ) { - log.error("No paths for certificate provided."); - process.exit(1); - } - - const credentials = { - key: readFileSync(cfg.Certificate.Key, {encoding: "utf-8"}), - cert: readFileSync(cfg.Certificate.Cert, {encoding: "utf-8"}), - ca: readFileSync(cfg.Certificate.Ca, {encoding: "utf-8"}) - } - - httpsc = https.createServer(credentials, App); - httpsc.listen(parseInt(cfg.Ports.HTTPS), () => { - log.info("Image hoster is running on port", cfg.Ports.HTTPS, "(SSL)"); - }); - } } else { log.error("NO CLI OPTIONS PROVIDED!!!") process.exit(1); -- cgit v1.2.3