Showing
12 changed files
with
114 additions
and
94 deletions
... | @@ -49,8 +49,7 @@ io.on('connection', (socket) => { | ... | @@ -49,8 +49,7 @@ io.on('connection', (socket) => { |
49 | io.emit("chatting", { | 49 | io.emit("chatting", { |
50 | name, | 50 | name, |
51 | msg, | 51 | msg, |
52 | - time: moment.format("h:ss A") | 52 | + time : moment(new Date()).format("h:ss A")}) |
53 | - }) | ||
54 | }) | 53 | }) |
55 | }); | 54 | }); |
56 | 55 | ... | ... |
... | @@ -12,30 +12,32 @@ class User { | ... | @@ -12,30 +12,32 @@ class User { |
12 | 12 | ||
13 | async login() { | 13 | async login() { |
14 | const client = this.body; | 14 | const client = this.body; |
15 | - | 15 | + |
16 | try { | 16 | try { |
17 | - try { | 17 | + const connection = await pool.getConnection(async (conn) => conn); |
18 | - const {id, password} = await UserStorage.getUserInfo(connection, client.id); | 18 | + try { |
19 | - // console.log(id, password); | 19 | + const { id, password } = await UserStorage.getUserInfo( |
20 | - | 20 | + connection, |
21 | - if (id) { | 21 | + client.id |
22 | - if (id === client.id && password === client.password) { | 22 | + ); |
23 | - return { success: true}; | 23 | + if (id) { |
24 | - } | 24 | + if (id === client.id && password === client.password) { |
25 | - return { success : false, msg: "비밀번호가 틀렸습니다."}; | 25 | + return { success: true }; |
26 | - } | 26 | + } |
27 | - return {success: false, msg: "존재하지 않는 아이디입니다."}; | 27 | + return { success: false, msg: "비밀번호가 틀렸습니다." }; |
28 | - } catch (err) { | ||
29 | - return {success: false, msg: err}; | ||
30 | - } finally { | ||
31 | - connection.release(); | ||
32 | } | 28 | } |
33 | - } catch (err) { | 29 | + return { success: false, msg: "존재하지 않는 아이디입니다." }; |
34 | - logger.error(`login DB Connection error\n: ${JSON.stringify(err)}`); | 30 | + } catch (err) { |
35 | - return false; | 31 | + return { success: false, msg: err }; |
32 | + } finally { | ||
33 | + connection.release(); | ||
36 | } | 34 | } |
37 | - } | 35 | + } catch (err) { |
38 | - | 36 | + logger.error(`login DB Connection error\n: ${JSON.stringify(err)}`); |
37 | + return false; | ||
38 | + } | ||
39 | + } | ||
40 | + | ||
39 | async register() { | 41 | async register() { |
40 | const client = this.body; | 42 | const client = this.body; |
41 | try { | 43 | try { | ... | ... |
... | @@ -13,16 +13,18 @@ class UserStorage { | ... | @@ -13,16 +13,18 @@ class UserStorage { |
13 | 13 | ||
14 | // static getUsers(isAll, ...fields) {} | 14 | // static getUsers(isAll, ...fields) {} |
15 | static async getUserInfo(connection, id) { | 15 | static async getUserInfo(connection, id) { |
16 | - return new Promise((resolve, reject) => { | 16 | + const query = `SELECT * FROM users WHERE id = '${id}';`; |
17 | - const query = "SELECT * FROM users WHERE id = ?;"; | 17 | + console.log(query); |
18 | - connection.query(query, [id], (err, data) => { | 18 | + let [row] = await connection.query(query); |
19 | - if (err) reject(`${err}`); | 19 | + console.log(row[0]); |
20 | - // console.log(data[0]); | 20 | + return row[0]; |
21 | - resolve(data[0]); | 21 | + // , [id], (err, data) => { |
22 | - pool.releaseConnection(conn); | 22 | + // console.log("44444444"); |
23 | - }); | 23 | + // if (err) reject(`${err}`); |
24 | - }); | 24 | + // resolve(data[0]); |
25 | - } | 25 | + // pool.releaseConnection(conn); |
26 | + // }); | ||
27 | + } | ||
26 | 28 | ||
27 | static async save (connection, userInfo) { | 29 | static async save (connection, userInfo) { |
28 | const query = "INSERT INTO users(id, name, password) VALUES(?, ?, ?);"; | 30 | const query = "INSERT INTO users(id, name, password) VALUES(?, ?, ?);"; | ... | ... |
... | @@ -7,13 +7,15 @@ | ... | @@ -7,13 +7,15 @@ |
7 | } | 7 | } |
8 | 8 | ||
9 | .infowindow-title { | 9 | .infowindow-title { |
10 | - font-size: 3rem; | 10 | + font-size: 15px; |
11 | + color: rebeccapurple; | ||
12 | + font-weight: 600; | ||
11 | } | 13 | } |
12 | 14 | ||
13 | .infowindow-address { | 15 | .infowindow-address { |
14 | - font-size: 1.6rem; | 16 | + font-size: 8px; |
15 | } | 17 | } |
16 | 18 | ||
17 | .infowindow-btn { | 19 | .infowindow-btn { |
18 | - font-size: 1.6rem; | 20 | + font-size: 8px; |
19 | } | 21 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -4,8 +4,8 @@ | ... | @@ -4,8 +4,8 @@ |
4 | 4 | ||
5 | var container = document.getElementById('map'); //지도를 담을 영역의 DOM 레퍼런스 | 5 | var container = document.getElementById('map'); //지도를 담을 영역의 DOM 레퍼런스 |
6 | var options = { //지도를 생성할 때 필요한 기본 옵션 | 6 | var options = { //지도를 생성할 때 필요한 기본 옵션 |
7 | - center: new kakao.maps.LatLng(37.54, 126.96), //지도의 중심좌표. | 7 | + center: new kakao.maps.LatLng(37.248, 127.08), //지도의 중심좌표. |
8 | - level: 7 //지도의 레벨(확대, 축소 정도) | 8 | + level: 4 //지도의 레벨(확대, 축소 정도) |
9 | }; | 9 | }; |
10 | 10 | ||
11 | var map = new kakao.maps.Map(container, options); //지도 생성 및 객체 리턴 | 11 | var map = new kakao.maps.Map(container, options); //지도 생성 및 객체 리턴 |
... | @@ -18,41 +18,44 @@ | ... | @@ -18,41 +18,44 @@ |
18 | * 2. 데이터 준비하기(제목, 주소, 카테고리) | 18 | * 2. 데이터 준비하기(제목, 주소, 카테고리) |
19 | */ | 19 | */ |
20 | 20 | ||
21 | -const dataSet = [ | 21 | +// const dataSet = [ |
22 | - { | 22 | +// { |
23 | - title: "희락돈까스", | 23 | +// title: "희락돈까스", |
24 | - address: "서울 영등포구 양산로 210", | 24 | +// address: "서울 영등포구 양산로 210", |
25 | - category: "양식", | 25 | +// category: "양식", |
26 | - }, | 26 | +// }, |
27 | - { | 27 | +// { |
28 | - title: "즉석우동짜장", | 28 | +// title: "즉석우동짜장", |
29 | - address: "서울 영등포구 대방천로 260", | 29 | +// address: "서울 영등포구 대방천로 260", |
30 | - category: "한식", | 30 | +// category: "한식", |
31 | - }, | 31 | +// }, |
32 | - { | 32 | +// { |
33 | - title: "아카사카", | 33 | +// title: "아카사카", |
34 | - address: "서울 서초구 서초대로74길 23", | 34 | +// address: "서울 서초구 서초대로74길 23", |
35 | - category: "일식", | 35 | +// category: "일식", |
36 | - } | ||
37 | -]; | ||
38 | - | ||
39 | -// async function getDataSet(category) { | ||
40 | -// let qs = category; | ||
41 | -// if(!qs) { | ||
42 | -// qs = ""; | ||
43 | // } | 36 | // } |
37 | +// ]; | ||
44 | 38 | ||
45 | -// const dataSet = await axios({ | 39 | + async function getDataSet(category) { |
46 | -// method: "get", // http method | 40 | + let qs = category; |
47 | -// url: `http://localhost:3000/restaurants?category=${qs}`, | 41 | + if(!qs) { |
48 | -// headers: {}, | 42 | + qs = ""; |
49 | -// data: {}, | 43 | + } |
50 | -// }); | 44 | + |
45 | + const dataSet = await axios({ | ||
46 | + method: "get", // http method | ||
47 | + url: `http://localhost:3000/restaurants?category=${qs}`, | ||
48 | + headers: {}, | ||
49 | + data: {}, | ||
50 | + }); | ||
51 | + // console.log(dataSet); | ||
52 | + | ||
53 | + return dataSet.data.result; | ||
54 | +} | ||
51 | 55 | ||
52 | -// return dataSet.data.result; | ||
53 | // } | 56 | // } |
54 | 57 | ||
55 | -// getDataSet(); | 58 | + getDataSet(); |
56 | 59 | ||
57 | /****************************************************************************** | 60 | /****************************************************************************** |
58 | * 3. 여러개 마커찍기 | 61 | * 3. 여러개 마커찍기 |
... | @@ -75,7 +78,7 @@ const dataSet = [ | ... | @@ -75,7 +78,7 @@ const dataSet = [ |
75 | }); | 78 | }); |
76 | } | 79 | } |
77 | 80 | ||
78 | - setMap(dataSet); | 81 | +// setMap(dataSet); |
79 | 82 | ||
80 | /* | 83 | /* |
81 | ************************************************************* | 84 | ************************************************************* |
... | @@ -170,6 +173,7 @@ const dataSet = [ | ... | @@ -170,6 +173,7 @@ const dataSet = [ |
170 | const categoryId = event.target.id; | 173 | const categoryId = event.target.id; |
171 | const category = categoryMap[categoryId]; | 174 | const category = categoryMap[categoryId]; |
172 | 175 | ||
176 | + | ||
173 | try { | 177 | try { |
174 | // 데이터 분류 | 178 | // 데이터 분류 |
175 | let categorizedDataSet = await getDataSet(category); | 179 | let categorizedDataSet = await getDataSet(category); |
... | @@ -194,16 +198,13 @@ const dataSet = [ | ... | @@ -194,16 +198,13 @@ const dataSet = [ |
194 | } | 198 | } |
195 | } | 199 | } |
196 | 200 | ||
197 | - setMap(dataSet); | 201 | + async function setting() { |
198 | - | 202 | + try { |
199 | -// async function setting() { | 203 | + const dataSet = await getDataSet(); |
200 | -// try { | 204 | + setMap(dataSet); |
201 | -// const dataSet = await getDataSet(); | 205 | + } catch (error) { |
202 | -// setMap(dataSet); | 206 | + console.error(error); |
203 | - | 207 | + } |
204 | -// } catch (error) { | 208 | + } |
205 | -// console.error(error); | ||
206 | -// } | ||
207 | -// } | ||
208 | 209 | ||
209 | -// setting(); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
210 | + setting(); | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | -"use strict" | 1 | +"use strict"; |
2 | -const socket = io.connect("http://localhost:3000/", {transports:['websocket']}); | 2 | + |
3 | +const socketIO = require("socket.io"); | ||
4 | +const http = require("http"); | ||
5 | +const app = express(); | ||
6 | +const server = http.createServer(app); | ||
7 | +const io = socketIO(server); | ||
8 | +const socket = io(); | ||
9 | +//.connect("http://localhost:3000/chat", {transports:['websocket']}); | ||
3 | 10 | ||
4 | const nickname = document.querySelector("#nickname") | 11 | const nickname = document.querySelector("#nickname") |
5 | const chatlist = document.querySelector(".chatting-list") | 12 | const chatlist = document.querySelector(".chatting-list") | ... | ... |
... | @@ -25,15 +25,12 @@ async function register() { | ... | @@ -25,15 +25,12 @@ async function register() { |
25 | return alert("비밀번호가 일치하지 않습니다.") | 25 | return alert("비밀번호가 일치하지 않습니다.") |
26 | } | 26 | } |
27 | 27 | ||
28 | - console.log(1); | ||
29 | const req = { | 28 | const req = { |
30 | id: id.value, | 29 | id: id.value, |
31 | name: name.value, | 30 | name: name.value, |
32 | password: password.value, | 31 | password: password.value, |
33 | }; | 32 | }; |
34 | 33 | ||
35 | - console.log("여기 안찍히나????"); | ||
36 | - | ||
37 | fetch("/register", { | 34 | fetch("/register", { |
38 | method: "POST", | 35 | method: "POST", |
39 | headers: { | 36 | headers: { | ... | ... |
... | @@ -16,6 +16,10 @@ const output = { | ... | @@ -16,6 +16,10 @@ const output = { |
16 | res.render("home/register"); | 16 | res.render("home/register"); |
17 | }, | 17 | }, |
18 | 18 | ||
19 | + chat: (req, res) => { | ||
20 | + res.render("home/chat"); | ||
21 | + }, | ||
22 | + | ||
19 | // restaurants: (req, res) => { | 23 | // restaurants: (req, res) => { |
20 | // res.render("home/restaurants"); | 24 | // res.render("home/restaurants"); |
21 | // } | 25 | // } | ... | ... |
... | @@ -12,6 +12,7 @@ router.get("/", ctrl.output.hello); | ... | @@ -12,6 +12,7 @@ router.get("/", ctrl.output.hello); |
12 | router.get("/login", ctrl.output.login); | 12 | router.get("/login", ctrl.output.login); |
13 | router.get("/register", ctrl.output.register); | 13 | router.get("/register", ctrl.output.register); |
14 | router.get("/restaurants", index.readRestaurants); | 14 | router.get("/restaurants", index.readRestaurants); |
15 | +router.get("/chat", ctrl.output.chat); | ||
15 | // router.get("/restaurants", Restaurant.restaurants); | 16 | // router.get("/restaurants", Restaurant.restaurants); |
16 | // router.get("/restaurants", ctrl.output.restaurants); | 17 | // router.get("/restaurants", ctrl.output.restaurants); |
17 | 18 | ... | ... |
... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
4 | <meta charset="UTF-8" /> | 4 | <meta charset="UTF-8" /> |
5 | <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | 5 | <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
6 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
7 | - <title>Document</title> | 7 | + <title>채팅방</title> |
8 | <link rel="stylesheet" href="/css/home/chat.css" /> | 8 | <link rel="stylesheet" href="/css/home/chat.css" /> |
9 | </head> | 9 | </head> |
10 | <body> | 10 | <body> |
... | @@ -23,8 +23,12 @@ | ... | @@ -23,8 +23,12 @@ |
23 | </span> | 23 | </span> |
24 | </div> | 24 | </div> |
25 | </div> | 25 | </div> |
26 | - | 26 | + <script |
27 | - <script src="/socket.io/socket.io.js"></script> | 27 | + src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.1/socket.io.js" |
28 | + integrity="sha512-9mpsATI0KClwt+xVZfbcf2lJ8IFBAwsubJ6mI3rtULwyM3fBmQFzj0It4tGqxLOGQwGfJdk/G+fANnxfq9/cew==" | ||
29 | + crossorigin="anonymous" | ||
30 | + referrerpolicy="no-referrer" | ||
31 | + ></script> | ||
28 | <script src="/js/home/chat.js"></script> | 32 | <script src="/js/home/chat.js"></script> |
29 | </body> | 33 | </body> |
30 | </html> | 34 | </html> | ... | ... |
... | @@ -9,13 +9,14 @@ | ... | @@ -9,13 +9,14 @@ |
9 | <meta name="description" content="맛집지도 서비스" /> | 9 | <meta name="description" content="맛집지도 서비스" /> |
10 | <meta name="keywords" content="맛집지도, 맛집추천, 실시간채팅" /> | 10 | <meta name="keywords" content="맛집지도, 맛집추천, 실시간채팅" /> |
11 | <link rel="stylesheet" href="/css/home/index.css" /> | 11 | <link rel="stylesheet" href="/css/home/index.css" /> |
12 | + <link rel="stylesheet" href="/css/home/map.css" /> | ||
12 | </head> | 13 | </head> |
13 | <body> | 14 | <body> |
14 | <nav> | 15 | <nav> |
15 | <div class="inner"> | 16 | <div class="inner"> |
16 | <div class="nav-container"> | 17 | <div class="nav-container"> |
17 | <h1 class="nav-title">맛집지도</h1> | 18 | <h1 class="nav-title">맛집지도</h1> |
18 | - <button class="nav-contact">Chatting Rooms</button> | 19 | + <button class="nav-contact">Contact : balljm@naver.com</button> |
19 | </div> | 20 | </div> |
20 | </div> | 21 | </div> |
21 | </nav> | 22 | </nav> |
... | @@ -48,12 +49,12 @@ | ... | @@ -48,12 +49,12 @@ |
48 | type="text/javascript" | 49 | type="text/javascript" |
49 | src="//dapi.kakao.com/v2/maps/sdk.js?appkey=e55f753363b95e27b799aa6286a6c398&libraries=services" | 50 | src="//dapi.kakao.com/v2/maps/sdk.js?appkey=e55f753363b95e27b799aa6286a6c398&libraries=services" |
50 | ></script> | 51 | ></script> |
51 | - <script src="/js/home/axios-index.js"></script> | 52 | + <script |
52 | - <!-- <script | ||
53 | src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.0.0-alpha.1/axios.min.js" | 53 | src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.0.0-alpha.1/axios.min.js" |
54 | integrity="sha512-xIPqqrfvUAc/Cspuj7Bq0UtHNo/5qkdyngx6Vwt+tmbvTLDszzXM0G6c91LXmGrRx8KEPulT+AfOOez+TeVylg==" | 54 | integrity="sha512-xIPqqrfvUAc/Cspuj7Bq0UtHNo/5qkdyngx6Vwt+tmbvTLDszzXM0G6c91LXmGrRx8KEPulT+AfOOez+TeVylg==" |
55 | crossorigin="anonymous" | 55 | crossorigin="anonymous" |
56 | referrerpolicy="no-referrer" | 56 | referrerpolicy="no-referrer" |
57 | - ></script> --> | 57 | + ></script> |
58 | + <script src="/js/home/axios-index.js"></script> | ||
58 | </body> | 59 | </body> |
59 | </html> | 60 | </html> | ... | ... |
-
Please register or login to post a comment