Jeongmin Seo

Update release_v0.2.0

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