forked from jherrick/361-proj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
63 lines (52 loc) · 1.75 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
// CS61 Project
var express = require('express');
var app = express();
var handlebars = require('express-handlebars').create({defaultLayout:'main'});
var bodyParser = require('body-parser');
var mysql = require('./dbcon.js');
var session = require('express-session');
//var cookieParser = require('cookie-parser');
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');
app.set('mysql', mysql);
app.use(bodyParser.urlencoded({extended:true}));
app.use('/static', express.static('public'));
app.use('/', express.static('public'));
app.set('port', process.argv[2]);
app.use(express.static('views/images'));
// Routes & functions files
app.use(session({secret: 'SuperSecretPassword'}));
app.use('/view-listings', require('./view-listings.js'));
app.use('/tenant', require('./tenant.js'));
app.use('/landlord', require('./landlord.js'));
app.use('/listings', require('./listings.js'));
app.use('/login', require('./login.js'));
app.use('/manage_prof', require('./manage_prof.js'));
app.use('/manage_prop', require('./manage_prop.js'));
app.use('/register', require('./register.js'));
app.use('/saved_listings', require('./saved_listings.js'));
//app.us(cookieParser());
// Home Route
app.get('/', function(req, res){
res.render('home');
});
app.get('/about', function(req, res){
res.render('about');
});
app.get('/careers', function(req, res){
res.render('careers');
});
// ERROR ROUTES
app.use(function(req,res){
res.status(404);
res.render('404');
});
app.use(function(err, req, res, next){
console.error(err.stack);
res.status(500);
res.render('500');
});
// Server listen config
app.listen(app.get('port'), function(){
console.log('Express started on http://localhost:' + app.get('port') + '; press Ctrl-C to terminate.');
});