Dodal https support
This commit is contained in:
		
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -60,4 +60,6 @@ typings/ | ||||
| # next.js build output | ||||
| .next | ||||
|  | ||||
| UpImage/ | ||||
| UpImage/ | ||||
|  | ||||
| archive/ | ||||
							
								
								
									
										28
									
								
								app.js
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								app.js
									
									
									
									
									
								
							| @@ -3,7 +3,19 @@ var express = require('express'); | ||||
| var path = require('path'); | ||||
| var cookieParser = require('cookie-parser'); | ||||
| var logger = require('morgan'); | ||||
| const http = require('http'); | ||||
| const https = require('https'); | ||||
| const fs = require('fs'); | ||||
|  | ||||
| const hostname = 'petrov.nexus'; | ||||
| const httpPort = 80; | ||||
| const httpsPort = 443; | ||||
|  | ||||
| const httpsOptions = { | ||||
|   key: fs.readFileSync('./archive/server.key'), | ||||
|   cert: fs.readFileSync('./archive/petrov_nexus.crt'), | ||||
|   ca: fs.readFileSync('./archive/petrov_nexus.ca-bundle') | ||||
| }; | ||||
|  | ||||
| // vključimo mongoose in ga povežemo z MongoDB | ||||
| var mongoose = require('mongoose'); | ||||
| @@ -23,6 +35,9 @@ var movieShowRouter = require('./routes/movies/movieShow'); | ||||
|  | ||||
| var app = express(); | ||||
|  | ||||
| const httpServer = http.createServer(app); | ||||
| const httpsServer = https.createServer(httpsOptions, app); | ||||
|  | ||||
| // view engine setup | ||||
| app.set('views', path.join(__dirname, 'views')); | ||||
| app.set('view engine', 'hbs'); | ||||
| @@ -78,9 +93,14 @@ app.use(function(err, req, res, next) { | ||||
|   res.render('error', {title:'Error'}); | ||||
| }); | ||||
|  | ||||
| const port = 80; | ||||
| app.listen(port, () => { | ||||
|   console.log(`Example app listening on port ${port}`) | ||||
| }) | ||||
| httpServer.listen(httpPort, () => { | ||||
|   console.log(`Server running at http://${hostname}:${httpPort}/`); | ||||
| }); | ||||
| httpsServer.listen(httpsPort, () => { | ||||
|   console.log(`Server running at https://${hostname}:${httpsPort}/`); | ||||
| }); | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| module.exports = app; | ||||
|   | ||||
							
								
								
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -13,8 +13,11 @@ | ||||
|         "debug": "~2.6.9", | ||||
|         "express": "^4.18.2", | ||||
|         "express-session": "^1.17.3", | ||||
|         "fs": "^0.0.1-security", | ||||
|         "hbs": "^4.2.0", | ||||
|         "http": "^0.0.1-security", | ||||
|         "http-errors": "~1.6.3", | ||||
|         "https": "^1.0.0", | ||||
|         "mongoose": "^7.3.1", | ||||
|         "morgan": "~1.9.1", | ||||
|         "multer": "^1.4.5-lts.1" | ||||
| @@ -607,6 +610,11 @@ | ||||
|         "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/function-bind": { | ||||
|       "version": "1.1.1", | ||||
|       "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", | ||||
| @@ -692,6 +700,11 @@ | ||||
|         "npm": "1.2.8000 || >= 1.4.16" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/http": { | ||||
|       "version": "0.0.1-security", | ||||
|       "resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz", | ||||
|       "integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g==" | ||||
|     }, | ||||
|     "node_modules/http-errors": { | ||||
|       "version": "1.6.3", | ||||
|       "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", | ||||
| @@ -706,6 +719,11 @@ | ||||
|         "node": ">= 0.6" | ||||
|       } | ||||
|     }, | ||||
|     "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": { | ||||
|       "version": "0.4.24", | ||||
|       "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", | ||||
|   | ||||
| @@ -12,8 +12,11 @@ | ||||
|     "debug": "~2.6.9", | ||||
|     "express": "^4.18.2", | ||||
|     "express-session": "^1.17.3", | ||||
|     "fs": "^0.0.1-security", | ||||
|     "hbs": "^4.2.0", | ||||
|     "http": "^0.0.1-security", | ||||
|     "http-errors": "~1.6.3", | ||||
|     "https": "^1.0.0", | ||||
|     "mongoose": "^7.3.1", | ||||
|     "morgan": "~1.9.1", | ||||
|     "multer": "^1.4.5-lts.1" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Nikola Petrov
					Nikola Petrov