Update index.js

This commit is contained in:
Annyv2 2015-12-01 15:33:06 -04:30
parent 18a3c01d44
commit ac5c58cd62

View File

@ -1,20 +1,23 @@
var app = require('express')();
var express = require('express');
var app=express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var socketioJwt = require('socketio-jwt');
var auth0Variables = require('./auth0-variables');
var dotenv = require('dotenv');
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
dotenv.load();
app.get('/auth0-variables.js', function(req, res){
res.sendFile(__dirname + '/auth0-variables.js');
});
var env = {
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
.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
}))
.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(){
console.log('listening on *:3001');
});