Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,12 @@
"site_key": "",
"secret_key": ""
}
},
"ssl": {
"enabled": false,
"cert_path": "../ssl/ilikehttps.cert",
"ca_path": "../ssl/ilikehttps.ca-bundle",
"key_path": "../ssl/ilikehttps.key",
"domain_name_without_protocol": "ilikehttps.com"
}
}
25 changes: 23 additions & 2 deletions src/structures/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const cookieParser = require("cookie-parser");
const session = require("express-session");
const passport = require("passport");

const { discord_client: {secret} } = require("@root/config.json");
const { discord_client: {secret}, ssl } = require("@root/config.json");

require("@utils/passport.js");

Expand Down Expand Up @@ -40,7 +40,28 @@ class App {
}

listen(port) {
return new Promise((resolve) => this.express.listen(port, resolve));
const fs = require('fs');
// return new Promise((resolve) => this.express.listen(port, resolve));
if(ssl.enabled === true) {
const path = require('path');
let httpsOptions = {
cert: fs.readFileSync(path.join(__dirname, ssl.cert_path)),
ca: fs.readFileSync(path.join(__dirname,ssl.ca_path)),
key: fs.readFileSync(path.join(__dirname, ssl.key_path))
}
return new Promise((resolve) => {
const https = require('https');
const httpsServer = https.createServer(httpsOptions, this.express);
// Encoding port 443 since it is SSL.
httpsServer.listen(443, ssl.domain_name_without_protocol);
resolve();
// SSL Should now be online!
})
} else if(ssl.enabled === false){
return new Promise((resolve) => this.express.listen(port, resolve));
} else {
return console.log('Invalid SSL Enabled/Disabled input')
}
}

loadRoutes() {
Expand Down