diff --git a/.gitignore b/.gitignore index 7af7f04..cf333bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /node_modules -.env \ No newline at end of file +.env +sslcert/privkey.pem +sslcert/fullchain.pem \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4690e68..3efb405 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,4 +9,5 @@ services: volumes: - /home/lucien/joclud_api:/app ports: - - "3000:3000" \ No newline at end of file + - "3000:3000" + - "443:443" \ No newline at end of file diff --git a/index.js b/index.js index a1ab8aa..b51e6dc 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ const path = require("path"); const config = require("./config"); const cookieParser = require("cookie-parser"); const cors = require("cors"); +const https = require("https"); require("dotenv").config(); const app = express(); @@ -32,3 +33,14 @@ loadRoutes("api"); app.listen(port, () => { console.log(`Server listening on http://localhost:${port}/`); }); + +const privateKey = fs.readFileSync("./sslcert/privkey.pem", "utf8"); +const certificate = fs.readFileSync("./sslcert/fullchain.pem", "utf8"); + +const credentials = { key: privateKey, cert: certificate }; + +const httpsServer = https.createServer(credentials, app); + +httpsServer.listen(443, () => { + console.log("https server listening on port 443") +}) \ No newline at end of file