-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (31 loc) · 1.1 KB
/
index.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
const dotenv = require('dotenv');
dotenv.config();
const http = require("http");
const express = require("express");
var session = require('express-session')
const ehb = require("express-handlebars");
var bodyParser = require('body-parser');
const app = express();
const port = process.env.PORT || 3000;
const passport = require("passport");
//Database Configuration
const mongo = require("mongodb");
var path = require('path');
//Initial Setup
app.use(express.static(path.join(__dirname, "views")));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(session({"secret": "keyboard cat"}));
app.use(passport.initialize());
app.use(passport.session());
app.engine('handlebars', ehb());
app.set('view engine', 'handlebars');
//Setup Database
var schemas = require(path.resolve( __dirname, "./schema.js"));
//Socket.io
const server = http.createServer(app);
var ioHandler = require(path.resolve( __dirname, "./io.js"));
ioHandler(server, schemas);
//Routes
var routes = require(path.resolve( __dirname, "./routes/route.js"))(app, schemas, mongo, ioHandler);
server.listen(port);