-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
133 lines (117 loc) · 4.94 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var product_add_form = require('./routes/product_add_form');
var product_add = require('./routes/product_add');
var product_list = require('./routes/product_list');
var product_one = require('./routes/product_one');
var product_update_form = require('./routes/product_update_form');
var product_update = require('./routes/product_update');
var product_remove = require('./routes/product_remove');
var like_add = require('./routes/like_add');
var like_remove = require('./routes/like_remove');
var comment_add = require('./routes/comment_add');
var reply_add = require('./routes/reply_add');
var shoppingCart = require('./routes/shoppingCart');
var shoppingCart_add = require('./routes/shoppingCart_add');
var shoppingCart_remove = require('./routes/shoppingCart_remove');
var shoppingCart_confirm = require('./routes/shoppingCart_confirm');
var order_add = require('./routes/order_add');
var order_remove = require('./routes/order_remove');
var order_update = require('./routes/order_update');
var buyer_list = require('./routes/buyer_list');
var seller_list = require('./routes/seller_list');
var order_show_form = require('./routes/order_show');
var login_form = require('./routes/login_form');
var login = require('./routes/login');
var logout = require('./routes/logout');
var login_show = require('./routes/login_show');
var register = require('./routes/register');
var register_form = require('./routes/register_form');
var checkAuth = require('./routes/checkAuth');
var member_edit_form = require('./routes/member_edit_form');
var member_edit = require('./routes/member_edit');
var member_report = require('./routes/member_report');
var member_report_add = require('./routes/member_report_add');
var member_one = require('./routes/member_one');
var feedback = require('./routes/feedback')
var feedback_add = require('./routes/feedback_add')
var terms_and_privacy = require('./routes/terms_and_privacy')
//var shoppingCart = require('./routes/shoppingCart');
//------------------------------------------------------------
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
var session = require('express-session');
app.use(session({secret: 'MinecraftBruhMoment', cookie: { maxAge: 60*60*1000 },saveUninitialized: false,resave: false}));
app.use(function(req, res, next) {
res.locals.user = req.session.user;
res.locals.username = req.session.username;
res.locals.userpic = req.session.userpic;
res.locals.shoppingCart = req.session.shoppingCart;
next();
});
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
app.use('/users', usersRouter);
app.use('/product/add/form', product_add_form);
app.use('/product/add', product_add);
app.use('/product/list', product_list);
app.use('/product/page', product_list);
app.use('/product/edit/form', product_update_form);
app.use('/product/edit', product_update);
app.use('/product/remove', product_remove);
app.use('/product/', product_one);
app.use('/like/add', like_add);
app.use('/like/remove', like_remove);
app.use('/comment', comment_add);
app.use('/reply', reply_add);
app.use('/shoppingCart/add', shoppingCart_add);
app.use('/shoppingCart/remove', shoppingCart_remove);
app.use('/shoppingCart/confirm', shoppingCart_confirm);
app.use('/shoppingCart', shoppingCart);
app.use('/login', login_form);
app.use('/user/login', login);
app.use('/logout', logout);
app.use('/user/login_show', login_show);
app.use('/register', register_form);
app.use('/user/register', register)
app.use('/order/add', order_add);
app.use('/order/remove', order_remove);
app.use('/order/update', order_update);
app.use('/buyer/list', buyer_list);
app.use('/seller/list', seller_list);
app.use('/order/show/form', order_show_form);
app.use('/member/edit/form', member_edit_form);
app.use('/member/edit', member_edit);
app.use('/member/report', member_report);
app.use('/member/report/add', member_report_add);
app.use('/member', member_one);
app.use('/feedback', feedback);
app.use('/feedback/add', feedback_add);
app.use('/terms_and_privacy', terms_and_privacy);
app.use(express.static('public/picture'));
app.use('/scripts', express.static(__dirname + '/node_modules'));
// catch 404 and forward to error handler
app.use(function(req, res, next) {
next(createError(404));
});
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
module.exports = app;