Skip to content

Commit

Permalink
adding https
Browse files Browse the repository at this point in the history
  • Loading branch information
LordFarquaadtheCreator committed Jun 18, 2024
1 parent bde0ff2 commit 7b3eeb5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"fs": "^0.0.1-security",
"nodemon": "^3.1.1",
"pg": "^8.11.5",
"ts-node": "^10.9.2",
Expand Down
15 changes: 6 additions & 9 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import checkDB, { secondsToMs } from "./dbChecker";
import cors from "cors";
import http from 'http';
import https from 'https';
import fs from 'fs';

// const privateKey = fs.readFileSync('sslcert/server.key', 'utf8');
// const certificate = fs.readFileSync('sslcert/server.crt', 'utf8');
// const credentials = {key: privateKey, cert: certificate};
const privateKey = fs.readFileSync('/etc/letsencrypt/live/test.byteccny.com/privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/test.byteccny.com/cert.pem', 'utf8');
const credentials = {key: privateKey, cert: certificate};

const PORT = 3000;
const INTERVAL = secondsToMs(60 * 60); // 1 hr
Expand Down Expand Up @@ -65,12 +66,8 @@ app.get("*", (req: any, res: any) => {
});
});

// app.listen(PORT, () => {
// console.log(`listening on port ${PORT}`);
// });

const httpServer = http.createServer(app);
// const httpsServer = https.createServer(credentials, app);
const httpsServer = https.createServer(credentials, app);

httpServer.listen(PORT);
// httpsServer.listen(PORT+1);
httpsServer.listen(PORT+1);

0 comments on commit 7b3eeb5

Please sign in to comment.