From 94ab062d78ad0a7a72017b4d67b7e630ee133f9c Mon Sep 17 00:00:00 2001 From: Seo Yeon Date: Sun, 24 Jan 2021 21:15:17 +0900 Subject: [PATCH] . --- client/.eslintcache | 2 +- client/src/Bookmark.js | 12 ++++- client/src/Components/Login.js | 13 +++--- client/src/Components/Place.js | 6 +-- client/src/Components/PrivateRoute.js | 2 +- client/src/Components/Signup.js | 12 ++--- client/src/Search.js | 34 ++++++++++---- client/src/index.js | 7 +-- client/src/utils/auth.js | 6 +-- googleSearch | 14 +++--- server/controllers/place.controller.js | 2 +- server/controllers/review.controller.js | 29 ++++++------ server/controllers/user.controller.js | 62 +++++++++++++++++++------ server/models/Review.js | 2 +- server/routes/auth.routes.js | 2 +- server/routes/user.routes.js | 10 ++++ 16 files changed, 142 insertions(+), 73 deletions(-) diff --git a/client/.eslintcache b/client/.eslintcache index f096dac..efa524d 100644 --- a/client/.eslintcache +++ b/client/.eslintcache @@ -1 +1 @@ -[{"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\index.js":"1","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js":"2","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\pagination.js":"3","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js":"4","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Login.js":"5","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\utils\\catchErrors.js":"6","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Signup.js":"7","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\utils\\auth.js":"8","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js":"9","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Search.js":"10","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\App.js":"11","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\PrivateRoute.js":"12","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Bookmark.js":"13"},{"size":1252,"mtime":1611127524644,"results":"14","hashOfConfig":"15"},{"size":362,"mtime":499162500000,"results":"16","hashOfConfig":"15"},{"size":2336,"mtime":1611127524186,"results":"17","hashOfConfig":"15"},{"size":1608,"mtime":1611127940167,"results":"18","hashOfConfig":"15"},{"size":2742,"mtime":1610519196409,"results":"19","hashOfConfig":"15"},{"size":405,"mtime":1609915408569,"results":"20","hashOfConfig":"15"},{"size":2675,"mtime":1610519220676,"results":"21","hashOfConfig":"15"},{"size":459,"mtime":1610352110057,"results":"22","hashOfConfig":"15"},{"size":2199,"mtime":1610503781980,"results":"23","hashOfConfig":"15"},{"size":10368,"mtime":1611250275739,"results":"24","hashOfConfig":"15"},{"size":2110,"mtime":1610617422890,"results":"25","hashOfConfig":"15"},{"size":438,"mtime":1610615328660,"results":"26","hashOfConfig":"15"},{"size":1987,"mtime":1611251902191,"results":"27","hashOfConfig":"15"},{"filePath":"28","messages":"29","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"30","usedDeprecatedRules":"31"},"1t9w6go",{"filePath":"32","messages":"33","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"31"},{"filePath":"34","messages":"35","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"31"},{"filePath":"36","messages":"37","errorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":"38","usedDeprecatedRules":"31"},{"filePath":"39","messages":"40","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"31"},{"filePath":"41","messages":"42","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"31"},{"filePath":"43","messages":"44","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"31"},{"filePath":"45","messages":"46","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"31"},{"filePath":"47","messages":"48","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"49","messages":"50","errorCount":0,"warningCount":7,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"51","messages":"52","errorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":"53","usedDeprecatedRules":"31"},{"filePath":"54","messages":"55","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"31"},{"filePath":"56","messages":"57","errorCount":5,"warningCount":14,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\index.js",["58"],"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 './App'\r\nimport Search from './Search';\r\nimport reportWebVitals from './reportWebVitals';\r\nimport Signup from './Components/Signup'\r\nimport Login from './Components/Login'\r\nimport PrivateRoute from \"./Components/PrivateRoute\";\r\nimport Bookmark from \"./Bookmark\"\r\nimport {\r\n BrowserRouter as Router,\r\n Switch,\r\n Route,\r\n Redirect,\r\n} from \"react-router-dom\";\r\nimport axios from 'axios';\r\n\r\n\r\nReactDOM.render(\r\n \r\n \r\n \r\n \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",["59","60"],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\pagination.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js",["61","62","63","64","65","66"],"import axios from 'axios';\r\nimport React, { useEffect, useState } from 'react';\r\nimport { Modal, Container, Row, Col, Button, Badge, Card, Accordion, Carousel } from 'react-bootstrap';\r\n\r\nfunction Place(props) {\r\n const [reviews, setReviews] = useState([])\r\n const getReview = () => {\r\n axios.get(`/api/review/${props.search.name}`)\r\n .then(res => {\r\n console.log(\"place res.data\", res.data)\r\n setReviews(res.data)\r\n })\r\n .catch(err => {\r\n console.log(err)\r\n })\r\n }\r\n\r\n useEffect(() => {\r\n getReview();\r\n }, [])\r\n\r\n\r\n return (\r\n setLgShow(false)}\r\n aria-labelledby=\"example-modal-sizes-title-lg\">\r\n \r\n \r\n {props.index + 1}. {props.search.name}\r\n \r\n \r\n \r\n \r\n {reviews.map((review, index) => {\r\n return (\r\n \r\n {review.title}\r\n
{review.summary}
\r\n
{review.content}
\r\n
\r\n )\r\n })}\r\n
\r\n\r\n
\r\n \r\n \r\n \r\n
\r\n );\r\n}\r\n\r\nexport default Place;\r\n","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Login.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\utils\\catchErrors.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Signup.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\utils\\auth.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Search.js",["67","68","69","70","71","72","73"],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\App.js",["74","75","76","77"],"import React, { useEffect, useState } from 'react';\r\nimport { Link, Redirect } from 'react-router-dom';\r\nimport ohuh from './ohuh.PNG'\r\nimport { Container, Row, Form, Image, InputGroup, Button, Col, FormControl, Navbar, Nav } from 'react-bootstrap';\r\nimport { handleLogout, isAuthenticated } from './utils/auth.js'\r\n\r\nfunction App() {\r\n const [state, setState] = useState(false);\r\n const [search, setSearch] = useState(\"\");\r\n const user = isAuthenticated()\r\n\r\n if (state !== false) {\r\n return ;\r\n }\r\n\r\n const handleChange = (e) => {\r\n setSearch(e.target.value);\r\n }\r\n\r\n const handleSubmit = () => {\r\n setState(true);\r\n }\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n \r\n
\r\n );\r\n}\r\n\r\nexport default App;\r\n","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\PrivateRoute.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Bookmark.js",["78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96"],{"ruleId":"97","severity":1,"message":"98","line":18,"column":8,"nodeType":"99","messageId":"100","endLine":18,"endColumn":13},{"ruleId":"101","replacedBy":"102"},{"ruleId":"103","replacedBy":"104"},{"ruleId":"97","severity":1,"message":"105","line":3,"column":33,"nodeType":"99","messageId":"100","endLine":3,"endColumn":36},{"ruleId":"97","severity":1,"message":"106","line":3,"column":46,"nodeType":"99","messageId":"100","endLine":3,"endColumn":51},{"ruleId":"97","severity":1,"message":"107","line":3,"column":53,"nodeType":"99","messageId":"100","endLine":3,"endColumn":57},{"ruleId":"97","severity":1,"message":"108","line":3,"column":59,"nodeType":"99","messageId":"100","endLine":3,"endColumn":68},{"ruleId":"97","severity":1,"message":"109","line":3,"column":70,"nodeType":"99","messageId":"100","endLine":3,"endColumn":78},{"ruleId":"110","severity":1,"message":"111","line":20,"column":6,"nodeType":"112","endLine":20,"endColumn":8,"suggestions":"113"},{"ruleId":"97","severity":1,"message":"114","line":5,"column":83,"nodeType":"99","messageId":"100","endLine":5,"endColumn":88},{"ruleId":"97","severity":1,"message":"98","line":8,"column":8,"nodeType":"99","messageId":"100","endLine":8,"endColumn":13},{"ruleId":"97","severity":1,"message":"115","line":16,"column":12,"nodeType":"99","messageId":"100","endLine":16,"endColumn":18},{"ruleId":"97","severity":1,"message":"116","line":17,"column":12,"nodeType":"99","messageId":"100","endLine":17,"endColumn":16},{"ruleId":"97","severity":1,"message":"117","line":19,"column":11,"nodeType":"99","messageId":"100","endLine":19,"endColumn":22},{"ruleId":"97","severity":1,"message":"118","line":20,"column":11,"nodeType":"99","messageId":"100","endLine":20,"endColumn":21},{"ruleId":"119","severity":1,"message":"120","line":90,"column":35,"nodeType":"121","endLine":90,"endColumn":76},{"ruleId":"97","severity":1,"message":"122","line":1,"column":17,"nodeType":"99","messageId":"100","endLine":1,"endColumn":26},{"ruleId":"97","severity":1,"message":"123","line":2,"column":10,"nodeType":"99","messageId":"100","endLine":2,"endColumn":14},{"ruleId":"97","severity":1,"message":"124","line":4,"column":64,"nodeType":"99","messageId":"100","endLine":4,"endColumn":75},{"ruleId":"97","severity":1,"message":"125","line":4,"column":77,"nodeType":"99","messageId":"100","endLine":4,"endColumn":83},{"ruleId":"97","severity":1,"message":"122","line":1,"column":27,"nodeType":"99","messageId":"100","endLine":1,"endColumn":36},{"ruleId":"97","severity":1,"message":"126","line":2,"column":10,"nodeType":"99","messageId":"100","endLine":2,"endColumn":15},{"ruleId":"97","severity":1,"message":"105","line":2,"column":17,"nodeType":"99","messageId":"100","endLine":2,"endColumn":20},{"ruleId":"97","severity":1,"message":"107","line":2,"column":22,"nodeType":"99","messageId":"100","endLine":2,"endColumn":26},{"ruleId":"97","severity":1,"message":"127","line":2,"column":45,"nodeType":"99","messageId":"100","endLine":2,"endColumn":48},{"ruleId":"97","severity":1,"message":"128","line":2,"column":50,"nodeType":"99","messageId":"100","endLine":2,"endColumn":56},{"ruleId":"97","severity":1,"message":"129","line":2,"column":82,"nodeType":"99","messageId":"100","endLine":2,"endColumn":87},{"ruleId":"97","severity":1,"message":"130","line":2,"column":89,"nodeType":"99","messageId":"100","endLine":2,"endColumn":94},{"ruleId":"97","severity":1,"message":"131","line":4,"column":10,"nodeType":"99","messageId":"100","endLine":4,"endColumn":18},{"ruleId":"97","severity":1,"message":"132","line":12,"column":12,"nodeType":"99","messageId":"100","endLine":12,"endColumn":16},{"ruleId":"97","severity":1,"message":"133","line":12,"column":18,"nodeType":"99","messageId":"100","endLine":12,"endColumn":25},{"ruleId":"97","severity":1,"message":"134","line":13,"column":12,"nodeType":"99","messageId":"100","endLine":13,"endColumn":19},{"ruleId":"97","severity":1,"message":"135","line":15,"column":20,"nodeType":"99","messageId":"100","endLine":15,"endColumn":32},{"ruleId":"136","severity":2,"message":"137","line":18,"column":13,"nodeType":"99","messageId":"138","endLine":18,"endColumn":21},{"ruleId":"136","severity":2,"message":"139","line":19,"column":62,"nodeType":"99","messageId":"138","endLine":19,"endColumn":66},{"ruleId":"136","severity":2,"message":"139","line":21,"column":25,"nodeType":"99","messageId":"138","endLine":21,"endColumn":29},{"ruleId":"136","severity":2,"message":"140","line":26,"column":13,"nodeType":"99","messageId":"138","endLine":26,"endColumn":24},{"ruleId":"136","severity":2,"message":"137","line":26,"column":32,"nodeType":"99","messageId":"138","endLine":26,"endColumn":40},{"ruleId":"97","severity":1,"message":"141","line":30,"column":11,"nodeType":"99","messageId":"100","endLine":30,"endColumn":19},"no-unused-vars","'axios' is defined but never used.","Identifier","unusedVar","no-native-reassign",["142"],"no-negated-in-lhs",["143"],"'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.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getReview'. Either include it or remove the dependency array.","ArrayExpression",["144"],"'Modal' is defined but never used.","'mobile' is assigned a value but never used.","'show' is assigned a value but never used.","'handleClose' is assigned a value but never used.","'handleShow' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","'useEffect' is defined but never used.","'Link' is defined but never used.","'FormControl' is defined but never used.","'Navbar' is defined but never used.","'Alert' is defined but never used.","'Row' is defined but never used.","'Button' is defined but never used.","'Image' is defined but never used.","'Table' is defined but never used.","'Redirect' is defined but never used.","'page' is assigned a value but never used.","'setPage' is assigned a value but never used.","'success' is assigned a value but never used.","'handleSubmit' is defined but never used.","no-undef","'setError' is not defined.","undef","'user' is not defined.","'catchErrors' is not defined.","'add_Page' is assigned a value but never used.","no-global-assign","no-unsafe-negation",{"desc":"145","fix":"146"},"Update the dependencies array to be: [getReview]",{"range":"147","text":"148"},[560,562],"[getReview]"] \ No newline at end of file +[{"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\index.js":"1","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js":"2","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js":"3","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Login.js":"4","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\utils\\catchErrors.js":"5","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Signup.js":"6","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\utils\\auth.js":"7","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js":"8","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Search.js":"9","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\App.js":"10","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\PrivateRoute.js":"11","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Bookmark.js":"12"},{"size":1368,"mtime":1611270972548,"results":"13","hashOfConfig":"14"},{"size":362,"mtime":499162500000,"results":"15","hashOfConfig":"14"},{"size":1606,"mtime":1611251972438,"results":"16","hashOfConfig":"14"},{"size":2742,"mtime":1610519196409,"results":"17","hashOfConfig":"14"},{"size":405,"mtime":1609915408569,"results":"18","hashOfConfig":"14"},{"size":2675,"mtime":1610519220676,"results":"19","hashOfConfig":"14"},{"size":459,"mtime":1610352110057,"results":"20","hashOfConfig":"14"},{"size":2199,"mtime":1610503781980,"results":"21","hashOfConfig":"14"},{"size":10892,"mtime":1611275393517,"results":"22","hashOfConfig":"14"},{"size":2110,"mtime":1610617422890,"results":"23","hashOfConfig":"14"},{"size":438,"mtime":1610615328660,"results":"24","hashOfConfig":"14"},{"size":2226,"mtime":1611269968099,"results":"25","hashOfConfig":"14"},{"filePath":"26","messages":"27","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1t9w6go",{"filePath":"28","messages":"29","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"30"},{"filePath":"31","messages":"32","errorCount":0,"warningCount":6,"fixableErrorCount":0,"fixableWarningCount":0,"source":"33","usedDeprecatedRules":"30"},{"filePath":"34","messages":"35","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"30"},{"filePath":"36","messages":"37","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"30"},{"filePath":"38","messages":"39","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"30"},{"filePath":"40","messages":"41","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"30"},{"filePath":"42","messages":"43","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"30"},{"filePath":"44","messages":"45","errorCount":0,"warningCount":10,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"46","messages":"47","errorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":"48","usedDeprecatedRules":"30"},{"filePath":"49","messages":"50","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"30"},{"filePath":"51","messages":"52","errorCount":0,"warningCount":14,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\index.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\reportWebVitals.js",[],["53","54"],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Place.js",["55","56","57","58","59","60"],"import axios from 'axios';\r\nimport React, { useEffect, useState } from 'react';\r\nimport { Modal, Container, Row, Col, Button, Badge, Card, Accordion, Carousel } from 'react-bootstrap';\r\n\r\nfunction Place(props) {\r\n const [reviews, setReviews] = useState([])\r\n const getReview = () => {\r\n axios.get(`/api/review/${props.search.name}`)\r\n .then(res => {\r\n console.log(\"place res.data\", res.data)\r\n setReviews(res.data)\r\n })\r\n .catch(err => {\r\n console.log(err)\r\n })\r\n }\r\n\r\n useEffect(() => {\r\n getReview();\r\n }, [])\r\n\r\n return (\r\n setLgShow(false)}\r\n aria-labelledby=\"example-modal-sizes-title-lg\">\r\n \r\n \r\n {props.index + 1}. {props.search.name}\r\n \r\n \r\n \r\n \r\n {reviews.map((review, index) => {\r\n return (\r\n \r\n {review.title}\r\n
{review.summary}
\r\n
{review.content}
\r\n
\r\n )\r\n })}\r\n
\r\n\r\n
\r\n \r\n \r\n \r\n
\r\n );\r\n}\r\n\r\nexport default Place;\r\n","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Login.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\utils\\catchErrors.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Signup.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\utils\\auth.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\Paginations.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Search.js",["61","62","63","64","65","66","67","68","69","70"],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\App.js",["71","72","73","74"],"import React, { useEffect, useState } from 'react';\r\nimport { Link, Redirect } from 'react-router-dom';\r\nimport ohuh from './ohuh.PNG'\r\nimport { Container, Row, Form, Image, InputGroup, Button, Col, FormControl, Navbar, Nav } from 'react-bootstrap';\r\nimport { handleLogout, isAuthenticated } from './utils/auth.js'\r\n\r\nfunction App() {\r\n const [state, setState] = useState(false);\r\n const [search, setSearch] = useState(\"\");\r\n const user = isAuthenticated()\r\n\r\n if (state !== false) {\r\n return ;\r\n }\r\n\r\n const handleChange = (e) => {\r\n setSearch(e.target.value);\r\n }\r\n\r\n const handleSubmit = () => {\r\n setState(true);\r\n }\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n \r\n
\r\n );\r\n}\r\n\r\nexport default App;\r\n","C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Components\\PrivateRoute.js",[],"C:\\Users\\hello\\Desktop\\project\\search-page\\client\\src\\Bookmark.js",["75","76","77","78","79","80","81","82","83","84","85","86","87","88"],{"ruleId":"89","replacedBy":"90"},{"ruleId":"91","replacedBy":"92"},{"ruleId":"93","severity":1,"message":"94","line":3,"column":33,"nodeType":"95","messageId":"96","endLine":3,"endColumn":36},{"ruleId":"93","severity":1,"message":"97","line":3,"column":46,"nodeType":"95","messageId":"96","endLine":3,"endColumn":51},{"ruleId":"93","severity":1,"message":"98","line":3,"column":53,"nodeType":"95","messageId":"96","endLine":3,"endColumn":57},{"ruleId":"93","severity":1,"message":"99","line":3,"column":59,"nodeType":"95","messageId":"96","endLine":3,"endColumn":68},{"ruleId":"93","severity":1,"message":"100","line":3,"column":70,"nodeType":"95","messageId":"96","endLine":3,"endColumn":78},{"ruleId":"101","severity":1,"message":"102","line":20,"column":6,"nodeType":"103","endLine":20,"endColumn":8,"suggestions":"104"},{"ruleId":"93","severity":1,"message":"105","line":5,"column":83,"nodeType":"95","messageId":"96","endLine":5,"endColumn":88},{"ruleId":"93","severity":1,"message":"106","line":22,"column":12,"nodeType":"95","messageId":"96","endLine":22,"endColumn":18},{"ruleId":"93","severity":1,"message":"107","line":23,"column":12,"nodeType":"95","messageId":"96","endLine":23,"endColumn":16},{"ruleId":"93","severity":1,"message":"108","line":24,"column":18,"nodeType":"95","messageId":"96","endLine":24,"endColumn":25},{"ruleId":"93","severity":1,"message":"109","line":25,"column":12,"nodeType":"95","messageId":"96","endLine":25,"endColumn":19},{"ruleId":"93","severity":1,"message":"110","line":26,"column":12,"nodeType":"95","messageId":"96","endLine":26,"endColumn":17},{"ruleId":"93","severity":1,"message":"111","line":28,"column":11,"nodeType":"95","messageId":"96","endLine":28,"endColumn":22},{"ruleId":"93","severity":1,"message":"112","line":29,"column":11,"nodeType":"95","messageId":"96","endLine":29,"endColumn":21},{"ruleId":"93","severity":1,"message":"113","line":84,"column":19,"nodeType":"95","messageId":"96","endLine":84,"endColumn":27},{"ruleId":"114","severity":1,"message":"115","line":106,"column":35,"nodeType":"116","endLine":106,"endColumn":76},{"ruleId":"93","severity":1,"message":"117","line":1,"column":17,"nodeType":"95","messageId":"96","endLine":1,"endColumn":26},{"ruleId":"93","severity":1,"message":"118","line":2,"column":10,"nodeType":"95","messageId":"96","endLine":2,"endColumn":14},{"ruleId":"93","severity":1,"message":"119","line":4,"column":64,"nodeType":"95","messageId":"96","endLine":4,"endColumn":75},{"ruleId":"93","severity":1,"message":"120","line":4,"column":77,"nodeType":"95","messageId":"96","endLine":4,"endColumn":83},{"ruleId":"93","severity":1,"message":"117","line":1,"column":27,"nodeType":"95","messageId":"96","endLine":1,"endColumn":36},{"ruleId":"93","severity":1,"message":"121","line":2,"column":10,"nodeType":"95","messageId":"96","endLine":2,"endColumn":15},{"ruleId":"93","severity":1,"message":"94","line":2,"column":17,"nodeType":"95","messageId":"96","endLine":2,"endColumn":20},{"ruleId":"93","severity":1,"message":"98","line":2,"column":22,"nodeType":"95","messageId":"96","endLine":2,"endColumn":26},{"ruleId":"93","severity":1,"message":"122","line":2,"column":45,"nodeType":"95","messageId":"96","endLine":2,"endColumn":48},{"ruleId":"93","severity":1,"message":"123","line":2,"column":50,"nodeType":"95","messageId":"96","endLine":2,"endColumn":56},{"ruleId":"93","severity":1,"message":"124","line":2,"column":82,"nodeType":"95","messageId":"96","endLine":2,"endColumn":87},{"ruleId":"93","severity":1,"message":"125","line":2,"column":89,"nodeType":"95","messageId":"96","endLine":2,"endColumn":94},{"ruleId":"93","severity":1,"message":"126","line":5,"column":10,"nodeType":"95","messageId":"96","endLine":5,"endColumn":18},{"ruleId":"93","severity":1,"message":"109","line":14,"column":12,"nodeType":"95","messageId":"96","endLine":14,"endColumn":19},{"ruleId":"93","severity":1,"message":"110","line":15,"column":12,"nodeType":"95","messageId":"96","endLine":15,"endColumn":17},{"ruleId":"93","severity":1,"message":"127","line":18,"column":14,"nodeType":"95","messageId":"96","endLine":18,"endColumn":26},{"ruleId":"93","severity":1,"message":"128","line":23,"column":20,"nodeType":"95","messageId":"96","endLine":23,"endColumn":32},{"ruleId":"93","severity":1,"message":"129","line":38,"column":11,"nodeType":"95","messageId":"96","endLine":38,"endColumn":19},"no-native-reassign",["130"],"no-negated-in-lhs",["131"],"no-unused-vars","'Col' is defined but never used.","Identifier","unusedVar","'Badge' is defined but never used.","'Card' is defined but never used.","'Accordion' is defined but never used.","'Carousel' is defined but never used.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'getReview'. Either include it or remove the dependency array.","ArrayExpression",["132"],"'Modal' is defined but never used.","'mobile' is assigned a value but never used.","'show' is assigned a value but never used.","'setPage' is assigned a value but never used.","'success' is assigned a value but never used.","'error' is assigned a value but never used.","'handleClose' is assigned a value but never used.","'handleShow' is assigned a value but never used.","'response' is assigned a value but never used.","react/jsx-no-duplicate-props","No duplicate props allowed","JSXAttribute","'useEffect' is defined but never used.","'Link' is defined but never used.","'FormControl' is defined but never used.","'Navbar' is defined but never used.","'Alert' is defined but never used.","'Row' is defined but never used.","'Button' is defined but never used.","'Image' is defined but never used.","'Table' is defined but never used.","'Redirect' is defined but never used.","'handleChange' is defined but never used.","'handleSubmit' is defined but never used.","'add_Page' is assigned a value but never used.","no-global-assign","no-unsafe-negation",{"desc":"133","fix":"134"},"Update the dependencies array to be: [getReview]",{"range":"135","text":"136"},[560,562],"[getReview]"] \ No newline at end of file diff --git a/client/src/Bookmark.js b/client/src/Bookmark.js index d01b808..c9bd9df 100644 --- a/client/src/Bookmark.js +++ b/client/src/Bookmark.js @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react' import { Alert, Col, Card, Container, Form, Row, Button, Nav, Navbar, ListGroup, Image, Table } from "react-bootstrap" import axios from "axios" +import catchErrors from './utils/catchErrors.js' import { Redirect } from 'react-router-dom' const INIT_PAGE = { @@ -11,14 +12,21 @@ const INIT_PAGE = { function Bookmark() { const [page, setPage] = useState(INIT_PAGE) const [success, setSuccess] = useState(false) + const [error, setError] = useState('') + + + function handleChange(event) { + const {title, value} = event.target + setPage({...page, [title]: value}) + } async function handleSubmit(event) { event.preventDefault() try { setError('') - const response = await axios.post('/api/users/', user) + const response = await axios.post('/api/users/bookmark ', page) console.log(response.data) - console.log(user) + console.log(page) // setUser(INIT_USER) setSuccess(true) } catch (error) { diff --git a/client/src/Components/Login.js b/client/src/Components/Login.js index d067312..d2240ce 100644 --- a/client/src/Components/Login.js +++ b/client/src/Components/Login.js @@ -9,27 +9,28 @@ import { handleLogin } from '../utils/auth' const INIT_USER = { email: '', password: '' -} +} //초기 유저에 이메일 비밀번호 설정 function Login() { + //const [<상태 값 저장 변수>, <상태 값 갱신 함수>] = useState(<상태 초기 값>); const [user, setUser] = useState(INIT_USER) const [disabled, setDisabled] = useState(true) const [error, setError] = useState('') const [success, setSuccess] = useState(false) const [loading, setLoading] = useState(false) - useEffect(() => { + useEffect(() => { //참거짓 판단 값들의 원소들이 element로 들어간다 const isUser = Object.values(user).every(el => Boolean(el)) isUser ? setDisabled(false) : setDisabled(true) }, [user]) function handleChange(event) { - const {name, value} = event.target - setUser({...user, [name]: value}) + const {name, value} = event.target //{}안에 값을 이벤트.타겟에 지정?한다 + setUser({...user, [name]: value}) } async function handleSubmit(event) { - event.preventDefault() + event.preventDefault() //리셋을 막는다 try { setLoading(true) setError('') @@ -46,7 +47,7 @@ function Login() { if (success) { console.log('success', success) - return + return //성공하면 홈화면으로 간다 } return ( diff --git a/client/src/Components/Place.js b/client/src/Components/Place.js index d3e3e07..10c0a53 100644 --- a/client/src/Components/Place.js +++ b/client/src/Components/Place.js @@ -3,9 +3,9 @@ import React, { useEffect, useState } from 'react'; import { Modal, Container, Row, Col, Button, Badge, Card, Accordion, Carousel } from 'react-bootstrap'; function Place(props) { - const [reviews, setReviews] = useState([]) - const getReview = () => { - axios.get(`/api/review/${props.search.name}`) + const [reviews, setReviews] = useState([]) + const getReview = () => { //review를 서버에 연결해서 + axios.get(`/api/review/${props.search.name}`) .then(res => { console.log("place res.data", res.data) setReviews(res.data) diff --git a/client/src/Components/PrivateRoute.js b/client/src/Components/PrivateRoute.js index 7823edf..af955ac 100644 --- a/client/src/Components/PrivateRoute.js +++ b/client/src/Components/PrivateRoute.js @@ -1,7 +1,7 @@ import React from 'react' import { Route, Redirect } from 'react-router-dom' import { isAuthenticated } from "../utils/auth"; - +//로그인 했을때 경로 실행하게 한다 function PrivateRoute({path, children}) { if (isAuthenticated()) { return ( diff --git a/client/src/Components/Signup.js b/client/src/Components/Signup.js index 9074fae..4baa825 100644 --- a/client/src/Components/Signup.js +++ b/client/src/Components/Signup.js @@ -8,10 +8,10 @@ const INIT_USER = { name: '', email: '', password: '' -} +} // 초기유저에 이름, 이메일, 비밀번호를 빈배열로 지정한다. function Signup() { - const [user, setUser] = useState(INIT_USER) + const [user, setUser] = useState(INIT_USER) const [disabled, setDisabled] = useState(true) const [error, setError] = useState('') const [success, setSuccess] = useState(false) @@ -20,16 +20,16 @@ function Signup() { const isUser = Object.values(user).every(el => Boolean(el)) isUser ? setDisabled(false) : setDisabled(true) }, [user]) - + //바뀌는것이 있을때 이벤트가 발생하는 함수? function handleChange(event) { const {name, value} = event.target setUser({...user, [name]: value}) } async function handleSubmit(event) { - event.preventDefault() + event.preventDefault() //submit을 누르면 이벤트가 실행 try { - setError('') + setError('') //post로 경로를 지정해서 서버에서 값을 받는다 const response = await axios.post('/api/users/signup', user) console.log(response.data) console.log(user) @@ -40,7 +40,7 @@ function Signup() { catchErrors(error, setError) } } - + //성공시 알림창이 뜨고 원래 페이지로 돌아간다 if (success) { alert('회원가입 되었습니다.') return diff --git a/client/src/Search.js b/client/src/Search.js index 45814df..fdcb833 100644 --- a/client/src/Search.js +++ b/client/src/Search.js @@ -3,10 +3,16 @@ 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, Modal } from 'react-bootstrap'; -import Paginations from './pagination.js'; +import Paginations from './Components/Paginations.js' +import catchErrors from './utils/catchErrors.js' import * as Icon from 'react-bootstrap-icons'; import axios from "axios"; +const INIT_PAGE = { + title: '', + url: '', +} + function Search(props) { const endPage = 10; const [state, setState] = useState(false); @@ -15,6 +21,9 @@ function Search(props) { const [search, setSearch] = useState(props.location.state.id); const [mobile, setMobile] = useState(); const [show, setShow] = useState(false); + const [page, setPage] = useState(INIT_PAGE) + const [success, setSuccess] = useState(false) + const [error, setError] = useState('') const handleClose = () => setShow(false); const handleShow = () => setShow(true); @@ -69,16 +78,23 @@ function Search(props) { setSearch(e.target.value); } - const handleSubmit = (e) => { - setState(true); + async function handleSubmit(e){ + setState(true); //버튼이 눌려서 handlesubmit이될때 setState값이 true로 바뀐다 + try { //respons 서버에 post로 요청하여 데이터를 받아온다 + const response = await axios.post('/api/users/bookmark', page) + setSuccess(true) + } catch (error) { + console.log(error) + catchErrors(error, setError) + } } function paginate(items, pageNumber, itemNumber) { - const page = []; - const startIndex = (pageNumber - 1) * itemNumber - for (var i = 0; i < itemNumber; i++) { + const page = []; //페이지를 빈배열로 설정 + const startIndex = (pageNumber - 1) * itemNumber // 처음인덱스 값이 페이지넘버 -1 * 아이템 넘버로 + for (var i = 0; i < itemNumber; i++) { page.push(items[(startIndex + i)]) - } + } return page } @@ -108,7 +124,7 @@ function Search(props) { return ( - + {place.name} @@ -146,4 +162,4 @@ export default Search // const bookmarksave = async (req, res) => { // const {userId, bookmarkId} = req.body // let bookmark = await Bookmark.findOne({bookmarkId:bookmarkId}).select('user') -// } \ No newline at end of file +// } diff --git a/client/src/index.js b/client/src/index.js index 3279178..0359d97 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -8,6 +8,7 @@ import reportWebVitals from './reportWebVitals'; import Signup from './Components/Signup' import Login from './Components/Login' import PrivateRoute from "./Components/PrivateRoute"; +import axios from 'axios' import Bookmark from "./Bookmark" import { BrowserRouter as Router, @@ -16,9 +17,9 @@ import { Redirect, } from "react-router-dom"; -// axios.defaults.validateStatus = function (status) { -// return status < 500; // default -// } +axios.defaults.validateStatus = function (status) { + return status < 500; // default +} ReactDOM.render( diff --git a/client/src/utils/auth.js b/client/src/utils/auth.js index 6c2a518..575231c 100644 --- a/client/src/utils/auth.js +++ b/client/src/utils/auth.js @@ -7,11 +7,11 @@ export function handleLogin(userId) { export async function handleLogout() { localStorage.removeItem('loginStatus') await axios.get('/api/auth/logout') - window.location.href='/' + window.location.href='/' //경로 지정 } - +//유저가 로그인 했는 지 확인하는 함수 export function isAuthenticated() { - const userId = localStorage.getItem('loginStatus') + const userId = localStorage.getItem('loginStatus') //유저아이디를 로컬스토리지에서 가져와서 저장 if (userId) { return userId }else{ diff --git a/googleSearch b/googleSearch index ad1200d..e25048f 100644 --- a/googleSearch +++ b/googleSearch @@ -1,20 +1,20 @@ -한라산(hallasan) site:tistory.com - Google 검색
2017. 12. 25.괜찮은 담배인데 어째 인식이 상당히 안좋은(;;;) KT&G의 궐련 담배. 한라산 입니다. 1989년부터 발매된 담배로 현재 발매되는 브랜드에서는�...
2020. 8. 13."한라산의 산들바람에서 얻은 영감, '문베어브루잉 한라산 위트 (Moonbearbrewing Hallasan WIT)'" 이름: 문베어브루잉 한라산 위트�...
2017. 11. 1.한라산 게스트하우스 (Hallasan Guesthouse) 다가오는 제주도 여행! 아직 괜찮은 숙소를 찾지 못하셨나요? 그럼 한라산 게스트하우스�...
2020. 3. 13.2010년 제주시에서 개발, 발표한 제주서체 중 하나인 제주한라산체는 다른 제주명조체나 제주고딕체와 달리 손글씨체의 형태를 띠고 있습니다.
2020. 3. 25.제주 한라산 무료 한글 폰트 제목용으로 목판형 한글 서체로 제목이나 기타 상품 설명에 유용 ... https://www.jeju.go.kr/jeju/symbol/font/hallasan.htm.
2016. 7. 11.One of them, Hallasan is one of the UNESCO World Natural ... Hallasan National Park has policy of climbing on a day~ ... 한라산국립공원.
2020. 12. 27.한라산 등반시 유용할 것 같아서 미리 블로그에 올려놓습니다~^^ 출처: ... http:// www.jeju.go.kr/hallasan/public/download/map.htm 한라산 지도�...
2012. 6. 18.한라산 / 漢拏山 / Hallasan(Mt) (2012년 6월) △ 한라산은 제주도 섬 한가운데에 있는 산으로, 산 높이는 남한에서 가장 높은, 해발 1950미터이다.
2011. 10. 16.참고로 한라산을 올라갈 수 있는 코스는 백록담까지 등반이 가능한 성판악, ... The trail which is shortest way to climb Mt. Hallasan (3.7km from�...
2017. 12. 25.괜찮은 담배인데 어째 인식이 상당히 안좋은(;;;) KT&G의 궐련 담배. 한라산 입니다. 1989년부터 발매된 담배로 현재 발매되는 브랜드에서는�...
2020. 8. 13."한라산의 산들바람에서 얻은 영감, '문베어브루잉 한라산 위트 (Moonbearbrewing Hallasan WIT)'" 이름: 문베어브루잉 한라산 위트�...
2017. 11. 1.한라산 게스트하우스 (Hallasan Guesthouse) 다가오는 제주도 여행! 아직 괜찮은 숙소를 찾지 못하셨나요? 그럼 한라산 게스트하우스�...
2020. 3. 13.2010년 제주시에서 개발, 발표한 제주서체 중 하나인 제주한라산체는 다른 제주명조체나 제주고딕체와 달리 손글씨체의 형태를 띠고 있습니다.
2020. 3. 25.제주 한라산 무료 한글 폰트 제목용으로 목판형 한글 서체로 제목이나 기타 상품 설명에 유용 ... https://www.jeju.go.kr/jeju/symbol/font/hallasan.htm.
2016. 7. 11.One of them, Hallasan is one of the UNESCO World Natural ... Hallasan National Park has policy of climbing on a day~ ... 한라산국립공원.
2020. 12. 27.한라산 등반시 유용할 것 같아서 미리 블로그에 올려놓습니다~^^ 출처: ... http:// www.jeju.go.kr/hallasan/public/download/map.htm 한라산 지도�...
2012. 6. 18.한라산 / 漢拏山 / Hallasan(Mt) (2012년 6월) △ 한라산은 제주도 섬 한가운데에 있는 산으로, 산 높이는 남한에서 가장 높은, 해발 1950미터이다.
2011. 10. 16.참고로 한라산을 올라갈 수 있는 코스는 백록담까지 등반이 가능한 성판악, ... The trail which is shortest way to climb Mt. Hallasan (3.7km from�...
\ No newline at end of file +var b=[function(){google.tick&&google.tick("load","dcl")}];google.dclc=function(a){b.length?b.push(a):a()};function c(){for(var a;a=b.shift();)a()}window.addEventListener?(document.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1)):window.attachEvent&&window.attachEvent("onload",c);}).call(this);(function(){(function(){google.csct={};google.csct.ps='AOvVaw3zt46FxvpBYF2Lq0ZyHYGn\x26ust\x3d1611360883749080';})();})();(function(){(function(){google.csct.rd=true;})();})();google.drty&&google.drty(); \ No newline at end of file diff --git a/server/controllers/place.controller.js b/server/controllers/place.controller.js index 384ea2a..2e1e11b 100644 --- a/server/controllers/place.controller.js +++ b/server/controllers/place.controller.js @@ -5,7 +5,7 @@ import axios from 'axios'; import { time } from 'console'; const searchPlace = async (req, res) => { - + //url 설정 const url = "https://search.naver.com/search.naver?sm=tab_hty.top&where=nexearch&query=" + encodeURI(req.params.search) const editUrl = /(http(s)?:\/\/)([a-z0-9\w]+\.*)+[a-z0-9]{2,4}/gi axios.get(url) diff --git a/server/controllers/review.controller.js b/server/controllers/review.controller.js index a92795d..bfdaa7c 100644 --- a/server/controllers/review.controller.js +++ b/server/controllers/review.controller.js @@ -1,17 +1,22 @@ import Review from '../models/Review.js' import cheerio from "cheerio"; -// import iconv from 'iconv' + import fs from 'fs' import axios from 'axios'; + // const Iconv = iconv.Iconv const search = async (req, res, next) => { + //**************************구글 크롤링 할 때************************/ try { let reviews = [] let content = [] - Review.find() + const url = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site%3Atistory.com&page_no=1" const response1 = await axios.get(url) + + fs.writeFileSync("googleSearch", response1.data, { encoding: 'utf-8' }) + // console.log(response1.data) const $1 = cheerio.load(response1.data); $1('.kCrYT').each(async function (i) { @@ -27,20 +32,19 @@ const search = async (req, res, next) => { reviews = reviews.filter(e => e) } }) - let promiseReview = await Promise.all(content) - promiseReview = promiseReview.filter(e => typeof (e) === 'string') + const promiseReview = await Promise.all(content) reviews.forEach(async (review, i) => { review["content"] = promiseReview[i] - const reviews = new Review(review).save() }) - res.send(reviews) } catch (error) { - console.log(error) + // console.log(error) res.send(error) } } + + //***************네이버 크롤링 할 때 ********************* */ // try { // let reviews = [] @@ -60,19 +64,16 @@ const search = async (req, res, next) => { // } const getReview = async (link) => { + let content = '없음' if (link) { - let content = '없음' const res = await axios.get(link) - const $2 = cheerio.load(res.data); + const $2 = cheerio.load(res.data); // cheerio 의미 if ($2('.tt_article_useless_p_margin').text()) { content = $2('.tt_article_useless_p_margin').text() } - return content } + return content } -const find = (res,req,next) => { - Review.find({address: }) +export default { search, getReview } -} -export default { search, find } diff --git a/server/controllers/user.controller.js b/server/controllers/user.controller.js index 902c729..732968e 100644 --- a/server/controllers/user.controller.js +++ b/server/controllers/user.controller.js @@ -2,6 +2,7 @@ import User from "../models/User.js" import isLength from 'validator/lib/isLength.js' import isEmail from "validator/lib/isEmail.js" import bcrypt from "bcryptjs"; +const reviews = ("../models/Review.js"); const signup = async (req, res) => { const { name, email, password } = req.body //구조분해해서 하나씩 @@ -33,7 +34,7 @@ const signup = async (req, res) => { } const userById = async (req, res, next, id) => { - try { + try { const user = await User.findById(id) if (!user) { res.status(404).send('사용자를 찾을 수 없습니다') @@ -46,18 +47,49 @@ const userById = async (req, res, next, id) => { } } -const bookMark = async (req, res) => { - const {title, url} = req.body - console.log(title, url) - try { - let bookmark = [] - const newBookmark = await new User ({ - bookmark, - }).save() - } catch (error) { - console.log(error) - res.status(500).send('사용자 아이디 검색 실패') - } -} +// const bookMark = async (req, res) => { +// const {title, url} = req.body +// console.log(title, url) +// try { +// let bookmark = [] +// const newBookmark = await new User ({ +// bookmark, +// }).save() +// } catch (error) { +// console.log(error) +// res.status(500).send('사용자 아이디 검색 실패') +// } +// } + +const bookMark = async(req, res, next) => { + const { title, link, content } = req.body; // 비구조화 할당 + + console.log(req.body); + let bookmark = [] + const newBookmark = await new Bookmark ({ + + }).save() + var reviewModel = new reviews(); + reviewModel.title = title; + reviewModel.content = content; + reviewModel.link = link; + reviewModel + .save() + .then(newReview => { + console.log("Create 완료"); + res.status(200).json({ + message: "Create success", + data: { + review: newReview + } + }); + }) + .catch(err => { + res.status(500).json({ + message: err + }); + }); + }; + -export default { signup, userById } \ No newline at end of file +export default { signup, userById, bookMark } \ No newline at end of file diff --git a/server/models/Review.js b/server/models/Review.js index ff31983..4c266b3 100644 --- a/server/models/Review.js +++ b/server/models/Review.js @@ -30,4 +30,4 @@ const ReviewSchema = new mongoose.Schema({ timestamps: true }) -export default mongoose.models.Review || mongoose.model('Review', ReviewSchema) \ No newline at end of file +export default mongoose.models.Review || mongoose.model('Review', ReviewSchema) diff --git a/server/routes/auth.routes.js b/server/routes/auth.routes.js index acf9bac..3ec7335 100644 --- a/server/routes/auth.routes.js +++ b/server/routes/auth.routes.js @@ -2,7 +2,7 @@ import express from "express" import authCtrl from "../controllers/auth.controller.js" const router = express.Router() - +//경로 설정? router.route('/api/auth/login') .post(authCtrl.login) diff --git a/server/routes/user.routes.js b/server/routes/user.routes.js index 66e4c18..53793e4 100644 --- a/server/routes/user.routes.js +++ b/server/routes/user.routes.js @@ -8,4 +8,14 @@ router.route('/api/users/signup') router.param('userId', userCtrl.userById) +router.get('/admin/:_id', verifyToken, function (req, res, next) { + console.log('/reserves/admin get req.params', req.params) + Reserve.find({ approve: false }).populate('user').exec(function (err, reserve) { + if (err) return res.status(500).json({ error: err }); + console.log('reserve list', reserve) + res.status(201).json(reserve); + }) + }); + + export default router \ No newline at end of file -- GitLab