Skip to content

Commit 0713295

Browse files
authored
Update index.js
1 parent c76944e commit 0713295

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/index.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import dotenv from "dotenv";
33
import cors from "cors";
44
import swaggerAutogen from "swagger-autogen";
55
import swaggerUiExpress from "swagger-ui-express";
6+
import fs from "fs";
7+
import path from "path";
8+
import HTTPS from "https";
69
import { handleUserSignUp, handleUserSignUpComplete, handleUserLogin, handlePatchPasswd, handleAutoComplete } from './controllers/user.controller.js';
710
import {
811
handleUserEditProfile,
@@ -112,6 +115,16 @@ app.use((err, req, res, next) => {
112115
});
113116

114117

115-
app.listen(port, () => {
116-
console.log(`Server: http://localhost:${port}`)
117-
})
118+
const option = {
119+
ca: fs.readFileSync("./pem/fullchain.pem"),
120+
key: fs
121+
.readFileSync(path.resolve(process.cwd(), "./pem/privkey.pem"), "utf8")
122+
.toString(),
123+
cert: fs
124+
.readFileSync(path.resolve(process.cwd(), "./pem/cert.pem"), "utf8")
125+
.toString(),
126+
};
127+
128+
HTTPS.createServer(option, app).listen(port, () => {
129+
console.log(`[HTTPS] Server is runnig on port ${port}`);
130+
});

0 commit comments

Comments
 (0)