-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
92 lines (74 loc) · 2.07 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
var express = require('express');
var testApp = express();
var sql = require('mssql');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var passport = require('passport');
var expressSession = require('express-session');
//var message = "hello Brackets";
//
//if (true) {
// console.log(message);
//} else {
// console.log("hi");
//}
var portToListen = process.env.PORT || 3000;
var sqlConfig = {
user: 'books',
password: 'pluralsight1@',
server: 'gpnju6fwr2.database.windows.net',
database: 'Books',
options: {
encrypt: true
}
}
var list = ['a', 'b', 'c', 'd', 'e'];
var navBarItems = [{
link: "/Books",
linkText: "Book"
}, {
link: "/Authors",
linkText: "Author"
},{
link: "/AddBooks",
linkText: "Add Books"
}];
testApp.use(express.static('public'));
//testApp.use(express.static('src/views'));
testApp.set('views', './src/views');
//testApp.set('view engine', 'jade');
//var handleBars = require('express-handlebars');
//
//testApp.engine('.hbs', handleBars({
// extname: '.hbs'
//}));
//
//testApp.set('view engine', '.hbs');
testApp.set('view engine', 'ejs');
//sql.connect(sqlConfig, function (err) {
// console.log(err);
//});
//not using sql as of now
testApp.use(bodyParser.json()) // support json encoded bodies
testApp.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies
testApp.use(cookieParser());
testApp.use(expressSession({secret: 'library'}));
require('./src/config/passportAuth')(testApp);
var bookRouter = require('./src/routes/bookRoutes')(navBarItems);
testApp.use('/Books', bookRouter);
var addBookRouter = require('./src/routes/addBookRoutes')(navBarItems);
testApp.use('/AddBooks', addBookRouter);
var authenticationRouter = require('./src/routes/authentication')(navBarItems);
testApp.use('/auth', authenticationRouter);
testApp.get('/', function (req, res) {
res.render('index', {
nav: navBarItems
});
});
testApp.listen(portToListen, function (err) {
if (err) {
console.log('failed to listen on port ' + portToListen);
} else {
console.log('running on port ' + portToListen);
}
});