Browse Source

small changes

ashwini 2 months ago
parent
commit
b8663cbbf8
5 changed files with 84 additions and 2 deletions
  1. 12 2
      app.js
  2. 20 0
      certificate/certificate.crt
  3. 28 0
      certificate/private.key
  4. 22 0
      package-lock.json
  5. 2 0
      package.json

+ 12 - 2
app.js

@@ -1,7 +1,11 @@
 const express = require('express');
 const express = require('express');
 const bodyParser = require('body-parser');
 const bodyParser = require('body-parser');
 const routes = require('./routes/route');
 const routes = require('./routes/route');
+const https=require("https");
 //const routes = require('../DVR-BACKEND/routes/route');
 //const routes = require('../DVR-BACKEND/routes/route');
+const fs = require('fs');
+
+
 
 
 const app = express();
 const app = express();
 const cors= require('cors');
 const cors= require('cors');
@@ -14,6 +18,12 @@ app.use(express.urlencoded({
   extended: true
   extended: true
 }));
 }));
 
 
+const options = {
+  key: fs.readFileSync('./certificate/private.key'),
+  cert: fs.readFileSync('./certificate/certificate.crt')
+};
+
+
 app.use(cors())
 app.use(cors())
 app.use('/', routes);
 app.use('/', routes);
 
 
@@ -27,6 +37,6 @@ app.all('/*', function (req, res, next) {
 
 
 
 
 
 
-app.listen(port, () => {
-  console.log(` listening port at http://localhost:${port}`)
+https.createServer(options, app).listen(port, () => {
+  console.log(` listening port at https://localhost:${port}`)
 });
 });

+ 20 - 0
certificate/certificate.crt

@@ -0,0 +1,20 @@
+-----BEGIN CERTIFICATE-----
+MIIDTzCCAjcCFDNtuRf/55tBJsbryf03o61toh0QMA0GCSqGSIb3DQEBCwUAMGQx
+CzAJBgNVBAYTAklOMRQwEgYDVQQIDAtNYWhhcmFzaHRyYTEPMA0GA1UEBwwGbXVt
+YmFpMRIwEAYDVQQKDAltaW5kY3JhZnQxDDAKBgNVBAsMA2R2cjEMMAoGA1UEAwwD
+ZHZyMB4XDTI0MDkwNDExMzEzNloXDTI1MDkwNDExMzEzNlowZDELMAkGA1UEBhMC
+SU4xFDASBgNVBAgMC01haGFyYXNodHJhMQ8wDQYDVQQHDAZtdW1iYWkxEjAQBgNV
+BAoMCW1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dKz0+fT57gci+lCxu6ChJNyHZqIdURamaw
+BEVwThxSBL4SOb3o2Y9Ni9xiSCgWuQ/8EOzbRyRXHM9ouAfGnWXGpUTpAoGANMwO
+NY0lm3SqQ/6bStH27+aBhOZNABbwkmain7/VvkpdOZxBVnct7Q/9gw2523g3pTa6
+PYpX9Ea7eHS7SwmIWGWFpXzMWnDeblQ+gqOSjlG7zE2Ct8sekrk/P0u/4B18lYfI
+rUp771dMl42kOZ4P5xkta81QVWccZAN3pk8EEQECgYA6vQxRZKJ6VXxpcyIfshEt
+B+ybbcDSb4YZUA3dNKRFIdrJe+E5GndWrJ+xP1ljvtRqaOymy4vlIllsWE17BV15
+iHr+XFfPHPbqMGOQUC3iDSeujJBUM6XvW0Azhe/OtdDjxG+PuHSD//70hfWcR7La
+NTnIzIjX2nYjwxDfFCIk2A==
+-----END PRIVATE KEY-----

+ 22 - 0
package-lock.json

@@ -19,6 +19,8 @@
         "cors": "^2.8.5",
         "cors": "^2.8.5",
         "cros": "^1.0.1",
         "cros": "^1.0.1",
         "express": "^4.18.2",
         "express": "^4.18.2",
+        "fs": "^0.0.1-security",
+        "https": "^1.0.0",
         "jsonwebtoken": "^8.5.1",
         "jsonwebtoken": "^8.5.1",
         "mkdirp": "^1.0.4",
         "mkdirp": "^1.0.4",
         "moment": "^2.29.4",
         "moment": "^2.29.4",
@@ -733,6 +735,11 @@
         "node": ">= 0.6"
         "node": ">= 0.6"
       }
       }
     },
     },
+    "node_modules/fs": {
+      "version": "0.0.1-security",
+      "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
+      "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
+    },
     "node_modules/fsevents": {
     "node_modules/fsevents": {
       "version": "2.3.2",
       "version": "2.3.2",
       "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
       "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
@@ -828,6 +835,11 @@
         "node": ">= 0.8"
         "node": ">= 0.8"
       }
       }
     },
     },
+    "node_modules/https": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz",
+      "integrity": "sha512-4EC57ddXrkaF0x83Oj8sM6SLQHAWXw90Skqu2M4AEWENZ3F02dFJE/GARA8igO79tcgYqGrD7ae4f5L3um2lgg=="
+    },
     "node_modules/iconv-lite": {
     "node_modules/iconv-lite": {
       "version": "0.6.3",
       "version": "0.6.3",
       "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
       "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
@@ -2620,6 +2632,11 @@
       "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
       "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
       "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
       "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
     },
     },
+    "fs": {
+      "version": "0.0.1-security",
+      "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
+      "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
+    },
     "fsevents": {
     "fsevents": {
       "version": "2.3.2",
       "version": "2.3.2",
       "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
       "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
@@ -2687,6 +2704,11 @@
         "toidentifier": "1.0.1"
         "toidentifier": "1.0.1"
       }
       }
     },
     },
+    "https": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz",
+      "integrity": "sha512-4EC57ddXrkaF0x83Oj8sM6SLQHAWXw90Skqu2M4AEWENZ3F02dFJE/GARA8igO79tcgYqGrD7ae4f5L3um2lgg=="
+    },
     "iconv-lite": {
     "iconv-lite": {
       "version": "0.6.3",
       "version": "0.6.3",
       "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
       "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",

+ 2 - 0
package.json

@@ -16,6 +16,8 @@
     "cors": "^2.8.5",
     "cors": "^2.8.5",
     "cros": "^1.0.1",
     "cros": "^1.0.1",
     "express": "^4.18.2",
     "express": "^4.18.2",
+    "fs": "^0.0.1-security",
+    "https": "^1.0.0",
     "jsonwebtoken": "^8.5.1",
     "jsonwebtoken": "^8.5.1",
     "mkdirp": "^1.0.4",
     "mkdirp": "^1.0.4",
     "moment": "^2.29.4",
     "moment": "^2.29.4",