This repository was archived by the owner on Jan 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
116 lines (79 loc) · 2.62 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Generated by CoffeeScript 1.7.1
/*
Module dependencies.
*/
(function() {
var app, db, express, http, mongoose, passport, path, routes;
express = require('express');
routes = require('./routes');
http = require('http');
path = require('path');
mongoose = require('mongoose');
passport = require('./routes/user');
app = express();
mongoose.connect('mongodb://localhost/test');
db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
return console.log('DB connection opened');
});
app.set('layout', 'layouts/main');
app.set('partials', {
welcome: 'partials/welcome',
accountTemplates: 'partials/accountTemplates',
csv: 'partials/csv',
scripts: 'partials/scripts',
model: 'partials/model',
tutorial: 'partials/tutorial',
dashboard: 'partials/dashboard',
uploadCSV: 'partials/uploadCSV',
unzip: 'partials/unzip'
});
app.engine('html', require("hogan-express"));
app.enable('view cache');
app.configure(function() {
app.set("port", process.env.PORT || 3000);
app.set("views", __dirname + "/views");
app.set("view engine", "html");
app.use(express.favicon());
app.use(express.logger("dev"));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser('csci3601'));
app.use(express.session({
cookie: {
maxAge: 3600000
},
secret: 'csci3601'
}));
app.use(passport.initialize());
app.use(passport.session());
return app.use(app.router);
});
app.use(express["static"](path.join(__dirname, "public")));
app.use(express["static"](path.join(__dirname, 'bower_components')));
app.configure('development', function() {
return app.use(express.errorHandler());
});
app.get("/", routes.index);
app.get("/dash", routes.dash);
app.get("/model-maker", routes.modelMaker);
app.get("/failed", routes.failed);
app.get("/user", routes.user);
app.get("/login", routes.login);
app.get("/newUser", routes.newUser);
app.get("/logout", routes.logout);
app.get("/account", routes.account);
app.get('/getPrompts', routes.getPromptArray);
app.post('/create', routes.create);
app.post('/updatePassword', routes.updatePassword);
app.post('/addPrompt', routes.addPrompt);
app.post('/', passport.authenticate('local-login', {
failureRedirect: '/failed',
successRedirect: '/dash'
}));
http.createServer(app).listen(app.get("port"), function() {
return console.log("Express server listening on port " + app.get("port"));
});
}).call(this);