Commit d7cb259ea3602013ab8db0288801907b6566d1bc
1 parent
708b91df
Exists in
master
Suporte a conexões HTTPS
Showing
1 changed file
with
10 additions
and
4 deletions
Show diff stats
server.js
| ... | ... | @@ -5,12 +5,20 @@ var properties = require('./helpers/properties'); |
| 5 | 5 | var endpoint_sinal = require('./endpoints/sinal'); |
| 6 | 6 | |
| 7 | 7 | /* Environment */ |
| 8 | +var fs = require('fs'); | |
| 9 | +var https = require('https'); | |
| 8 | 10 | var path = require('path'); |
| 9 | 11 | var express = require('express'); |
| 10 | 12 | var bodyParser = require('body-parser'); |
| 11 | 13 | var PythonShell = require('python-shell'); |
| 14 | + | |
| 12 | 15 | var app = express(); |
| 13 | 16 | |
| 17 | +/* SSL configuration */ | |
| 18 | +var privateKey = fs.readFileSync('sslcert/server.key', 'utf8'); | |
| 19 | +var certificate = fs.readFileSync('sslcert/server.crt', 'utf8'); | |
| 20 | +var credentials = {key: privateKey, cert: certificate}; | |
| 21 | + | |
| 14 | 22 | var options = { |
| 15 | 23 | pythonPath: 'python3', |
| 16 | 24 | scriptPath: __dirname + '/../wikilibras-core', |
| ... | ... | @@ -23,12 +31,9 @@ require('./db/config').connect(mongoose); |
| 23 | 31 | var Sign = require('./db/schemas/sinal').init(mongoose); |
| 24 | 32 | var API = require('./db/api'); |
| 25 | 33 | var outputVideosDir = __dirname + '/../wikilibras-core/users/' |
| 26 | -// var outputVideosDir = '/home/wikilibras/wikilibras-core/users/' | |
| 27 | 34 | |
| 28 | -// app.use(express.static(path.join(__dirname, '/public'))); | |
| 29 | 35 | app.use("/public", express.static(outputVideosDir)); |
| 30 | 36 | |
| 31 | -// deprecated: app.use(express.bodyParser({ keepExtensions: true })); | |
| 32 | 37 | app.use(express.urlencoded({ keepExtensions: true })) |
| 33 | 38 | app.use(express.json()) |
| 34 | 39 | |
| ... | ... | @@ -70,6 +75,7 @@ app.delete('/api/:hash', function(req, res) { |
| 70 | 75 | }); |
| 71 | 76 | }); |
| 72 | 77 | |
| 73 | -app.listen(properties.PORT, properties.HOST, function() { | |
| 78 | +var httpsServer = https.createServer(credentials, app); | |
| 79 | +httpsServer.listen(properties.PORT, properties.HOST, function() { | |
| 74 | 80 | console.log('Server running on ' + properties.HOST + ':' + properties.PORT); |
| 75 | 81 | }); |
| 76 | 82 | \ No newline at end of file | ... | ... |