Update index.js
This commit is contained in:
parent
18a3c01d44
commit
ac5c58cd62
@ -1,20 +1,23 @@
|
|||||||
var app = require('express')();
|
var express = require('express');
|
||||||
|
var app=express();
|
||||||
var http = require('http').Server(app);
|
var http = require('http').Server(app);
|
||||||
var io = require('socket.io')(http);
|
var io = require('socket.io')(http);
|
||||||
var socketioJwt = require('socketio-jwt');
|
var socketioJwt = require('socketio-jwt');
|
||||||
var auth0Variables = require('./auth0-variables');
|
var dotenv = require('dotenv');
|
||||||
|
|
||||||
app.get('/', function(req, res){
|
dotenv.load();
|
||||||
res.sendFile(__dirname + '/index.html');
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/auth0-variables.js', function(req, res){
|
var env = {
|
||||||
res.sendFile(__dirname + '/auth0-variables.js');
|
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
|
||||||
});
|
AUTH0_DOMAIN: process.env.AUTH0_DOMAIN,
|
||||||
|
}
|
||||||
|
|
||||||
|
app.set('views', __dirname + '/views')
|
||||||
|
app.set('view engine', 'jade');
|
||||||
|
|
||||||
io
|
io
|
||||||
.on('connection', socketioJwt.authorize({
|
.on('connection', socketioJwt.authorize({
|
||||||
secret: Buffer(auth0Variables.AUTH0_CLIENT_SECRET, 'base64'),
|
secret: Buffer(JSON.stringify(process.env.AUTH0_CLIENT_SECRET), 'base64'),
|
||||||
timeout: 15000 // 15 seconds to send the authentication message
|
timeout: 15000 // 15 seconds to send the authentication message
|
||||||
}))
|
}))
|
||||||
.on('authenticated', function(socket){
|
.on('authenticated', function(socket){
|
||||||
@ -25,6 +28,16 @@ io
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.use(express.static(__dirname + '/public'));
|
||||||
|
|
||||||
|
app.get('/', function (req, res) {
|
||||||
|
res.render('index',
|
||||||
|
{ env: env }
|
||||||
|
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
http.listen(3001, function(){
|
http.listen(3001, function(){
|
||||||
console.log('listening on *:3001');
|
console.log('listening on *:3001');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user