-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
36 lines (26 loc) · 855 Bytes
/
server.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
var express = require("express");
var mongodb = require('mongodb');
var parser = require("body-parser");
var path = require('path');
var app = express();
global.appRoot = path.resolve(__dirname);
var dialogs = require("./server/routes/dialogs.js");
var mongo = mongodb.MongoClient;
//Set view engine
app.set('view engine', 'pug');
app.set('views', __dirname + '/client/');
app.set('view options', {
layout: false
});
//Set statically served root.
app.use(express.static(__dirname + "/client"));
app.use(parser.urlencoded({extended : true}));
app.use(parser.json());
app.use('/dialogs', dialogs);
app.get('/', function(req,res){
res.render('index');
});
//Listen for connections.
app.listen(process.env.PORT || 8080, function(){
console.log("Express server listening on port %d in %s mode", this.address().port, app.settings.env);
});