Commit d7cb259ea3602013ab8db0288801907b6566d1bc

Authored by Adabriand Furtado
1 parent 708b91df
Exists in master

Suporte a conexões HTTPS

Showing 1 changed file with 10 additions and 4 deletions   Show diff stats
@@ -5,12 +5,20 @@ var properties = require('./helpers/properties'); @@ -5,12 +5,20 @@ var properties = require('./helpers/properties');
5 var endpoint_sinal = require('./endpoints/sinal'); 5 var endpoint_sinal = require('./endpoints/sinal');
6 6
7 /* Environment */ 7 /* Environment */
  8 +var fs = require('fs');
  9 +var https = require('https');
8 var path = require('path'); 10 var path = require('path');
9 var express = require('express'); 11 var express = require('express');
10 var bodyParser = require('body-parser'); 12 var bodyParser = require('body-parser');
11 var PythonShell = require('python-shell'); 13 var PythonShell = require('python-shell');
  14 +
12 var app = express(); 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 var options = { 22 var options = {
15 pythonPath: 'python3', 23 pythonPath: 'python3',
16 scriptPath: __dirname + '/../wikilibras-core', 24 scriptPath: __dirname + '/../wikilibras-core',
@@ -23,12 +31,9 @@ require('./db/config').connect(mongoose); @@ -23,12 +31,9 @@ require('./db/config').connect(mongoose);
23 var Sign = require('./db/schemas/sinal').init(mongoose); 31 var Sign = require('./db/schemas/sinal').init(mongoose);
24 var API = require('./db/api'); 32 var API = require('./db/api');
25 var outputVideosDir = __dirname + '/../wikilibras-core/users/' 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 app.use("/public", express.static(outputVideosDir)); 35 app.use("/public", express.static(outputVideosDir));
30 36
31 -// deprecated: app.use(express.bodyParser({ keepExtensions: true }));  
32 app.use(express.urlencoded({ keepExtensions: true })) 37 app.use(express.urlencoded({ keepExtensions: true }))
33 app.use(express.json()) 38 app.use(express.json())
34 39
@@ -70,6 +75,7 @@ app.delete('/api/:hash', function(req, res) { @@ -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 console.log('Server running on ' + properties.HOST + ':' + properties.PORT); 80 console.log('Server running on ' + properties.HOST + ':' + properties.PORT);
75 }); 81 });
76 \ No newline at end of file 82 \ No newline at end of file