-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
56 lines (39 loc) · 1.04 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var express = require("express");
var passport = require("./auth.js");
var passportLocal = require("passport-local");
var app = express();
var io = require("socket.io");
var http = require('http').Server(app);
var io = require('socket.io')(http);
//routes
var routes = require("./routes.js");
//sockets function
var addSockets = require("./socketEvents.js");
//utilities
var bodyParser = require("body-parser");
var cookieParser = require("cookie-parser");
var expressSession = require("express-session");
//actual variables
//holds current socket ids used by usernames required in routes and socketEvents
user2Sock = {};
sock2User = {};
app.set("view engine","ejs");
//use utilities
app.use(bodyParser.urlencoded({
extended:false
}));
app.use(cookieParser());
app.use(expressSession({
secret:"secret key",
resave:false,
saveUninitialized:false
}));
app.use(passport.initialize());
app.use(passport.session());
//routes
routes(app,passport,io);
//add socket events
addSockets(io);
http.listen(3000,function(){
console.log("listenning");
})