-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (41 loc) · 1.29 KB
/
index.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
var express = require('express');
var bodyParser = require("body-parser");
const sequelize =require('./config/config.json')
const cookieParser = require('cookie-parser');
const auth = require('./routes/auth');
const tweet =require('./routes/tweet')
const people =require('./routes/people')
const comment =require('./routes/comment')
var app = express();
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.text({ type: 'text/html' }));
app.use(bodyParser.json());
app.set('view engine', 'ejs');
app.use('/auth', auth);
app.use('/tweet',tweet);
app.use('/people',people);
app.use('/comment',comment)
app.get('/',(req, res, next) => {
const token = req.cookies.jwt;
if (token) {
res.render('home', { login_info:false });
}
else{
res.render('home', { login_info:true });
}
});
app.get('/*', (req, res, next) => {
res.send("page not found");
});
// sequelize.sync().then(
// result => {
// console.log("table created");
// }
// ).catch(err =>{
// console.log(err);
// })
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
});