이승윤

refector: 코드 리펙토링

...@@ -4,16 +4,19 @@ var port = 3000; ...@@ -4,16 +4,19 @@ var port = 3000;
4 4
5 var mongoose = require('mongoose'); 5 var mongoose = require('mongoose');
6 mongoose.Promise = global.Promise; 6 mongoose.Promise = global.Promise;
7 +
7 //auto-increment를 위한 패키지 8 //auto-increment를 위한 패키지
8 var path = require('path'); 9 var path = require('path');
9 var logger = require('morgan'); 10 var logger = require('morgan');
10 var bodyParser = require('body-parser'); 11 var bodyParser = require('body-parser');
11 var cookieParser = require('cookie-parser'); 12 var cookieParser = require('cookie-parser');
12 var flash = require('connect-flash'); 13 var flash = require('connect-flash');
14 +
13 //passport 로그인 관련 15 //passport 로그인 관련
14 var passport = require('passport'); 16 var passport = require('passport');
15 var session = require('express-session'); 17 var session = require('express-session');
16 18
19 +//mongodb 연동
17 var db = mongoose.connection; 20 var db = mongoose.connection;
18 db.on('error', console.error); 21 db.on('error', console.error);
19 db.once('open', function () { 22 db.once('open', function () {
...@@ -39,6 +42,7 @@ app.use(bodyParser.urlencoded({ extended: false })); ...@@ -39,6 +42,7 @@ app.use(bodyParser.urlencoded({ extended: false }));
39 app.use(cookieParser()); 42 app.use(cookieParser());
40 app.use('/uploads', express.static('uploads')); 43 app.use('/uploads', express.static('uploads'));
41 44
45 +// MiddleWare 지정
42 var sessionMiddleWare = session({ 46 var sessionMiddleWare = session({
43 secret: 'fastcampus', 47 secret: 'fastcampus',
44 resave: false, 48 resave: false,
...@@ -67,7 +71,7 @@ app.use(function (req, res, next) { ...@@ -67,7 +71,7 @@ app.use(function (req, res, next) {
67 next(); 71 next();
68 }); 72 });
69 73
70 -//routes add 74 +//routes
71 app.use('/', Video); 75 app.use('/', Video);
72 app.use('/categori', categori); 76 app.use('/categori', categori);
73 app.use('/accounts', accounts); 77 app.use('/accounts', accounts);
......
...@@ -2,7 +2,6 @@ var express = require('express'); ...@@ -2,7 +2,6 @@ var express = require('express');
2 var router = express.Router(); 2 var router = express.Router();
3 var UserModel = require('../models/UserModel'); 3 var UserModel = require('../models/UserModel');
4 var passport = require('passport'); 4 var passport = require('passport');
5 -var FacebookStrategy = require('passport-facebook').Strategy;
6 const GoogleStrategy = require('passport-google-oauth20').Strategy; 5 const GoogleStrategy = require('passport-google-oauth20').Strategy;
7 6
8 passport.serializeUser(function (user, done) { 7 passport.serializeUser(function (user, done) {
...@@ -49,10 +48,9 @@ passport.use( ...@@ -49,10 +48,9 @@ passport.use(
49 ) 48 )
50 ); 49 );
51 50
52 -// http://localhost:3000/auth/facebook 접근시 facebook으로 넘길 url 작성해줌
53 router.get('/google', passport.authenticate('google', { scope: ['profile'] })); 51 router.get('/google', passport.authenticate('google', { scope: ['profile'] }));
54 52
55 -//인증후 페이스북에서 이 주소로 리턴해줌. 상단에 적은 callbackURL과 일치 53 +//인증후 구글에서 이 주소로 리턴해줌. 상단에 적은 callbackURL과 일치
56 router.get( 54 router.get(
57 '/google/callback', 55 '/google/callback',
58 passport.authenticate('google', { 56 passport.authenticate('google', {
......
...@@ -107,26 +107,6 @@ ...@@ -107,26 +107,6 @@
107 </script> 107 </script>
108 108
109 <script> 109 <script>
110 -$(document).on('click' , '.comment_delete' , function(){
111 - if(confirm('삭제하시겠습니까?')){ //확인창 예 눌렀을 시만 진행
112 - var $self = $(this);
113 - $.ajax({
114 - url: '/admin/products/ajax_comment/delete',
115 - type: 'POST',
116 - data: { comment_id : $self.attr('comment_id') },
117 - })
118 - .done(function() {
119 - $self.parent().remove();
120 - alert("삭제가 완료되었습니다.");
121 - })
122 - .fail(function(args) {
123 - console.log(args);
124 - });
125 - }
126 -});
127 -</script>
128 -
129 -<script>
130 var tag = document.createElement('script'); 110 var tag = document.createElement('script');
131 111
132 tag.src = "https://www.youtube.com/iframe_api"; 112 tag.src = "https://www.youtube.com/iframe_api";
......