diff --git a/client/.eslintcache b/client/.eslintcache index d9fb004f3b35357bccc1d538995a296de0d45634..f83c75ade11d62ac752caac17284c28746575c66 100644 --- a/client/.eslintcache +++ b/client/.eslintcache @@ -1 +1 @@ -[{"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js":"1","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Search.js":"2","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\index.js":"3","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js":"4","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js":"5","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js":"6"},{"size":362,"mtime":1608689675665,"results":"7","hashOfConfig":"8"},{"size":7987,"mtime":1611670471858,"results":"9","hashOfConfig":"8"},{"size":889,"mtime":1611497488080,"results":"10","hashOfConfig":"8"},{"size":2548,"mtime":1611668355580,"results":"11","hashOfConfig":"8"},{"size":2199,"mtime":1610325754517,"results":"12","hashOfConfig":"8"},{"size":1456,"mtime":1611495914736,"results":"13","hashOfConfig":"8"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1n20xnc",{"filePath":"16","messages":"17","errorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"18","messages":"19","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"20"},{"filePath":"21","messages":"22","errorCount":0,"warningCount":8,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"25","messages":"26","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js",[],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Search.js",["27","28","29","30","31","32"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\index.js",["33","34"],"import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport './index.css';\r\nimport 'bootstrap/dist/css/bootstrap.min.css';\r\nimport App from './Pages/App';\r\nimport Search from './Pages/Search';\r\nimport axios from 'axios';\r\nimport reportWebVitals from './reportWebVitals';\r\nimport {\r\n BrowserRouter as Router,\r\n Switch,\r\n Route,\r\n Redirect,\r\n} from \"react-router-dom\";\r\n\r\nReactDOM.render(\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ,\r\n document.getElementById('root')\r\n);\r\n\r\n// If you want to start measuring performance in your app, pass a function\r\n// to log results (for example: reportWebVitals(console.log))\r\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\r\nreportWebVitals();\r\n","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js",["35","36","37","38","39","40","41","42"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js",["43","44","45"],{"ruleId":"46","severity":1,"message":"47","line":2,"column":16,"nodeType":"48","messageId":"49","endLine":2,"endColumn":24},{"ruleId":"50","severity":1,"message":"51","line":34,"column":8,"nodeType":"52","endLine":34,"endColumn":10,"suggestions":"53"},{"ruleId":"50","severity":1,"message":"54","line":38,"column":8,"nodeType":"52","endLine":38,"endColumn":21,"suggestions":"55"},{"ruleId":"50","severity":1,"message":"56","line":53,"column":8,"nodeType":"52","endLine":53,"endColumn":10,"suggestions":"57"},{"ruleId":"46","severity":1,"message":"58","line":68,"column":11,"nodeType":"48","messageId":"49","endLine":68,"endColumn":17},{"ruleId":"59","severity":1,"message":"60","line":129,"column":35,"nodeType":"61","endLine":129,"endColumn":76},{"ruleId":"46","severity":1,"message":"62","line":7,"column":8,"nodeType":"48","messageId":"49","endLine":7,"endColumn":13},{"ruleId":"46","severity":1,"message":"47","line":13,"column":3,"nodeType":"48","messageId":"49","endLine":13,"endColumn":11},{"ruleId":"46","severity":1,"message":"63","line":3,"column":33,"nodeType":"48","messageId":"49","endLine":3,"endColumn":36},{"ruleId":"46","severity":1,"message":"64","line":3,"column":46,"nodeType":"48","messageId":"49","endLine":3,"endColumn":51},{"ruleId":"46","severity":1,"message":"65","line":3,"column":53,"nodeType":"48","messageId":"49","endLine":3,"endColumn":57},{"ruleId":"46","severity":1,"message":"66","line":3,"column":59,"nodeType":"48","messageId":"49","endLine":3,"endColumn":68},{"ruleId":"46","severity":1,"message":"67","line":3,"column":70,"nodeType":"48","messageId":"49","endLine":3,"endColumn":78},{"ruleId":"46","severity":1,"message":"68","line":13,"column":10,"nodeType":"48","messageId":"49","endLine":13,"endColumn":15},{"ruleId":"46","severity":1,"message":"69","line":13,"column":17,"nodeType":"48","messageId":"49","endLine":13,"endColumn":25},{"ruleId":"50","severity":1,"message":"70","line":32,"column":6,"nodeType":"52","endLine":32,"endColumn":8,"suggestions":"71"},{"ruleId":"46","severity":1,"message":"72","line":1,"column":17,"nodeType":"48","messageId":"49","endLine":1,"endColumn":26},{"ruleId":"46","severity":1,"message":"73","line":2,"column":10,"nodeType":"48","messageId":"49","endLine":2,"endColumn":14},{"ruleId":"46","severity":1,"message":"74","line":4,"column":64,"nodeType":"48","messageId":"49","endLine":4,"endColumn":75},"no-unused-vars","'Redirect' is defined but never used.","Identifier","unusedVar","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getAssociation'. Either include it or remove the dependency array.","ArrayExpression",["75"],"React Hook useEffect has a missing dependency: 'index'. Either include it or remove the dependency array. You can also replace multiple useState variables with useReducer if 'setPagePlace' needs the current value of 'index'.",["76"],"React Hook useEffect has missing dependencies: 'getAssociation', 'props.history', 'search', and 'state'. Either include them or remove the dependency array.",["77"],"'places' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","'axios' is defined but never used.","'Col' is defined but never used.","'Badge' is defined but never used.","'Card' is defined but never used.","'Accordion' is defined but never used.","'Carousel' is defined but never used.","'state' is assigned a value but never used.","'setState' is assigned a value but never used.","React Hook useEffect has missing dependencies: 'getReview' and 'infiniteScroll'. Either include them or remove the dependency array.",["78"],"'useEffect' is defined but never used.","'Link' is defined but never used.","'FormControl' is defined but never used.",{"desc":"79","fix":"80"},{"desc":"81","fix":"82"},{"desc":"83","fix":"84"},{"desc":"85","fix":"86"},"Update the dependencies array to be: [getAssociation]",{"range":"87","text":"88"},"Update the dependencies array to be: [association, index]",{"range":"89","text":"90"},"Update the dependencies array to be: [getAssociation, props.history, search, state]",{"range":"91","text":"92"},"Update the dependencies array to be: [getReview, infiniteScroll]",{"range":"93","text":"94"},[1288,1290],"[getAssociation]",[1398,1411],"[association, index]",[1994,1996],"[getAssociation, props.history, search, state]",[962,964],"[getReview, infiniteScroll]"] \ No newline at end of file +[{"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js":"1","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Search.js":"2","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\index.js":"3","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js":"4","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js":"5","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Place.js":"6","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Hello.js":"7"},{"size":362,"mtime":1608689675665,"results":"8","hashOfConfig":"9"},{"size":7672,"mtime":1611722932802,"results":"10","hashOfConfig":"9"},{"size":889,"mtime":1611497488080,"results":"11","hashOfConfig":"9"},{"size":2199,"mtime":1610325754517,"results":"12","hashOfConfig":"9"},{"size":1456,"mtime":1611495914736,"results":"13","hashOfConfig":"9"},{"size":2146,"mtime":1611734244694,"results":"14","hashOfConfig":"9"},{"size":2011,"mtime":1611721355007,"results":"15","hashOfConfig":"9"},{"filePath":"16","messages":"17","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1n20xnc",{"filePath":"18","messages":"19","errorCount":0,"warningCount":8,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"20","messages":"21","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"22"},{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"25","messages":"26","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"27","messages":"28","errorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"29","messages":"30","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js",[],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Search.js",["31","32","33","34","35","36","37","38"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\index.js",["39","40"],"import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport './index.css';\r\nimport 'bootstrap/dist/css/bootstrap.min.css';\r\nimport App from './Pages/App';\r\nimport Search from './Pages/Search';\r\nimport axios from 'axios';\r\nimport reportWebVitals from './reportWebVitals';\r\nimport {\r\n BrowserRouter as Router,\r\n Switch,\r\n Route,\r\n Redirect,\r\n} from \"react-router-dom\";\r\n\r\nReactDOM.render(\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ,\r\n document.getElementById('root')\r\n);\r\n\r\n// If you want to start measuring performance in your app, pass a function\r\n// to log results (for example: reportWebVitals(console.log))\r\n// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals\r\nreportWebVitals();\r\n","C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\App.js",["41","42","43"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Place.js",["44","45"],"C:\\Users\\sag06\\Desktop\\project\\search-page\\client\\src\\Pages\\Hello.js",["46"],{"ruleId":"47","severity":1,"message":"48","line":2,"column":16,"nodeType":"49","messageId":"50","endLine":2,"endColumn":24},{"ruleId":"47","severity":1,"message":"51","line":13,"column":12,"nodeType":"49","messageId":"50","endLine":13,"endColumn":19},{"ruleId":"47","severity":1,"message":"52","line":13,"column":21,"nodeType":"49","messageId":"50","endLine":13,"endColumn":31},{"ruleId":"53","severity":1,"message":"54","line":33,"column":8,"nodeType":"55","endLine":33,"endColumn":10,"suggestions":"56"},{"ruleId":"53","severity":1,"message":"57","line":37,"column":8,"nodeType":"55","endLine":37,"endColumn":21,"suggestions":"58"},{"ruleId":"53","severity":1,"message":"59","line":52,"column":8,"nodeType":"55","endLine":52,"endColumn":10,"suggestions":"60"},{"ruleId":"47","severity":1,"message":"61","line":67,"column":11,"nodeType":"49","messageId":"50","endLine":67,"endColumn":17},{"ruleId":"62","severity":1,"message":"63","line":128,"column":35,"nodeType":"64","endLine":128,"endColumn":76},{"ruleId":"47","severity":1,"message":"65","line":7,"column":8,"nodeType":"49","messageId":"50","endLine":7,"endColumn":13},{"ruleId":"47","severity":1,"message":"48","line":13,"column":3,"nodeType":"49","messageId":"50","endLine":13,"endColumn":11},{"ruleId":"47","severity":1,"message":"66","line":1,"column":17,"nodeType":"49","messageId":"50","endLine":1,"endColumn":26},{"ruleId":"47","severity":1,"message":"67","line":2,"column":10,"nodeType":"49","messageId":"50","endLine":2,"endColumn":14},{"ruleId":"47","severity":1,"message":"68","line":4,"column":64,"nodeType":"49","messageId":"50","endLine":4,"endColumn":75},{"ruleId":"47","severity":1,"message":"69","line":3,"column":26,"nodeType":"49","messageId":"50","endLine":3,"endColumn":32},{"ruleId":"53","severity":1,"message":"70","line":34,"column":6,"nodeType":"55","endLine":34,"endColumn":8,"suggestions":"71"},{"ruleId":"47","severity":1,"message":"65","line":1,"column":8,"nodeType":"49","messageId":"50","endLine":1,"endColumn":13},"no-unused-vars","'Redirect' is defined but never used.","Identifier","unusedVar","'showSet' is assigned a value but never used.","'setShowSet' is assigned a value but never used.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getAssociation'. Either include it or remove the dependency array.","ArrayExpression",["72"],"React Hook useEffect has a missing dependency: 'index'. Either include it or remove the dependency array. You can also replace multiple useState variables with useReducer if 'setPagePlace' needs the current value of 'index'.",["73"],"React Hook useEffect has missing dependencies: 'getAssociation', 'props.history', 'search', and 'state'. Either include them or remove the dependency array.",["74"],"'places' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","'axios' is defined but never used.","'useEffect' is defined but never used.","'Link' is defined but never used.","'FormControl' is defined but never used.","'Button' is defined but never used.","React Hook useEffect has missing dependencies: 'getReview' and 'infiniteScroll'. Either include them or remove the dependency array.",["75"],{"desc":"76","fix":"77"},{"desc":"78","fix":"79"},{"desc":"80","fix":"81"},{"desc":"82","fix":"83"},"Update the dependencies array to be: [getAssociation]",{"range":"84","text":"85"},"Update the dependencies array to be: [association, index]",{"range":"86","text":"87"},"Update the dependencies array to be: [getAssociation, props.history, search, state]",{"range":"88","text":"89"},"Update the dependencies array to be: [getReview, infiniteScroll]",{"range":"90","text":"91"},[1248,1250],"[getAssociation]",[1358,1371],"[association, index]",[1954,1956],"[getAssociation, props.history, search, state]",[1102,1104],"[getReview, infiniteScroll]"] \ No newline at end of file diff --git a/client/src/Components/Place.js b/client/src/Components/Place.js deleted file mode 100644 index a8532feac6c1924b9019a1b27056a680bc6fa8f1..0000000000000000000000000000000000000000 --- a/client/src/Components/Place.js +++ /dev/null @@ -1,58 +0,0 @@ -import axios from 'axios'; -import React, { useEffect, useState } from 'react'; -import { Modal, Container, Row, Button, } from 'react-bootstrap'; - -function Place(props) { - const [reviews, setReviews] = useState() - const [db, setDb] = useState(false) - const getReview = () => { - axios({ url: `/api/review?keyword=${props.place.name}`, method: 'post', data: { db: db } }) - .then(res => { - console.log("place res.data", res.data) - setReviews(res.data.review) - setDb(res.data.db) - console.log(db) - }) - .catch(err => { - console.log(err) - }) - } - - useEffect(() => { - getReview(); - }, []) - - return ( - - - - {props.index + 1}. {props.place.name} - - - - - {Array.isArray(reviews) ? reviews.map((review, index) => { - return ( - - {review.title} -
{review.summary}
-
{review.content}
-
- ) - }) - : "리뷰가 없습니다."} -
- -
- - - -
- ); -} - -export default Place; diff --git a/client/src/Pages/Place.js b/client/src/Pages/Place.js new file mode 100644 index 0000000000000000000000000000000000000000..44c8bb9412b76ad4d425443ea4ecab10c5d12676 --- /dev/null +++ b/client/src/Pages/Place.js @@ -0,0 +1,71 @@ +import axios from 'axios'; +import React, { useEffect, useState } from 'react'; +import { Container, Row, Button, } from 'react-bootstrap'; +import queryString from 'query-string' + +function Place(props) { + console.log(props) + const [db, setDb] = useState(false) + const [index, setIndex] = useState(0) + const [reviews, setReviews] = useState([]) + const place = queryString.parse(props.location.search).place + + const getReview = (index) => { + console.log(index, "dlseprtm") + axios({ url: `/api/review?keyword=${place}&index=${index}`, method: 'post', data: { db: db } }) + .then(res => { + console.log("place res.data", res.data) + setReviews([...reviews, ...res.data.review]) + setDb(res.data.db) + setIndex(res.data.index) + }) + .then(() => { + console.log(index, "인텍스", db) + }) + .catch(err => { + console.log(err) + }) + } + + useEffect(() => { + getReview(); + window.addEventListener("scroll", infiniteScroll); + return () => { window.removeEventListener("scroll", infiniteScroll); } + }, []); + + // useEffect(() => { + // getReview(); + + // }, [index]) + + const infiniteScroll = () => { + const { documentElement, body } = document; + const scrollHeight = Math.max(documentElement.scrollHeight, body.scrollHeight); + const scrollTop = Math.max(documentElement.scrollTop, body.scrollTop); + const clientHeight = documentElement.clientHeight; + if (scrollTop + clientHeight >= scrollHeight) { + // setIndex(index + 1) + getReview(index + 1); + console.log("더불러", index + 1) + } + console.log(scrollHeight, scrollTop, clientHeight) + } + + return ( + + {place} + {Array.isArray(reviews) ? reviews.map((review, index) => { + return ( + + {review.title} +
{review.summary}
+
{review.content}
+
+ ) + }) + : "리뷰가 없습니다."} +
+ ); +} + +export default Place; diff --git a/client/src/Pages/Search.js b/client/src/Pages/Search.js index 6651f1ebb57d24d0a0e8dcaff2a958e54bfcfe67..50a2e5686af4367ecde454851f05609af4a17440 100644 --- a/client/src/Pages/Search.js +++ b/client/src/Pages/Search.js @@ -1,7 +1,6 @@ import React, { useState, useEffect } from 'react'; import { Link, Redirect } from 'react-router-dom'; import ohuh from '../ohuh-sm.PNG'; -import Place from '../Components/Place'; import { Container, Form, Row, Col, Card, Image, InputGroup, FormControl, Button } from 'react-bootstrap'; import Paginations from '../Components/Paginations'; import axios from 'axios'; @@ -13,7 +12,7 @@ function Search(props) { const [index, setIndex] = useState(1); const [showSet, setShowSet] = useState([false, false, false, false]); const [search, setSearch] = useState(queryString.parse(props.location.search).keyword); - const [pagePlace, setPagePlace] = useState(); + const [pagePlace, setPagePlace] = useState([]); const [association, setAssociation] = useState([]) const getAssociation = () => { @@ -125,7 +124,7 @@ function Search(props) { return ( - +
@@ -150,15 +149,12 @@ function Search(props) { {place.name} - + {place.address} - - setShowSet([false, false, false, false])} /> + + + @@ -168,7 +164,7 @@ function Search(props) { - + ); } diff --git a/client/src/index.js b/client/src/index.js index 363cb5fe526a69d30572e710e507eac6c89428fd..e76bb82d3e57a2592160b8e86d2c99b48d850190 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -12,6 +12,8 @@ import { Route, Redirect, } from "react-router-dom"; +import Place from './Pages/Place'; +import Hello from './Pages/Hello'; ReactDOM.render( @@ -19,6 +21,8 @@ ReactDOM.render( + + , diff --git a/server/controllers/review.controller.js b/server/controllers/review.controller.js index 29812d7e15810408a413dad6237d90bc08b9813a..d3ce198352161eb2701436a7d47611c7a49c26bc 100644 --- a/server/controllers/review.controller.js +++ b/server/controllers/review.controller.js @@ -2,50 +2,44 @@ import Review from '../models/Review.js' import cheerio from "cheerio"; import axios from 'axios'; -const search = async (req, res, next) => { - console.log(req.reviews, "1") +const search = async (req, res) => { try { - for (let j = 1; j < 2; j++) { - let reviews = [] - // console.log(req.reviews, "제발")/ - let url = "https://www.google.com/search?q=" + encodeURI(req.query.keyword) + "+site%3Atistory.com&page_no=" + j - let response1 = await axios.get(url) - let $1 = cheerio.load(response1.data); - $1('.kCrYT').each(async function (i) { - console.log("3") - let title = $1(this).find('h3').text() - let searchParams = new URLSearchParams($1(this).find('a').attr('href')); - let link = searchParams.get("/url?q") - let summary = $1(this).find('.s3v9rd').find('.s3v9rd').text() - if (title) { - reviews[i] = { title: title, link: link } - } else if (summary) { - reviews[i - 1] = { ...reviews[i - 1], summary: summary } - reviews = reviews.filter(e => e) - } - }) - reviews.forEach((review, i) => { - Review.findOne({ link: review.link }, async function (err, reviewss) { - console.log("4") + let reviews = [] + console.log(req.reviews, "제발") - if (err) { return res.status(404).send({ error: err }) } - if (reviewss) { - reviewss.keyword = [...reviewss.keyword, req.query.keyword] - reviewss.save() - } - if (!reviewss) { - reviews["keyword"] = [req.query.keyword] - let Reviews = await new Review(review).save() - // console.log(Reviews,"1") - req.reviews.push(Reviews) - } - }) - }) - } - const a = await Promise.all(req.reviews) - console.log(a, "2") - res.status(200).send({ review: a, db: true }) + let url = "https://www.google.com/search?q=" + encodeURI(req.query.keyword) + `+site%3Atistory.com&start=${Number(req.query.index) * 10}` + console.log(url) + let response1 = await axios.get(url) + let $1 = cheerio.load(response1.data); + $1('.kCrYT').each(async function (i) { + console.log("3") + let title = $1(this).find('h3').text() + let searchParams = new URLSearchParams($1(this).find('a').attr('href')); + let link = searchParams.get("/url?q") + let summary = $1(this).find('.s3v9rd').find('.s3v9rd').text() + if (title) { + reviews[i] = { title: title, link: link } + } else if (summary) { + reviews[i - 1] = { ...reviews[i - 1], summary: summary } + reviews = reviews.filter(e => e) + } + }) + // reviews.forEach(async (review, i) => { + // await Review.updateOne({ link: review.link }, { $push: { bookmark: req.query.keyword } }) + // const reviewss = await Review.findOne({ link: review.link }) + // if (!reviewss) { + // // reviews["keyword"] = [req.query.keyword] + let newReviews = [] + newReviews = [...newReviews, ...reviews] + // await new Review(review).save() + // } + // }) + // console.log(req.reviews, "걸러낸 리뷰즈입니다") + // const a = await Promise.all(newReviews) + // console.log(a, "2") + console.log(req.query.index, "인덱스ㅡㅡ") + res.status(200).send({ review: newReviews, db: true, index: Number(req.query.index) + 1 }) } catch (error) { console.log("6") console.log(error) @@ -53,17 +47,17 @@ const search = async (req, res, next) => { } -const find = (req, res, next) => { - console.log("7", req.query.keyword) +const find = async(req, res, next) => { + console.log("7", req.query) const keyword = req.query.keyword if (req.body.db) { next() } - Review.find({ keyword: keyword }, function (err, reviews) { + await Review.find({ keyword: keyword }, function (err, reviews) { req.reviews = [] if (reviews) { - if (reviews.length > 10) { - res.status(200).send({ review: reviews, db: true }) + if (reviews.length > 5) { + res.status(200).send({ review: reviews, db: true, message: "제발용" }) } req.reviews = reviews }