강현태

DB 동기화 완료

...@@ -35,49 +35,56 @@ ...@@ -35,49 +35,56 @@
35 <DataType>text|0</DataType> 35 <DataType>text|0</DataType>
36 <NotNull>1</NotNull> 36 <NotNull>1</NotNull>
37 </column> 37 </column>
38 - <key id="12" parent="4" name="PRIMARY"> 38 + <column id="12" parent="4" name="latest">
39 + <Position>6</Position>
40 + <DataType>int(11)|0</DataType>
41 + <NotNull>1</NotNull>
42 + <DefaultExpression>&apos;0&apos;</DefaultExpression>
43 + </column>
44 + <key id="13" parent="4" name="PRIMARY">
39 <NameSurrogate>1</NameSurrogate> 45 <NameSurrogate>1</NameSurrogate>
40 <ColNames>toon_index</ColNames> 46 <ColNames>toon_index</ColNames>
41 <Primary>1</Primary> 47 <Primary>1</Primary>
42 </key> 48 </key>
43 - <column id="13" parent="5" name="id"> 49 + <column id="14" parent="5" name="id">
44 <Position>1</Position> 50 <Position>1</Position>
45 <DataType>bigint(20)|0</DataType> 51 <DataType>bigint(20)|0</DataType>
46 <NotNull>1</NotNull> 52 <NotNull>1</NotNull>
47 </column> 53 </column>
48 - <key id="14" parent="5" name="PRIMARY"> 54 + <key id="15" parent="5" name="PRIMARY">
49 <NameSurrogate>1</NameSurrogate> 55 <NameSurrogate>1</NameSurrogate>
50 <ColNames>id</ColNames> 56 <ColNames>id</ColNames>
51 <Primary>1</Primary> 57 <Primary>1</Primary>
52 </key> 58 </key>
53 - <column id="15" parent="6" name="user_id"> 59 + <column id="16" parent="6" name="user_id">
54 <Position>1</Position> 60 <Position>1</Position>
55 <DataType>bigint(20)|0</DataType> 61 <DataType>bigint(20)|0</DataType>
56 <NotNull>1</NotNull> 62 <NotNull>1</NotNull>
57 </column> 63 </column>
58 - <column id="16" parent="6" name="toon_index"> 64 + <column id="17" parent="6" name="toon_index">
59 <Position>2</Position> 65 <Position>2</Position>
60 <DataType>int(11)|0</DataType> 66 <DataType>int(11)|0</DataType>
61 <NotNull>1</NotNull> 67 <NotNull>1</NotNull>
62 </column> 68 </column>
63 - <column id="17" parent="6" name="recent"> 69 + <column id="18" parent="6" name="last">
64 <Position>3</Position> 70 <Position>3</Position>
65 - <DataType>text|0</DataType> 71 + <DataType>int(11)|0</DataType>
66 <NotNull>1</NotNull> 72 <NotNull>1</NotNull>
73 + <DefaultExpression>&apos;0&apos;</DefaultExpression>
67 </column> 74 </column>
68 - <index id="18" parent="6" name="toon_index"> 75 + <index id="19" parent="6" name="toon_index">
69 <ColNames>toon_index</ColNames> 76 <ColNames>toon_index</ColNames>
70 </index> 77 </index>
71 - <index id="19" parent="6" name="user_id"> 78 + <index id="20" parent="6" name="user_id">
72 <ColNames>user_id</ColNames> 79 <ColNames>user_id</ColNames>
73 </index> 80 </index>
74 - <foreign-key id="20" parent="6" name="user_toon_relation_ibfk_1"> 81 + <foreign-key id="21" parent="6" name="user_toon_relation_ibfk_1">
75 <ColNames>user_id</ColNames> 82 <ColNames>user_id</ColNames>
76 <RefSchemaName>YTMT</RefSchemaName> 83 <RefSchemaName>YTMT</RefSchemaName>
77 <RefTableName>user</RefTableName> 84 <RefTableName>user</RefTableName>
78 <RefColNames>id</RefColNames> 85 <RefColNames>id</RefColNames>
79 </foreign-key> 86 </foreign-key>
80 - <foreign-key id="21" parent="6" name="user_toon_relation_ibfk_2"> 87 + <foreign-key id="22" parent="6" name="user_toon_relation_ibfk_2">
81 <ColNames>toon_index</ColNames> 88 <ColNames>toon_index</ColNames>
82 <RefSchemaName>YTMT</RefSchemaName> 89 <RefSchemaName>YTMT</RefSchemaName>
83 <RefTableName>toon</RefTableName> 90 <RefTableName>toon</RefTableName>
......
This diff is collapsed. Click to expand it.
...@@ -16,12 +16,12 @@ var setting = require('./routes/setting'); ...@@ -16,12 +16,12 @@ var setting = require('./routes/setting');
16 var session = require('express-session'); 16 var session = require('express-session');
17 17
18 passport.serializeUser(function(user, done) { 18 passport.serializeUser(function(user, done) {
19 - console.log('serialize'); 19 + console.log('serialized');
20 done(null, user); 20 done(null, user);
21 }); 21 });
22 -passport.deserializeUser(function(obj, done) { 22 +passport.deserializeUser(function(user, done) {
23 - console.log('deserialize'); 23 + console.log('deserialized');
24 - done(null, obj); 24 + done(null, user);
25 }); 25 });
26 26
27 var app = express(); 27 var app = express();
......
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
2 "_args": [ 2 "_args": [
3 [ 3 [
4 { 4 {
5 - "raw": "async@^2.0.1", 5 + "raw": "async",
6 "scope": null, 6 "scope": null,
7 "escapedName": "async", 7 "escapedName": "async",
8 "name": "async", 8 "name": "async",
9 - "rawSpec": "^2.0.1", 9 + "rawSpec": "",
10 - "spec": ">=2.0.1 <3.0.0", 10 + "spec": "latest",
11 - "type": "range" 11 + "type": "tag"
12 }, 12 },
13 - "/Users/kanghyeontae/IdeaProjects/YTMT/node_modules/form-data" 13 + "/Users/kanghyeontae/IdeaProjects/YTMT"
14 ] 14 ]
15 ], 15 ],
16 - "_from": "async@>=2.0.1 <3.0.0", 16 + "_from": "async@latest",
17 "_id": "async@2.6.0", 17 "_id": "async@2.6.0",
18 "_inCache": true, 18 "_inCache": true,
19 "_location": "/async", 19 "_location": "/async",
...@@ -29,22 +29,24 @@ ...@@ -29,22 +29,24 @@
29 "_npmVersion": "5.5.1", 29 "_npmVersion": "5.5.1",
30 "_phantomChildren": {}, 30 "_phantomChildren": {},
31 "_requested": { 31 "_requested": {
32 - "raw": "async@^2.0.1", 32 + "raw": "async",
33 "scope": null, 33 "scope": null,
34 "escapedName": "async", 34 "escapedName": "async",
35 "name": "async", 35 "name": "async",
36 - "rawSpec": "^2.0.1", 36 + "rawSpec": "",
37 - "spec": ">=2.0.1 <3.0.0", 37 + "spec": "latest",
38 - "type": "range" 38 + "type": "tag"
39 }, 39 },
40 "_requiredBy": [ 40 "_requiredBy": [
41 - "/form-data" 41 + "#USER",
42 + "/",
43 + "/phantomjs/form-data"
42 ], 44 ],
43 "_resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", 45 "_resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz",
44 "_shasum": "61a29abb6fcc026fea77e56d1c6ec53a795951f4", 46 "_shasum": "61a29abb6fcc026fea77e56d1c6ec53a795951f4",
45 "_shrinkwrap": null, 47 "_shrinkwrap": null,
46 - "_spec": "async@^2.0.1", 48 + "_spec": "async",
47 - "_where": "/Users/kanghyeontae/IdeaProjects/YTMT/node_modules/form-data", 49 + "_where": "/Users/kanghyeontae/IdeaProjects/YTMT",
48 "author": { 50 "author": {
49 "name": "Caolan McMahon" 51 "name": "Caolan McMahon"
50 }, 52 },
......
1 -0 info it worked if it ends with ok
2 -1 verbose cli [ '/usr/local/bin/node',
3 -1 verbose cli '/usr/local/bin/npm',
4 -1 verbose cli 'install',
5 -1 verbose cli 'cookieSession',
6 -1 verbose cli '--save' ]
7 -2 info using npm@3.10.10
8 -3 info using node@v6.11.4
9 -4 silly loadCurrentTree Starting
10 -5 silly install loadCurrentTree
11 -6 silly install readLocalPackageData
12 -7 silly fetchPackageMetaData cookieSession
13 -8 silly fetchNamedPackageData cookieSession
14 -9 silly mapToRegistry name cookieSession
15 -10 silly mapToRegistry using default registry
16 -11 silly mapToRegistry registry https://registry.npmjs.org/
17 -12 silly mapToRegistry data Result {
18 -12 silly mapToRegistry raw: 'cookieSession',
19 -12 silly mapToRegistry scope: null,
20 -12 silly mapToRegistry escapedName: 'cookieSession',
21 -12 silly mapToRegistry name: 'cookieSession',
22 -12 silly mapToRegistry rawSpec: '',
23 -12 silly mapToRegistry spec: 'latest',
24 -12 silly mapToRegistry type: 'tag' }
25 -13 silly mapToRegistry uri https://registry.npmjs.org/cookieSession
26 -14 verbose request uri https://registry.npmjs.org/cookieSession
27 -15 verbose request no auth needed
28 -16 info attempt registry request try #1 at 10:46:34 PM
29 -17 verbose request id 6a301e79ad3ee39e
30 -18 http request GET https://registry.npmjs.org/cookieSession
31 -19 http 404 https://registry.npmjs.org/cookieSession
32 -20 verbose headers { 'content-type': 'application/json',
33 -20 verbose headers 'cache-control': 'max-age=0',
34 -20 verbose headers 'content-length': '2',
35 -20 verbose headers 'accept-ranges': 'bytes',
36 -20 verbose headers date: 'Tue, 05 Dec 2017 13:46:36 GMT',
37 -20 verbose headers via: '1.1 varnish',
38 -20 verbose headers connection: 'keep-alive',
39 -20 verbose headers 'x-served-by': 'cache-nrt6151-NRT',
40 -20 verbose headers 'x-cache': 'MISS',
41 -20 verbose headers 'x-cache-hits': '0',
42 -20 verbose headers 'x-timer': 'S1512481595.892739,VS0,VE1380',
43 -20 verbose headers vary: 'Accept-Encoding' }
44 -21 silly get cb [ 404,
45 -21 silly get { 'content-type': 'application/json',
46 -21 silly get 'cache-control': 'max-age=0',
47 -21 silly get 'content-length': '2',
48 -21 silly get 'accept-ranges': 'bytes',
49 -21 silly get date: 'Tue, 05 Dec 2017 13:46:36 GMT',
50 -21 silly get via: '1.1 varnish',
51 -21 silly get connection: 'keep-alive',
52 -21 silly get 'x-served-by': 'cache-nrt6151-NRT',
53 -21 silly get 'x-cache': 'MISS',
54 -21 silly get 'x-cache-hits': '0',
55 -21 silly get 'x-timer': 'S1512481595.892739,VS0,VE1380',
56 -21 silly get vary: 'Accept-Encoding' } ]
57 -22 silly fetchPackageMetaData Error: Registry returned 404 for GET on https://registry.npmjs.org/cookieSession
58 -22 silly fetchPackageMetaData at makeError (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:302:12)
59 -22 silly fetchPackageMetaData at CachingRegistryClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:280:14)
60 -22 silly fetchPackageMetaData at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:210:14)
61 -22 silly fetchPackageMetaData at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:187:22)
62 -22 silly fetchPackageMetaData at emitTwo (events.js:106:13)
63 -22 silly fetchPackageMetaData at Request.emit (events.js:191:7)
64 -22 silly fetchPackageMetaData at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1048:10)
65 -22 silly fetchPackageMetaData at emitOne (events.js:96:13)
66 -22 silly fetchPackageMetaData at Request.emit (events.js:188:7)
67 -22 silly fetchPackageMetaData at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:969:12)
68 -22 silly fetchPackageMetaData error for cookieSession { Error: Registry returned 404 for GET on https://registry.npmjs.org/cookieSession
69 -22 silly fetchPackageMetaData at makeError (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:302:12)
70 -22 silly fetchPackageMetaData at CachingRegistryClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:280:14)
71 -22 silly fetchPackageMetaData at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:210:14)
72 -22 silly fetchPackageMetaData at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:187:22)
73 -22 silly fetchPackageMetaData at emitTwo (events.js:106:13)
74 -22 silly fetchPackageMetaData at Request.emit (events.js:191:7)
75 -22 silly fetchPackageMetaData at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1048:10)
76 -22 silly fetchPackageMetaData at emitOne (events.js:96:13)
77 -22 silly fetchPackageMetaData at Request.emit (events.js:188:7)
78 -22 silly fetchPackageMetaData at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:969:12) pkgid: 'cookieSession', statusCode: 404, code: 'E404' }
79 -23 silly rollbackFailedOptional Starting
80 -24 silly rollbackFailedOptional Finishing
81 -25 silly runTopLevelLifecycles Finishing
82 -26 silly install printInstalled
83 -27 verbose stack Error: Registry returned 404 for GET on https://registry.npmjs.org/cookieSession
84 -27 verbose stack at makeError (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:302:12)
85 -27 verbose stack at CachingRegistryClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:280:14)
86 -27 verbose stack at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:210:14)
87 -27 verbose stack at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:187:22)
88 -27 verbose stack at emitTwo (events.js:106:13)
89 -27 verbose stack at Request.emit (events.js:191:7)
90 -27 verbose stack at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1048:10)
91 -27 verbose stack at emitOne (events.js:96:13)
92 -27 verbose stack at Request.emit (events.js:188:7)
93 -27 verbose stack at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:969:12)
94 -28 verbose statusCode 404
95 -29 verbose pkgid cookieSession
96 -30 verbose cwd /Users/kanghyeontae/IdeaProjects/YTMT
97 -31 error Darwin 17.2.0
98 -32 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "cookieSession" "--save"
99 -33 error node v6.11.4
100 -34 error npm v3.10.10
101 -35 error code E404
102 -36 error 404 Registry returned 404 for GET on https://registry.npmjs.org/cookieSession
103 -37 error 404
104 -38 error 404 'cookieSession' is not in the npm registry.
105 -39 error 404 Your package name is not valid, because
106 -40 error 404 1. name can no longer contain capital letters
107 -41 error 404 Note that you can also install from a
108 -42 error 404 tarball, folder, http url, or git url.
109 -43 verbose exit [ 1, true ]
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
6 "start": "node ./bin/www" 6 "start": "node ./bin/www"
7 }, 7 },
8 "dependencies": { 8 "dependencies": {
9 + "async": "^2.6.0",
9 "bcrypt-nodejs": "0.0.3", 10 "bcrypt-nodejs": "0.0.3",
10 "body-parser": "~1.18.2", 11 "body-parser": "~1.18.2",
11 "casperjs": "^1.1.4", 12 "casperjs": "^1.1.4",
......
...@@ -17,8 +17,8 @@ passport.use(new KakaoStrategy({ ...@@ -17,8 +17,8 @@ passport.use(new KakaoStrategy({
17 17
18 console.log("(!)로그인 : " + profile._json.id+"("+profile._json.properties.nickname +")"); 18 console.log("(!)로그인 : " + profile._json.id+"("+profile._json.properties.nickname +")");
19 return done(null, { 19 return done(null, {
20 - 'user_id': profile.auth_id, 20 + 'user_id': profile._json.id,
21 - 'nickname': profile.auth_name 21 + 'nickname': profile._json.properties.nickname
22 }); 22 });
23 } 23 }
24 )); 24 ));
......
1 var express = require('express'); 1 var express = require('express');
2 var cheerio = require('cheerio'); 2 var cheerio = require('cheerio');
3 var request = require('request'); 3 var request = require('request');
4 +var async = require('async');
4 var router = express.Router(); 5 var router = express.Router();
5 6
6 -updatedToons = getUpdatedToons(); 7 +function getUpdatedToons(cb){
7 -function getUpdatedToons(){
8 var allToons = new Array(); 8 var allToons = new Array();
9 var allToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn"; 9 var allToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn";
10 request(allToonsUrl, function(err, res, html){ 10 request(allToonsUrl, function(err, res, html){
11 if(!err){ 11 if(!err){
12 var $ = cheerio.load(html); 12 var $ = cheerio.load(html);
13 - 13 + var p = Promise.resolve();
14 - $(".thumb").has('.ico_updt').next().each(function() { 14 + var eachs = $(".thumb").has('.ico_updt').next().each(function() {
15 + p = p.then(function() {
15 var link = $(this); 16 var link = $(this);
16 var toonName = link.text(); 17 var toonName = link.text();
17 var toonHref = link.attr('href'); 18 var toonHref = link.attr('href');
18 19
19 - allToons[toonName]=toonHref; 20 + allToons[toonName] = toonHref;
20 //connection.query(""); 21 //connection.query("");
21 -
22 }); 22 });
23 + });
24 + p.then(function(){
25 + cb(allToons);
26 + });
27 + }else{
28 + console.log("업데이트 웹툰 못가져왔습니다.");
29 + throw err;
23 } 30 }
24 }); 31 });
25 - return allToons;
26 } 32 }
27 33
28 -function getMyToons(id){ 34 +function getMyToons(id,cb){
29 - var sql = ""; 35 + var sqlquery = 'SELECT name, thum_link, webtoon_link, week, last FROM user u, user_toon_relation ur, toon t WHERE u.id=? && u.id=ur.user_id && t.toon_index=ur.toon_index;';
30 - connection.query('SELECT * FROM user u, user_toon_relation ur WHERE u.id=ur.user_id && id=?;'); 36 + var mylist;
31 - 37 + connection.query(sqlquery,id,function(err,rows,result){
38 + if(!err){
39 + mylist=rows;
40 + cb(mylist);
41 + }else{
42 + console.log("내 웹툰 리스트 가져오는데 실패했습니다!");
43 + throw err;
44 + }
45 + });
32 } 46 }
33 47
48 +
34 /* GET home page. */ 49 /* GET home page. */
35 router.get('/', function(req, res, next) { 50 router.get('/', function(req, res, next) {
36 - res.render('mytoons',{ 51 + async.series(
37 - list : updatedToons 52 + [
53 + function(callback){
54 + getMyToons(req.user.user_id, function (mytoon_list) {
55 + callback(null,mytoon_list);
38 }); 56 });
57 + },
58 + function(callback){
59 + getUpdatedToons(function (updated_list) {
60 + callback(null,updated_list);
61 + });
62 + }
63 + ],
64 + function(err, results){
65 + console.log(results);
66 + res.render('mytoons', {
67 + mytoons: results[0],
68 + updatedtoons: results[1]
69 + });
70 + }
71 + );
72 +
73 +
74 +
75 +
76 +
39 }); 77 });
40 78
41 module.exports = router; 79 module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
26 <% } %> 26 <% } %>
27 <td> 27 <td>
28 <a href="<%= A.webtoon_link %>"> 28 <a href="<%= A.webtoon_link %>">
29 - <img src="<%= A.thum_link %>"/> 29 + <img alt="img" width="83" height="90" src="<%= A.thum_link %>"/>
30 </a> 30 </a>
31 <%= A.name %> 31 <%= A.name %>
32 </td> 32 </td>
......
...@@ -10,15 +10,16 @@ ...@@ -10,15 +10,16 @@
10 <p>추가한 리스트</p> 10 <p>추가한 리스트</p>
11 11
12 <a href="/auth/logout/kakao">로그아웃</a> 12 <a href="/auth/logout/kakao">로그아웃</a>
13 -<a href="/setting">세팅</a> 13 +<a href="/setting/">세팅</a>
14 </br> 14 </br>
15 15
16 <table> 16 <table>
17 +
17 <% 18 <%
18 - var current = ""; 19 +
19 - for(updated in list){ 20 + for(i=0;i<mytoons.length; i++){
20 %> 21 %>
21 - <%= updated + " : " + list[updated] %><br> 22 + <%= mytoons[i].name + " : " + mytoons[i].week %><br>
22 <% 23 <%
23 } 24 }
24 %> 25 %>
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
11 11
12 <% 12 <%
13 var current = ""; 13 var current = "";
14 - for(toonName in list) { 14 + for(toonName in mytoons) {
15 - var A = list[toonName]; 15 + var A = mytoons[toonName];
16 %> 16 %>
17 <%= A %></br> 17 <%= A %></br>
18 <% 18 <%
......