-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
68 lines (46 loc) · 1.72 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
const express = require('express');
const hbs = require('hbs');
const bodyParser = require('body-parser');
const validator = require('express-validator');
const session = require('express-session');
const app = express();
const appMiddleware = require('./middlewares/appMiddleware');
const index = require('./routes/index');
const projects = require('./routes/projects');
const admin = require('./routes/admin');
app.set('views',__dirname+'/views');
app.set('view engine', 'hbs');
app.set('view options', { layout: 'layout' });
hbs.registerPartials(__dirname+'/views/partials');
hbs.registerHelper("inc", function(value, options) {
return value+1;
})
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:false}));
app.use(session({
secret:'my secret',
resave:false,
saveUninitialized:false,
cookie:{maxAge:1000000}
}))
app.use(validator());
app.use(express.static(__dirname+'/static'))
app.use(appMiddleware.logger);
app.use(appMiddleware.authenticated);
app.use('/', index);
app.use('/projects', projects);
app.use('/admin', appMiddleware.authenticate, admin)
// app.get('/contact', routes.contact);
// app.get('/blogs', routes.blogList);
// app.get('/projects', routes.projectList);
// app.get('/project/:projectAlias', routes.projectDetail);
// app.get('/login', routes.login);
// app.post('/login', routes.doLogin);
// app.get('/signup', routes.signup);
// app.post('/signup', routes.doSignup);
// app.get('/dashboard', routes.dashboard);
// app.get('/admin/projects', routes.adminProjectList);
// app.get('/admin/projects/:alias', routes.adminProjectDetail);
app.use(appMiddleware.notFoundError);
app.use(appMiddleware.handleError);
app.listen(3000, () => console.log('Server started on port 3000'));