λ΄λ Έλ© μλμ μΈμ , μ΄λμλ μΈλ¬Ένμ μμμ κΈ°λ₯Ό μ μκ³ μ§μν μν΅μ ν μ μλ 곡κ°, λ§λ£¨μ λλ€.
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 - λ¬Έμ νΈμ§