신일섭

플랫폼을 Line으로 설정

Showing 1 changed file with 73 additions and 0 deletions
1 +var express = require('express');
2 +var path = require('path');
3 +var favicon = require('serve-favicon');
4 +//var logger = require('morgan');
5 +var cookieParser = require('cookie-parser');
6 +var bodyParser = require('body-parser');
7 +var mysql = require('mysql');
8 +var request = require('request');
9 +//var index = require('./routes/index');
10 +//var users = require('./routes/users');
11 +//var mytoons = require('./routes/mytoons');
12 +//var yourtoons=require('./routes/yourtoons');
13 +var passport = require('passport');
14 +//var setting = require('./routes/setting');
15 +var session = require('express-session');
16 +//port
17 +/*passport.serializeUser(function(user, done) {
18 + console.log('serialized');
19 + done(null, user);
20 +});
21 +passport.deserializeUser(function(user, done) {
22 + console.log('deserialized');
23 + done(null, user);
24 +});
25 +*/
26 +var app = express();
27 +// view engine setup
28 +app.set('views', path.join(__dirname, 'views'));
29 +app.set('view engine', 'ejs');
30 +// uncomment after placing your favicon in /public
31 +//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
32 +app.use(logger('dev'));
33 +app.use(bodyParser.json());
34 +app.use(bodyParser.urlencoded({ extended: false }));
35 +app.use(cookieParser());
36 +app.use(express.static(path.join(__dirname, 'public')));
37 +connection = mysql.createConnection({
38 + host : 'localhost',
39 + user : 'root',
40 + password : 'password',
41 + port : 3306,
42 + database : 'Shoppingcart'
43 +});
44 +app.use(session({
45 + secret: 'secrettexthere',
46 + saveUninitialized: true,
47 + resave: true
48 +}));
49 +app.use(passport.initialize());
50 +app.use(passport.session());
51 +app.use('/', index);
52 +app.use('/users', users);
53 +app.use('/mytoons', mytoons);
54 +app.use('/setting', setting);
55 +app.use('/yourtoons', yourtoons);
56 +//app.use(express.static('views'));
57 +// catch 404 and forward to error handler
58 +app.use(function(req, res, next) {
59 + var err = new Error('Not Found');
60 + err.status = 404;
61 + next(err);
62 +});
63 +// error handler
64 +app.use(function(err, req, res, next) {
65 + // set locals, only providing error in development
66 + res.locals.message = err.message;
67 + res.locals.error = req.app.get('env') === 'development' ? err : {};
68 + // render the error page
69 + res.status(err.status || 500);
70 + res.render('error');
71 +});
72 +var server = app.listen(3000);
73 +module.exports = app;
...\ No newline at end of file ...\ No newline at end of file