๋ด๋ ธ๋ฉ ์๋์ ์ธ์ , ์ด๋์๋ ์ธ๋ฌธํ์ ์์์ ๊ธฐ๋ฅผ ์ ์๊ณ ์ง์ํ ์ํต์ ํ ์ ์๋ ๊ณต๊ฐ, ๋ง๋ฃจ์ ๋๋ค.
MARU๋ ๋ํ์ ์ฐํฉ IT ๋ฒค์ฒ์ฐฝ์ ๋์๋ฆฌ SOPT ๋ด์์ ์ ํ๋ฆฌ์ผ์ด์ ๊ฐ๋ฐ ํ๋ก์ ํธ๋ฅผ ํจ๊ปํ ๋ฉค๋ฒ๋ค๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค.
ํ ๋จ์์ ํ์ ์ ๊ฐ์ด ๊ฒฝํํ๊ณ ๋ค์ํ ๊ด์ ๋ค์ ๊ณต์ ํ ์ ํฌ๋ โ๋ง๋ฃจโ๋ฅผ ๊ฐ๋ฐํ๋ฉด์ ๋ค์ ํ ๋ฒ ํ ๋จ์์ ์ญ๋์ ๋ฐฐ์ํ ์ ์์์ต๋๋ค.
Project Period : 2020.08~2020.09
์์ผํต์ ์ ์ด์ฉํ ํ ๋ก - ์ ํจ์
// 'connection' ์ด๋ฒคํธ ๋ฐ์
io.on('connection', (socket) => {
// ํด๋ผ์ด์ธํธ ์ ์ ๋์ ์ on('disconnect') ๋ฐ์
socket.on('disconnect', () => {
console.log('user disconnected');
});
// room ๋๊ฐ๊ธฐ : socket.leave
socket.on('leaveRoom', (roomIdx, name) => {
socket.leave(room[roomIdx], () => {
io.to(room[roomIdx]).emit('leaveRoom', roomIdx, name);
});
});
// ํ ๋ก ์์ ๋ฒ์ด๋ ์๊ฐ ์ฒดํฌ
socket.on('leave', (name, roomIdx) => {
var date=new Date();
let disconnectTime = moment(date).format('YYYY-MM-DD HH:mm:ss');
//๋๋น ํต์ ๋ถ๋ถ
});
// ํน์ room ์๊ฒ ์ด๋ฒคํธ ๋ณด๋ผ ์ : io.to('room์ด๋ฆ').emit()
socket.on('joinRoom', (roomIdx, name) => {
socket.join(room[roomIdx], () => {
room.push('room'+roomIdx);
io.to(room[roomIdx]).emit('joinRoom', roomIdx,name);
});
});
//ํด๋ผ : socket.emit('chat message') , ์๋ฒ : socket.on('chat message') ๋งค๊ฐ๋ณ์ : name, msg, roomIdx
socket.on('chat message', (name, msg, roomIdx) => {
a=roomIdx;
var date = new Date();
let chatTime = moment(date).format('YYYY-MM-DD HH:mm:ss');
//๋๋น ํต์ ๋ถ๋ถ
io.to(room[a]).emit('chat message', name, msg);
});
});
});
KAKAO API๋ฅผ ์ด์ฉํ ์ฑ ๊ฒ์ - ์ต์ ๊ท
const options = {
kakaoTest: async(title) => {
return {
url: `https://dapi.kakao.com/v3/search/book?target=title`,
method: 'GET',
headers: {
'Authorization': '',
},
qs: {
query : title,
},
encoding: 'UTF-8',
}
}
}
module.exports = options;
request(kakao, function (err, response, body) {
if (!err && response.statusCode == 200) {
const book = JSON.parse(body).documents;
// ๊ฒ์ํ ๊ฒฐ๊ณผ๊ฐ ์กด์ฌํ์ง ์์ ๋
if (book.length === 0) {
res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, resMessage.NO_SEARCH));
return;
}
// ๊ฒ์ ๊ฒฐ๊ณผ๊ฐ ์กด์ฌํ ๋
bookList = [];
for (let item of book) {
bookList.push({
authors : item.authors[0],
title : item.title,
thumbnail : item.thumbnail
})
}
res.status(statusCode.OK).send(util.success(statusCode.OK, resMessage.SUCCESS_SEARCH, bookList))
}
Firebase๋ฅผ ์ด์ฉํ ์๋ฆผ ๊ตฌํ - ์์์ง
try {
const deviceTokens = await alarmModel.getDeviceToken(roomIdx, nickName);
const registrationTokens = []; //๋๋ฐ์ด์ค ๋ฑ๋ก
for (let i = 0; i < deviceTokens.length; ++i) {
if (deviceTokens[i].deviceToken == null) {
res.status(statusCode.DB_ERROR).send(util.fail(statusCode.DB_ERROR, resMessage.INTERNAL_SERVER_ERROR));
return;
}
registrationTokens.push(deviceTokens[i].deviceToken);
}
if (!admin.apps.length) {
admin.initializeApp({
credential: admin.credential.cert(firebaseConfig),
databaseURL: ""
});
}
var options = {
priority: 'high',
timeToLive: 60 * 60 * 24 * 2
};
//payload
var payload = {
notification: {
title: title,
body: nickName + " : " + message,
},
};
"dependencies": {
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"dotenv": "^8.2.0",
"ejs": "^3.1.5",
"express": "~4.16.1",
"fcm-node": "^1.5.2",
"firebase-admin": "^9.2.0",
"http-errors": "^1.6.3",
"jsonwebtoken": "^8.5.1",
"moment": "^2.27.0",
"moment-timezone": "^0.5.31",
"morgan": "~1.9.1",
"nodemon": "^2.0.4",
"pbkdf2": "^3.1.1",
"promise-mysql": "^4.1.3",
"rand-token": "^1.0.1",
"request": "^2.88.2",
"serve-favicon": "^2.5.0",
"socket.io": "^2.3.0"
}
- Coding Convention
- Git Convention
โnaming
1. **๋ณ์๋ช
, ํ์ผ๋ช
** : ์นด๋ฉ์ผ์ด์ค (`inputBox`)
2. **ํด๋๋ช
** : ์๋ฌธ์ (`inputbox`)
3. **ํด๋์ค๋ช
** : ์ฒซ๊ธ์ ๋๋ฌธ์ (`InputBox`)
- var ๋ณด๋ค๋ let, const ์งํฅ
- ๋น๋๊ธฐ
- promise์ then๋ณด๋ค๋ async/await ์ฌ์ฉ
branch
- master
- develop
- feature_jg
- feature_yz
- feature_hw
Commit Message
CREATE - ๊ธฐ๋ฅ ๊ตฌํ
UPDATE - ์ฝ๋ ์์
MERGE - ์ฝ๋ ๋ณํฉ
FIX - ๋ฒ๊ทธ ์์
RELEASE - ๋ฒ์ ๋ฐฐํฌ
DELETE - ๊ธฐ๋ฅ ์ญ์
DOCS - ๋ฌธ์ ํธ์ง