-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
58 lines (52 loc) · 1.4 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
57
58
/* global __dirname */
var express = require("express");
var http = require("http");
var cookieParser = require("cookie-parser");
var session = require("express-session");
var ejs = require("ejs");
var passport = require("passport");
var stylus = require('stylus');
var nib = require('nib');
var db = require("./db");
var port = 3000;
var app = express();
require("./config/passport")(passport);
function compile(str, path) {
console.log("Compiling stylus");
return stylus(str)
.set('filename', path)
.define('bg_color', "#0f0f38")
.define('fg_color', "#ebeff0")
.use(nib());
}
app.set('view engine', 'ejs');
app.use(cookieParser());
app.use(stylus.middleware(
{ src: __dirname + '/client/resources/'
, dest: __dirname + '/client/'
, compile: compile
, debug: true
, force: true
}
));
app.use(express.static(__dirname + "/client"));
app.use(session({secret: 'twitterLogin'}));
app.use(passport.initialize());
app.use(passport.session()); // persistent login sessions
app.use("/", require('./routes/index'));
app.use(/^\/todo.?/, require('./routes/todo'));
app.use(/^\/dashboard.?/, require('./routes/dashboard'));
app.use(/^\/profile.?/, require('./routes/profile'));
db.connect({
host: 'localhost',
user: 'root',
password: 'webdata',
database: 'todo'
}, function (err) {
if (err) {
console.log(err);
process.exit(1);
}
else
http.createServer(app).listen(port);
});