From 2814a1026e8837ab966e8525012141c3c92c9373 Mon Sep 17 00:00:00 2001 From: Youjung Heo Date: Sat, 6 Aug 2022 15:45:04 +0900 Subject: [PATCH 01/27] =?UTF-8?q?del:>=20console.log=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20#191?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/db/linkAnswerKeywordDB.js | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/db/linkAnswerKeywordDB.js b/functions/db/linkAnswerKeywordDB.js index 6730c83..c078e00 100644 --- a/functions/db/linkAnswerKeywordDB.js +++ b/functions/db/linkAnswerKeywordDB.js @@ -58,7 +58,6 @@ const getTopKeywordListOnAnswer = async (client, userId) => { ORDER BY l.count_keyword_id DESC LIMIT 3 `); - console.log(rows); return convertSnakeToCamel.keysToCamel(rows); }; From a653e3b45fc0c8c88c141a9b0aca79955bbe05f5 Mon Sep 17 00:00:00 2001 From: Youjung Heo Date: Sat, 6 Aug 2022 16:08:11 +0900 Subject: [PATCH 02/27] =?UTF-8?q?chore:>=20=EC=B4=88=EB=8C=80=EC=A4=91?= =?UTF-8?q?=EC=9D=B8=20=ED=8C=80=EC=9B=90=EB=8F=84=20=ED=8C=80=EC=9B=90=20?= =?UTF-8?q?=EA=B4=80=EB=A6=AC=20=EC=B0=BD=EC=97=90=EC=84=9C=20=EB=B3=B4?= =?UTF-8?q?=EC=9D=B4=EB=8F=84=EB=A1=9D=20=EC=B6=94=EA=B0=80=20#191?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/db/memberDB.js | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/db/memberDB.js b/functions/db/memberDB.js index dc797e6..c414582 100644 --- a/functions/db/memberDB.js +++ b/functions/db/memberDB.js @@ -56,7 +56,6 @@ const getAllTeamMemberByTeamId = async (client, teamId) => { WHERE m.team_id = $1 AND m.is_deleted = false AND u.is_deleted = false - AND m.is_confirmed = true `, [teamId], ); From 5f3d0b2d7e55d922bf1f1c7388e4d30005771859 Mon Sep 17 00:00:00 2001 From: Youjung Heo Date: Sat, 6 Aug 2022 16:17:59 +0900 Subject: [PATCH 03/27] =?UTF-8?q?chore:>=20=EC=B4=88=EB=8C=80=20=EA=B1=B0?= =?UTF-8?q?=EC=A0=88=20=EB=B0=8F=20=ED=8C=80=20=ED=83=88=ED=87=B4=ED=95=9C?= =?UTF-8?q?=20=EC=9C=A0=EC=A0=80=20=EA=B2=80=EC=83=89=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8F=B0=EC=8A=A4=EC=97=90=20=EC=B6=94=EA=B0=80=20#191?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/db/userDB.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/db/userDB.js b/functions/db/userDB.js index 3e60687..fdf7b04 100644 --- a/functions/db/userDB.js +++ b/functions/db/userDB.js @@ -113,7 +113,8 @@ const getUserListByProfileIdTeamId = async (client, profileId, userId, teamId, o AND u.is_deleted = FALSE AND id NOT IN (SELECT user_id FROM member - WHERE team_id = $3) + WHERE team_id = $3 + AND is_deleted = false) ) OFFSET $5 LIMIT $4; `, From 36d5c3622c426ebb900ed015bdee97c96734a807 Mon Sep 17 00:00:00 2001 From: Youjung Heo Date: Sat, 6 Aug 2022 16:37:28 +0900 Subject: [PATCH 04/27] =?UTF-8?q?chore:>=20=ED=8C=80=EC=9B=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=EC=8B=9C=20=EC=9C=A0=EC=A0=80=20=EC=97=86=EB=8A=94=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=EC=97=90=EC=84=9C=20=EC=99=84=EB=A3=8C=20?= =?UTF-8?q?=EB=88=84=EB=A5=B4=EB=A9=B4=20500=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#191?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/team/teamMemberEditPOST.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/api/routes/team/teamMemberEditPOST.js b/functions/api/routes/team/teamMemberEditPOST.js index aa83514..b5f5e58 100644 --- a/functions/api/routes/team/teamMemberEditPOST.js +++ b/functions/api/routes/team/teamMemberEditPOST.js @@ -11,7 +11,7 @@ module.exports = async (req, res) => { const user = req.user; const { teamId, userIdList } = req.body; - if (!user || !teamId || !userIdList) return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.NULL_VALUE)); + if (!user || !teamId || userIdList === 0) return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.NULL_VALUE)); let client; From 31db72caca1411e20ea1231ca2346b4ba835eb79 Mon Sep 17 00:00:00 2001 From: Youjung Heo Date: Sat, 6 Aug 2022 16:47:21 +0900 Subject: [PATCH 05/27] =?UTF-8?q?chore:>=20=ED=8C=80=EC=9B=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=EC=8B=9C=20=EC=9C=A0=EC=A0=80=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=EB=94=94=20=EC=97=86=EC=9C=BC=EB=A9=B4=20=EB=B9=88=EB=B0=B0?= =?UTF-8?q?=EC=97=B4=20=EB=A6=AC=ED=84=B4=20#191?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/db/memberDB.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/db/memberDB.js b/functions/db/memberDB.js index c414582..b133297 100644 --- a/functions/db/memberDB.js +++ b/functions/db/memberDB.js @@ -80,7 +80,7 @@ const addHostMember = async (client, teamId, userId) => { //^_^// 팀에 멤버를 추가하는 쿼리 const addMember = async (client, teamId, userIdList) => { - if (!userIdList) { + if (userIdList.length === 0) { return []; } From b2e73c2e58876d8fb17ce3c1be2dcd4e9396e549 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Sat, 6 Aug 2022 16:51:37 +0900 Subject: [PATCH 06/27] =?UTF-8?q?fix:>=20=EC=82=AD=EC=A0=9C=20=EB=90=9C=20?= =?UTF-8?q?=ED=82=A4=EC=9B=8C=EB=93=9C=20=EC=A1=B0=ED=9A=8C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=ED=95=B4=EA=B2=B0=20#201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/db/linkFeedbacKeywordDB.js | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/db/linkFeedbacKeywordDB.js b/functions/db/linkFeedbacKeywordDB.js index d24fc61..8e81f92 100644 --- a/functions/db/linkFeedbacKeywordDB.js +++ b/functions/db/linkFeedbacKeywordDB.js @@ -41,6 +41,7 @@ const getKeywordsWithFeedbackIdList = async (client, feedbackIds) => { JOIN color ON keyword.color_id = color.id WHERE link_feedback_keyword.feedback_id IN (${feedbackIds.join()}) AND link_feedback_keyword.is_deleted = false + AND keyword.is_deleted = false `); return convertSnakeToCamel.keysToCamel(rows); }; From 18adb785c9702f1ee4441c1ace2d979ff57da6b5 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Sat, 6 Aug 2022 17:04:31 +0900 Subject: [PATCH 07/27] add:> cors #201 --- functions/api/index.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/functions/api/index.js b/functions/api/index.js index 17fe622..8c039ff 100644 --- a/functions/api/index.js +++ b/functions/api/index.js @@ -1,11 +1,11 @@ // 각종 모듈들 -const functions = require("firebase-functions"); -const express = require("express"); -const cors = require("cors"); -const cookieParser = require("cookie-parser"); -const dotenv = require("dotenv"); -const hpp = require("hpp"); -const helmet = require("helmet"); +const functions = require('firebase-functions'); +const express = require('express'); +const cors = require('cors'); +const cookieParser = require('cookie-parser'); +const dotenv = require('dotenv'); +const hpp = require('hpp'); +const helmet = require('helmet'); // 보안 상 깃허브에 올리면 안 되는 정보를 .env라는 파일로 관리하기 위해 사용하는 모듈 dotenv.config(); @@ -15,11 +15,15 @@ const app = express(); // Cross-Origin Resource Sharing을 열어주는 미들웨어 // https://evan-moon.github.io/2020/05/21/about-cors/ 에서 자세한 정보 확인 -app.use(cors()); +const corsOpt = function (req, callback) { + callback(null, { origin: true }); +}; + +app.use(cors(corsOpt)); // 보안을 위한 미들웨어들 // process.env.NODE_ENV는 배포된 서버에서는 'production'으로, 로컬에서 돌아가는 서버에서는 'development'로 고정됨. -if (process.env.NODE_ENV === "production") { +if (process.env.NODE_ENV === 'production') { app.use(hpp()); app.use(helmet()); } @@ -30,15 +34,15 @@ app.use(express.urlencoded({ extended: true })); app.use(cookieParser()); // 라우팅: routes 폴더로 관리 -app.use("/", require("./routes")); +app.use('/', require('./routes')); // route 폴더에 우리가 지정할 경로가 아닌 다른 경로로 요청이 올 경우, // 잘못된 경로로 요청이 들어왔다는 메시지를 클라이언트에 보냄 -app.use("*", (req, res) => { +app.use('*', (req, res) => { res.status(404).json({ status: 404, success: false, - message: "잘못된 경로입니다.", + message: '잘못된 경로입니다.', }); }); @@ -46,13 +50,13 @@ app.use("*", (req, res) => { module.exports = functions .runWith({ timeoutSeconds: 300, // 요청을 처리하는 과정이 300초를 초과하면 타임아웃 시키기 - memory: "512MB", // 서버에 할당되는 메모리 + memory: '512MB', // 서버에 할당되는 메모리 }) - .region("asia-northeast3") // 서버가 돌아갈 region. asia-northeast3는 서울 + .region('asia-northeast3') // 서버가 돌아갈 region. asia-northeast3는 서울 .https.onRequest(async (req, res) => { // 들어오는 요청에 대한 로그를 콘솔에 찍기. 디버깅 때 유용하게 쓰일 예정. // 콘솔에 찍고 싶은 내용을 원하는 대로 추가하면 됨. (req.headers, req.query 등) - console.log("\n\n", "[api]", `[${req.method.toUpperCase()}]`, req.originalUrl, req.body); + console.log('\n\n', '[api]', `[${req.method.toUpperCase()}]`, req.originalUrl, req.body); // 맨 위에 선언된 express app 객체를 리턴. // 요것이 functions/index.js 안의 api: require("./api")에 들어가는 것. From 9bd3ced47e95994a02abcd3c5fea62a149478f4e Mon Sep 17 00:00:00 2001 From: Youjung Heo Date: Sat, 6 Aug 2022 17:19:34 +0900 Subject: [PATCH 08/27] =?UTF-8?q?fix:>=20=EC=9D=B4=EB=AF=B8=20=EC=B4=88?= =?UTF-8?q?=EB=8C=80=EB=90=9C=20=EC=9C=A0=EC=A0=80=EC=97=90=EA=B2=8C=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=EC=9C=BC=EB=A1=9C=20=EC=B4=88=EB=8C=80=20?= =?UTF-8?q?=EB=82=A0=EB=A6=AC=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80=20#191?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/routes/team/teamMemberEditPOST.js | 17 +++++++++++++- functions/db/memberDB.js | 22 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/functions/api/routes/team/teamMemberEditPOST.js b/functions/api/routes/team/teamMemberEditPOST.js index b5f5e58..aa9dc5f 100644 --- a/functions/api/routes/team/teamMemberEditPOST.js +++ b/functions/api/routes/team/teamMemberEditPOST.js @@ -6,6 +6,11 @@ const db = require('../../../db/db'); const slackAPI = require('../../../lib/slackAPI'); const { memberDB } = require('../../../db'); +const extractValues = (arr, key) => { + if (!Array.isArray(arr)) return [arr[key] || null]; + return [...new Set(arr.map((o) => o[key]).filter(Boolean))]; +}; + module.exports = async (req, res) => { const user = req.user; @@ -30,8 +35,18 @@ module.exports = async (req, res) => { //^_^// userIdList 중복 제거 const uniqueUserIdList = [ ... new Set(JSON.parse(userIdList))]; + //^_^// 이미 초대가 날라갔는지 확인 + const duplicateMember = await memberDB.checkDuplicateMemeber(client, teamId, uniqueUserIdList); + + const duplicateMemberUserId = extractValues(duplicateMember, 'userId'); + + const uniqueDuplicateMember = [ ... new Set(duplicateMemberUserId)]; + + const notInvitedUserId = uniqueUserIdList + .filter( x => x != uniqueDuplicateMember ); + //^_^// 새로운 유저 멤버로 추가 - const newMemberData = await memberDB.addMember(client, teamId, uniqueUserIdList); + const newMemberData = await memberDB.addMember(client, teamId, notInvitedUserId); const resultData = { member: newMemberData diff --git a/functions/db/memberDB.js b/functions/db/memberDB.js index b133297..0af26a9 100644 --- a/functions/db/memberDB.js +++ b/functions/db/memberDB.js @@ -87,7 +87,6 @@ const addMember = async (client, teamId, userIdList) => { const valuesInsertQuery = userIdList .map((x) => `(${teamId}, ${x})`) .join(', '); - console.log(valuesInsertQuery); const { rows: resultRows } = await client.query( ` INSERT INTO member @@ -237,6 +236,26 @@ const getMemberByTeamId = async (client, teamId) => { return convertSnakeToCamel.keysToCamel(rows); }; +const checkDuplicateMemeber = async (client, teamId, userIdList) => { + const valuesInsertQuery = '(' + userIdList + .map((x) => `${x}`) + .join(', ') + + ')'; + + const { rows } = await client.query( + ` + SELECT user_id + FROM member m + WHERE team_id = $1 + AND user_id in ${valuesInsertQuery} + AND is_deleted = false + `, + [teamId], + ); + + return convertSnakeToCamel.keysToCamel(rows); +}; + module.exports = { getAllTeamByUserId, getAllTeamMemberByTeamId, @@ -252,4 +271,5 @@ module.exports = { getInvitedTeamIdList, getAllInvitedTeamIdList, getMemberByTeamId, + checkDuplicateMemeber, }; From 5604cf2ab2e61df88faa56fe1bde5fc8c512266b Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Sun, 7 Aug 2022 16:33:45 +0900 Subject: [PATCH 09/27] add:> sharp resize, rotate #204 --- functions/.eslintrc.js | 34 ++-- functions/middlewares/uploadImage.js | 6 + functions/package-lock.json | 294 +++++++++++++++++++++++++-- functions/package.json | 3 +- 4 files changed, 307 insertions(+), 30 deletions(-) diff --git a/functions/.eslintrc.js b/functions/.eslintrc.js index 4e11496..c627b73 100644 --- a/functions/.eslintrc.js +++ b/functions/.eslintrc.js @@ -4,26 +4,26 @@ module.exports = { commonjs: true, es2021: true, }, - extends: ["eslint:recommended", "eslint-config-prettier"], + extends: ['eslint:recommended', 'eslint-config-prettier'], parserOptions: { ecmaVersion: 12, }, rules: { - "no-prototype-builtins": "off", - "no-self-assign": "off", - "no-empty": "off", - "no-case-declarations": "off", - "consistent-return": "off", - "arrow-body-style": "off", - camelcase: "off", - quotes: "off", - "no-unused-vars": "off", - "comma-dangle": "off", - "no-bitwise": "off", - "no-use-before-define": "off", - "no-extra-boolean-cast": "off", - "no-empty-pattern": "off", - curly: "off", - "no-unreachable": "off", + 'no-prototype-builtins': 'off', + 'no-self-assign': 'off', + 'no-empty': 'off', + 'no-case-declarations': 'off', + 'consistent-return': 'off', + 'arrow-body-style': 'off', + camelcase: 'off', + quotes: 'off', + 'no-unused-vars': 'off', + 'comma-dangle': 'off', + 'no-bitwise': 'off', + 'no-use-before-define': 'off', + 'no-extra-boolean-cast': 'off', + 'no-empty-pattern': 'off', + curly: 'off', + 'no-unreachable': 'off', }, }; diff --git a/functions/middlewares/uploadImage.js b/functions/middlewares/uploadImage.js index 9929880..fd04a9c 100644 --- a/functions/middlewares/uploadImage.js +++ b/functions/middlewares/uploadImage.js @@ -9,6 +9,11 @@ const { firebaseConfig } = require('../config/firebaseClient'); const util = require('../lib/util'); const statusCode = require('../constants/statusCode'); const responseMessage = require('../constants/responseMessage'); +const sharp = require('sharp'); + +const resizeImage = async (input) => { + return sharp(input).rotate().resize(300).toBuffer(); +}; const uploadImage = (dir) => { return function (req, res, next) { @@ -34,6 +39,7 @@ const uploadImage = (dir) => { const filepath = path.join(os.tmpdir(), imageFileName); imageToAdd = { imageFileName, filepath, mimetype }; file.pipe(fs.createWriteStream(filepath)); + resizeImage(file); imagesToUpload.push(imageToAdd); }); diff --git a/functions/package-lock.json b/functions/package-lock.json index a3ca083..03009e5 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -991,8 +991,7 @@ "base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "optional": true + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" }, "bignumber.js": { "version": "9.0.2", @@ -1000,6 +999,28 @@ "integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==", "optional": true }, + "bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "body-parser": { "version": "1.19.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz", @@ -1033,6 +1054,15 @@ "concat-map": "0.0.1" } }, + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "buffer-equal-constant-time": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", @@ -1113,6 +1143,11 @@ } } }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, "cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -1123,6 +1158,15 @@ "wrap-ansi": "^7.0.0" } }, + "color": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", + "requires": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + } + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1136,6 +1180,15 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "color-string": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", + "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", + "requires": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, "compressible": { "version": "2.0.18", "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", @@ -1268,6 +1321,19 @@ "ms": "2.0.0" } }, + "decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "requires": { + "mimic-response": "^3.1.0" + } + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" + }, "deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -1284,6 +1350,11 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "detect-libc": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.1.tgz", + "integrity": "sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==" + }, "dicer": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.1.tgz", @@ -1367,7 +1438,6 @@ "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "optional": true, "requires": { "once": "^1.4.0" } @@ -1603,6 +1673,11 @@ "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", "optional": true }, + "expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==" + }, "express": { "version": "4.17.2", "resolved": "https://registry.npmjs.org/express/-/express-4.17.2.tgz", @@ -1667,7 +1742,7 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "fast-text-encoding": { @@ -1857,6 +1932,11 @@ "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1927,6 +2007,11 @@ "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", "optional": true }, + "github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" + }, "glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -2052,7 +2137,7 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true }, "has-symbols": { @@ -2165,6 +2250,11 @@ "resolved": "https://registry.npmjs.org/idb/-/idb-3.0.2.tgz", "integrity": "sha512-+FLa/0sTXqyux0o6C+i2lOR0VoS60LU/jzUo5xjfY6+7sEEgy4Gz1O7yFBXvjd7N0NyIGWIRg8DcQSLEG+VSPw==" }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", @@ -2205,15 +2295,25 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, "ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" }, + "is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true }, "is-fullwidth-code-point": { @@ -2306,7 +2406,7 @@ "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "jsonwebtoken": { @@ -2498,7 +2598,7 @@ "lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", - "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "integrity": "sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==", "dev": true }, "long": { @@ -2581,6 +2681,11 @@ "mime-db": "1.51.0" } }, + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -2589,15 +2694,30 @@ "brace-expansion": "^1.1.7" } }, + "minimist": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + }, + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "negotiator": { @@ -2605,6 +2725,29 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, + "node-abi": { + "version": "3.24.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.24.0.tgz", + "integrity": "sha512-YPG3Co0luSu6GwOBsmIdGW6Wx0NyNDLg/hriIyDllVsNwnI6UeqaWShxC3lbH4LtEQUgoLP3XR1ndXiDAWvmRw==", + "requires": { + "semver": "^7.3.5" + }, + "dependencies": { + "semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "node-addon-api": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.0.0.tgz", + "integrity": "sha512-CvkDw2OEnme7ybCykJpVcKH+uAOLV2qLqiyla128dN9TkEWfrYmxG6C2boDe5KcNQqZF3orkqzGgOMvZ/JNekA==" + }, "node-fetch": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.1.0.tgz", @@ -2853,6 +2996,25 @@ "xtend": "^4.0.0" } }, + "prebuild-install": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", + "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "requires": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + } + }, "prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -2927,7 +3089,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "optional": true, "requires": { "end-of-stream": "^1.1.0", "once": "^1.3.1" @@ -2974,6 +3135,24 @@ "unpipe": "1.0.0" } }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==" + } + } + }, "readable-stream": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", @@ -3134,6 +3313,31 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, + "sharp": { + "version": "0.30.7", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.30.7.tgz", + "integrity": "sha512-G+MY2YW33jgflKPTXXptVO28HvNOo9G3j0MybYAHeEmby+QuD2U98dT6ueht9cv/XDqZspSpIhoSW+BAKJ7Hig==", + "requires": { + "color": "^4.2.3", + "detect-libc": "^2.0.1", + "node-addon-api": "^5.0.0", + "prebuild-install": "^7.1.1", + "semver": "^7.3.7", + "simple-get": "^4.0.1", + "tar-fs": "^2.1.1", + "tunnel-agent": "^0.6.0" + }, + "dependencies": { + "semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -3163,6 +3367,29 @@ "integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==", "optional": true }, + "simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==" + }, + "simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "requires": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", + "requires": { + "is-arrayish": "^0.3.1" + } + }, "slice-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", @@ -3188,7 +3415,7 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, "statuses": { @@ -3303,6 +3530,41 @@ } } }, + "tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "teeny-request": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-7.1.3.tgz", @@ -3330,7 +3592,7 @@ "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "tmp": { @@ -3356,6 +3618,14 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "requires": { + "safe-buffer": "^5.0.1" + } + }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/functions/package.json b/functions/package.json index 16da29c..816da47 100644 --- a/functions/package.json +++ b/functions/package.json @@ -38,7 +38,8 @@ "passport-kakao": "^1.0.1", "path": "^0.12.7", "pg": "^8.7.1", - "qs": "^6.10.3" + "qs": "^6.10.3", + "sharp": "^0.30.7" }, "devDependencies": { "eslint": "^7.6.0", From 25760c1d0f58ba7e2d968882c72ac6253027ad79 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Tue, 9 Aug 2022 23:20:12 +0900 Subject: [PATCH 10/27] del:> resizeImage #204 --- functions/middlewares/uploadImage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/middlewares/uploadImage.js b/functions/middlewares/uploadImage.js index fd04a9c..d1c2404 100644 --- a/functions/middlewares/uploadImage.js +++ b/functions/middlewares/uploadImage.js @@ -39,7 +39,6 @@ const uploadImage = (dir) => { const filepath = path.join(os.tmpdir(), imageFileName); imageToAdd = { imageFileName, filepath, mimetype }; file.pipe(fs.createWriteStream(filepath)); - resizeImage(file); imagesToUpload.push(imageToAdd); }); From 11ca73371f0b3c5abb568fd91854bd78fd344028 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Tue, 23 Aug 2022 02:57:36 +0900 Subject: [PATCH 11/27] =?UTF-8?q?feat:>=20=ED=8C=80=20=EB=A9=94=EC=9D=B8?= =?UTF-8?q?=20=EB=82=B4=EA=B0=80=20=EC=86=8D=ED=95=9C=20=ED=8C=80=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?-=20=EC=9D=B4=EC=8A=88=20=EC=83=9D=EC=84=B1=20=EC=88=9C=20#204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/team/teamGET.js | 15 ++++++++--- .../api/routes/team/teamInviteAcceptPUT.js | 15 +++++++++-- .../api/routes/team/teamInviteRejectPUT.js | 15 +++++++++-- functions/db/memberDB.js | 27 +++++++++---------- 4 files changed, 50 insertions(+), 22 deletions(-) diff --git a/functions/api/routes/team/teamGET.js b/functions/api/routes/team/teamGET.js index 006ea39..64289f1 100644 --- a/functions/api/routes/team/teamGET.js +++ b/functions/api/routes/team/teamGET.js @@ -17,10 +17,19 @@ module.exports = async (req, res) => { try { client = await db.connect(req); - const myTeamList = await memberDB.getAllTeamByUserId(client, userId); - myTeamList.forEach((item) => (item.image = resizeImage(item.image))); + const myIssueList = await memberDB.getAllTeamByUserId(client, userId); + const myTeamList = myIssueList.filter((o) => !o.isDeleted); + const myTeamUniqueList = myTeamList.filter((team, index, arr) => { + return arr.findIndex((item) => item.id === team.id && item.name === team.name) === index; + }); - res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.READ_ALL_TEAM_SUCCESS, myTeamList)); + myTeamUniqueList.forEach((item) => { + delete item.createdAt; + delete item.isDeleted; + item.image = resizeImage(item.image); + }); + + res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.READ_ALL_TEAM_SUCCESS, myTeamUniqueList)); } catch (error) { functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`); console.log(error); diff --git a/functions/api/routes/team/teamInviteAcceptPUT.js b/functions/api/routes/team/teamInviteAcceptPUT.js index f99fa7b..80d640f 100644 --- a/functions/api/routes/team/teamInviteAcceptPUT.js +++ b/functions/api/routes/team/teamInviteAcceptPUT.js @@ -5,6 +5,7 @@ const responseMessage = require('../../../constants/responseMessage'); const db = require('../../../db/db'); const { memberDB, teamDB } = require('../../../db'); const slackAPI = require('../../../lib/slackAPI'); +const resizeImage = require('../../../lib/resizeImage'); module.exports = async (req, res) => { const { id: userId } = req.user; @@ -27,10 +28,20 @@ module.exports = async (req, res) => { } const member = await memberDB.updateMemberAccept(client, userId, teamId); - const team = await memberDB.getAllTeamByUserId(client, userId); + const myIssueList = await memberDB.getAllTeamByUserId(client, userId); + const myTeamList = myIssueList.filter((o) => !o.isDeleted); + const myTeamUniqueList = myTeamList.filter((team, index, arr) => { + return arr.findIndex((item) => item.id === team.id && item.name === team.name) === index; + }); + + myTeamUniqueList.forEach((item) => { + delete item.createdAt; + delete item.isDeleted; + item.image = resizeImage(item.image); + }); const invitedTeam = await teamDB.getNewTeamByUserId(client, userId); - res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.POST_MEMBER_SUCCESS, { member, team, invitedTeam })); + res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.POST_MEMBER_SUCCESS, { member, team: myTeamUniqueList, invitedTeam })); } catch (error) { functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`); console.log(error); diff --git a/functions/api/routes/team/teamInviteRejectPUT.js b/functions/api/routes/team/teamInviteRejectPUT.js index 5ed5b1c..d1f1182 100644 --- a/functions/api/routes/team/teamInviteRejectPUT.js +++ b/functions/api/routes/team/teamInviteRejectPUT.js @@ -5,6 +5,7 @@ const responseMessage = require('../../../constants/responseMessage'); const db = require('../../../db/db'); const { memberDB, teamDB } = require('../../../db'); const slackAPI = require('../../../lib/slackAPI'); +const resizeImage = require('../../../lib/resizeImage'); module.exports = async (req, res) => { const { id: userId } = req.user; @@ -27,10 +28,20 @@ module.exports = async (req, res) => { } const member = await memberDB.updateMemberReject(client, userId, teamId); - const team = await memberDB.getAllTeamByUserId(client, userId); + const myIssueList = await memberDB.getAllTeamByUserId(client, userId); + const myTeamList = myIssueList.filter((o) => !o.isDeleted); + const myTeamUniqueList = myTeamList.filter((team, index, arr) => { + return arr.findIndex((item) => item.id === team.id && item.name === team.name) === index; + }); + + myTeamUniqueList.forEach((item) => { + delete item.createdAt; + delete item.isDeleted; + item.image = resizeImage(item.image); + }); const invitedTeam = await teamDB.getNewTeamByUserId(client, userId); - res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.POST_MEMBER_SUCCESS, { member, team, invitedTeam })); + res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.POST_MEMBER_SUCCESS, { member, team: myTeamUniqueList, invitedTeam })); } catch (error) { functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`); console.log(error); diff --git a/functions/db/memberDB.js b/functions/db/memberDB.js index 0af26a9..ca2c276 100644 --- a/functions/db/memberDB.js +++ b/functions/db/memberDB.js @@ -4,14 +4,16 @@ const convertSnakeToCamel = require('../lib/convertSnakeToCamel'); const getAllTeamByUserId = async (client, userId) => { const { rows } = await client.query( /*sql*/ ` - SELECT t.id, t.name, t.image - FROM "team" t, (SELECT team_id - FROM "member" m - WHERE user_id = $1 and is_confirmed = true - AND is_deleted = false) m - WHERE t.id = m.team_id - AND t.is_deleted = false - ORDER BY t.updated_at DESC + SELECT t.id, t.name, t.image, i.created_at, i.is_deleted + FROM "team" t + JOIN "member" m ON t.id = m.team_id + LEFT OUTER JOIN "issue" i ON t.id = i.team_id + WHERE m.user_id = $1 + AND m.is_confirmed = true + AND m.is_deleted = false + -- AND i.is_deleted = false + AND t.is_deleted = false + ORDER BY i.created_at is null ASC, i.created_at DESC `, [userId], ); @@ -84,9 +86,7 @@ const addMember = async (client, teamId, userIdList) => { return []; } - const valuesInsertQuery = userIdList - .map((x) => `(${teamId}, ${x})`) - .join(', '); + const valuesInsertQuery = userIdList.map((x) => `(${teamId}, ${x})`).join(', '); const { rows: resultRows } = await client.query( ` INSERT INTO member @@ -237,10 +237,7 @@ const getMemberByTeamId = async (client, teamId) => { }; const checkDuplicateMemeber = async (client, teamId, userIdList) => { - const valuesInsertQuery = '(' + userIdList - .map((x) => `${x}`) - .join(', ') - + ')'; + const valuesInsertQuery = '(' + userIdList.map((x) => `${x}`).join(', ') + ')'; const { rows } = await client.query( ` From c178406dcca4e36f1ae8103e3345f6bfcc46b469 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Tue, 23 Aug 2022 03:30:31 +0900 Subject: [PATCH 12/27] =?UTF-8?q?feat:>=20=ED=8C=80=20=EB=A9=94=EC=9D=B8?= =?UTF-8?q?=20=EB=82=98=EC=99=80=20=EA=B4=80=EB=A0=A8=EB=90=9C=20=EC=9D=B4?= =?UTF-8?q?=EC=8A=88=20=EC=A0=95=EB=A0=AC=20=EB=A1=9C=EC=A7=81=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20-=20=EB=82=B4=EA=B0=80=20=ED=94=BC=EB=93=9C?= =?UTF-8?q?=EB=B0=B1=20=EB=B0=9B=EC=9D=80=20=EC=8B=9C=EA=B0=84=20=EC=B5=9C?= =?UTF-8?q?=EC=8B=A0=EC=88=9C=20(+=EC=82=AD=EC=A0=9C=20=EA=B2=80=EC=A6=9D)?= =?UTF-8?q?=20#204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/team/teamIssueGET.js | 3 ++- functions/db/issueDB.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/functions/api/routes/team/teamIssueGET.js b/functions/api/routes/team/teamIssueGET.js index 461bebf..b342432 100644 --- a/functions/api/routes/team/teamIssueGET.js +++ b/functions/api/routes/team/teamIssueGET.js @@ -57,7 +57,8 @@ module.exports = async (req, res) => { //^_^// 합치기 완료 const map = new Map(); - myIssue.forEach((item) => map.set(item.id, item)); + idList.forEach((item) => map.set(item, item)); + myIssue.forEach((item) => map.set(item.id, { ...map.get(item.id), ...item })); myFeedbackList.forEach((item) => map.set(item.id, { ...map.get(item.id), ...item })); myTeam.forEach((team) => map.set(team.issueId, { ...map.get(team.issueId), team })); const resultList = Array.from(map.values()); diff --git a/functions/db/issueDB.js b/functions/db/issueDB.js index 506a948..1762ef2 100644 --- a/functions/db/issueDB.js +++ b/functions/db/issueDB.js @@ -6,9 +6,15 @@ const getFeedbackIdRecentListByUserId = async (client, userId) => { ` SELECT f.id, f.issue_id FROM "feedback" f + JOIN "member" m ON m.user_id = f.tagged_user_id + JOIN "issue" i ON i.id = f.issue_id WHERE f.tagged_user_id = $1 + AND i.team_id = m.team_id + AND m.is_confirmed = true + AND m.is_deleted = false + AND i.is_deleted = false AND f.is_deleted = false - ORDER BY updated_at + ORDER BY f.created_at DESC `, [userId], ); @@ -105,7 +111,7 @@ const getTeamByIssueIdList = async (client, issueId) => { const getAllFeedbackPersonList = async (client, issueId) => { const { rows } = await client.query( ` - SELECT f.issue_id, uu.id , uu.name, uu.image + SELECT f.issue_id, uu.id , uu.name, uu.image, f.created_at FROM feedback "f", (SELECT u.id, u.name, u.image FROM "user" u JOIN "feedback" f @@ -114,6 +120,7 @@ const getAllFeedbackPersonList = async (client, issueId) => { GROUP BY u.id) uu WHERE uu.id=f.tagged_user_id AND f.issue_id in (${issueId.join(',')}) + ORDER BY f.created_at DESC `, ); return convertSnakeToCamel.keysToCamel(rows); From 0d99877ca6499be97bfabf23968364236f106bb1 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Tue, 23 Aug 2022 03:36:47 +0900 Subject: [PATCH 13/27] =?UTF-8?q?feat:>=20=ED=8C=80=EC=9D=98=20=EC=9D=B4?= =?UTF-8?q?=EC=8A=88=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=A0=95=EB=A0=AC?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD=20-=20=EC=9D=B4?= =?UTF-8?q?=EC=8A=88=20=EC=83=9D=EC=84=B1=20=EC=88=9C=20#204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/db/issueDB.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/db/issueDB.js b/functions/db/issueDB.js index 1762ef2..3cb0d0b 100644 --- a/functions/db/issueDB.js +++ b/functions/db/issueDB.js @@ -29,7 +29,7 @@ const getIssueIdRecentListByTeamId = async (client, teamId) => { FROM "issue" i WHERE i.team_id = $1 AND i.is_deleted = false - ORDER BY i.updated_at DESC + ORDER BY i.created_at DESC `, [teamId], From 52ed12fc39dafd4b5d3100e0ac34376dcf63272b Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Tue, 23 Aug 2022 03:47:56 +0900 Subject: [PATCH 14/27] =?UTF-8?q?feat:>=20=EC=9C=A0=EC=A0=80=20=ED=83=88?= =?UTF-8?q?=ED=87=B4=20=EC=8B=9C=20=ED=98=B8=EC=8A=A4=ED=8A=B8=EC=9D=B8=20?= =?UTF-8?q?=ED=8C=80=20=EC=9E=88=EB=8A=94=EC=A7=80=20=EA=B2=80=EC=82=AC=20?= =?UTF-8?q?API=20#204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/routes/team/teamMemberEditPOST.js | 31 +++++++---------- functions/api/routes/user/index.js | 1 + functions/api/routes/user/userHostCheckGET.js | 33 +++++++++++++++++++ functions/constants/responseMessage.js | 1 + functions/db/memberDB.js | 25 ++++++++++++-- 5 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 functions/api/routes/user/userHostCheckGET.js diff --git a/functions/api/routes/team/teamMemberEditPOST.js b/functions/api/routes/team/teamMemberEditPOST.js index aa9dc5f..f7364c6 100644 --- a/functions/api/routes/team/teamMemberEditPOST.js +++ b/functions/api/routes/team/teamMemberEditPOST.js @@ -12,17 +12,13 @@ const extractValues = (arr, key) => { }; module.exports = async (req, res) => { - const user = req.user; const { teamId, userIdList } = req.body; - + if (!user || !teamId || userIdList === 0) return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.NULL_VALUE)); - let client; - - - + try { client = await db.connect(req); @@ -30,40 +26,37 @@ module.exports = async (req, res) => { if (!checkUser) { //^_^// is_host가 false인 경우 수정하지 못하도록 함 return res.status(statusCode.FORBIDDEN).send(util.fail(statusCode.FORBIDDEN, responseMessage.NO_AUTH_MEMBER)); - }; + } //^_^// userIdList 중복 제거 - const uniqueUserIdList = [ ... new Set(JSON.parse(userIdList))]; + const uniqueUserIdList = [...new Set(JSON.parse(userIdList))]; //^_^// 이미 초대가 날라갔는지 확인 - const duplicateMember = await memberDB.checkDuplicateMemeber(client, teamId, uniqueUserIdList); + const duplicateMember = await memberDB.checkDuplicateMember(client, teamId, uniqueUserIdList); const duplicateMemberUserId = extractValues(duplicateMember, 'userId'); - const uniqueDuplicateMember = [ ... new Set(duplicateMemberUserId)]; - - const notInvitedUserId = uniqueUserIdList - .filter( x => x != uniqueDuplicateMember ); + const uniqueDuplicateMember = [...new Set(duplicateMemberUserId)]; + + const notInvitedUserId = uniqueUserIdList.filter((x) => x != uniqueDuplicateMember); //^_^// 새로운 유저 멤버로 추가 const newMemberData = await memberDB.addMember(client, teamId, notInvitedUserId); const resultData = { - member: newMemberData + member: newMemberData, }; - + res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.POST_MEMBER, resultData)); - } catch (error) { functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`); console.log(error); - + const slackMessage = `[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl} ${req.user ? `uid:${req.user.id}` : 'req.user 없음'} ${JSON.stringify(error)}`; slackAPI.sendMessageToSlack(slackMessage, slackAPI.DEV_WEB_HOOK_ERROR_MONITORING); res.status(statusCode.INTERNAL_SERVER_ERROR).send(util.fail(statusCode.INTERNAL_SERVER_ERROR, responseMessage.INTERNAL_SERVER_ERROR)); - } finally { client.release(); } -}; \ No newline at end of file +}; diff --git a/functions/api/routes/user/index.js b/functions/api/routes/user/index.js index 7066011..8273ace 100644 --- a/functions/api/routes/user/index.js +++ b/functions/api/routes/user/index.js @@ -17,6 +17,7 @@ router.get('/myKeyword', checkUser, require('./myKeywordListGET')); router.get('/notice/bar', checkUser, require('./userNoticeBarGET')); router.get('/notice', checkUser, require('./userNoticeListGET')); router.get('/', checkUser, require('./userInformationByTokenGET')); +router.get('/host', checkUser, require('./userHostCheckGET')); router.get('/:profileId', require('./userInformationByProfileIdGET')); router.get('/:profileId/answer', require('./userPinnedAnswerGET')); router.get('/:profileId/team', require('./userPinnedTeamGET')); diff --git a/functions/api/routes/user/userHostCheckGET.js b/functions/api/routes/user/userHostCheckGET.js new file mode 100644 index 0000000..9c752ce --- /dev/null +++ b/functions/api/routes/user/userHostCheckGET.js @@ -0,0 +1,33 @@ +const functions = require('firebase-functions'); +const util = require('../../../lib/util'); +const statusCode = require('../../../constants/statusCode'); +const responseMessage = require('../../../constants/responseMessage'); +const db = require('../../../db/db'); +const slackAPI = require('../../../lib/slackAPI'); +const { memberDB } = require('../../../db'); + +module.exports = async (req, res) => { + const { id: userId } = req.user; + + if (!userId) return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.NULL_VALUE)); + + let client; + + try { + client = await db.connect(req); + + const teamList = await memberDB.checkUserIsHost(client, userId); + + res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.USER_HOST_CHECK_SUCCESS, teamList)); + } catch (error) { + functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`); + console.log(error); + + const slackMessage = `[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl} ${req.user ? `uid:${req.user.id}` : 'req.user 없음'} + ${JSON.stringify(error)}`; + slackAPI.sendMessageToSlack(slackMessage, slackAPI.DEV_WEB_HOOK_ERROR_MONITORING); + res.status(statusCode.INTERNAL_SERVER_ERROR).send(util.fail(statusCode.INTERNAL_SERVER_ERROR, responseMessage.INTERNAL_SERVER_ERROR)); + } finally { + client.release(); + } +}; diff --git a/functions/constants/responseMessage.js b/functions/constants/responseMessage.js index e85b208..9e178c4 100644 --- a/functions/constants/responseMessage.js +++ b/functions/constants/responseMessage.js @@ -25,6 +25,7 @@ module.exports = { NO_USER_SEARCH_LIST: '유저 검색 결과 없음', UPDATE_USER: '유저 정보 수정 성공', DELETE_USER_SUCCESS: '유저 삭제 성공', + USER_HOST_CHECK_SUCCESS: '유저 호스트 여부 확인 성공', // 키워드 ALREADY_KEYWORD: '이미 존재하는 키워드입니다', diff --git a/functions/db/memberDB.js b/functions/db/memberDB.js index ca2c276..dfb1323 100644 --- a/functions/db/memberDB.js +++ b/functions/db/memberDB.js @@ -236,7 +236,7 @@ const getMemberByTeamId = async (client, teamId) => { return convertSnakeToCamel.keysToCamel(rows); }; -const checkDuplicateMemeber = async (client, teamId, userIdList) => { +const checkDuplicateMember = async (client, teamId, userIdList) => { const valuesInsertQuery = '(' + userIdList.map((x) => `${x}`).join(', ') + ')'; const { rows } = await client.query( @@ -253,6 +253,26 @@ const checkDuplicateMemeber = async (client, teamId, userIdList) => { return convertSnakeToCamel.keysToCamel(rows); }; +const checkUserIsHost = async (client, userId) => { + const { rows } = await client.query( + ` + SELECT t.id, t.name, t.image + FROM "member" m + JOIN "team" t + ON m.team_id = t.id + WHERE m.user_id = $1 + AND m.is_confirmed = true + AND m.is_deleted = false + AND m.is_host = true + AND t.is_deleted = false + ORDER BY t.created_at DESC + `, + [userId], + ); + + return convertSnakeToCamel.keysToCamel(rows); +}; + module.exports = { getAllTeamByUserId, getAllTeamMemberByTeamId, @@ -268,5 +288,6 @@ module.exports = { getInvitedTeamIdList, getAllInvitedTeamIdList, getMemberByTeamId, - checkDuplicateMemeber, + checkDuplicateMember, + checkUserIsHost, }; From 9367f7c843392af18db9988a06f97cf71d2e64c7 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Tue, 23 Aug 2022 03:52:50 +0900 Subject: [PATCH 15/27] =?UTF-8?q?chore:>=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=EB=AA=85=20=EC=A7=80=EC=A0=95=20#204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/user/userHostCheckGET.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/api/routes/user/userHostCheckGET.js b/functions/api/routes/user/userHostCheckGET.js index 9c752ce..93fd576 100644 --- a/functions/api/routes/user/userHostCheckGET.js +++ b/functions/api/routes/user/userHostCheckGET.js @@ -18,7 +18,7 @@ module.exports = async (req, res) => { const teamList = await memberDB.checkUserIsHost(client, userId); - res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.USER_HOST_CHECK_SUCCESS, teamList)); + res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.USER_HOST_CHECK_SUCCESS, { teamList })); } catch (error) { functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`); console.log(error); From 5d79ef3e900c96ca670ba58710a07d7709a2f570 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Sun, 28 Aug 2022 01:43:34 +0900 Subject: [PATCH 16/27] =?UTF-8?q?feat:>=20=ED=95=B4=EB=8B=B9=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=EA=B0=80=20=EC=93=B4=20=EC=9D=B4=EC=8A=88=EC=99=80=20?= =?UTF-8?q?=EA=B7=B8=EC=97=90=20=ED=8F=AC=ED=95=A8=EB=90=9C=20=ED=94=BC?= =?UTF-8?q?=EB=93=9C=EB=B0=B1,=20=ED=95=B4=EB=8B=B9=20=EB=A9=A4=EB=B2=84?= =?UTF-8?q?=EA=B0=80=20=ED=8F=AC=ED=95=A8=EB=90=98=EA=B1=B0=EB=82=98=20?= =?UTF-8?q?=EC=93=B4=20=ED=94=BC=EB=93=9C=EB=B0=B1=20=EB=B0=8F=20=EC=97=B0?= =?UTF-8?q?=EA=B4=80=EB=90=9C=20=ED=82=A4=EC=9B=8C=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20#207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/team/teamMemberDELETE.js | 42 +++++++++++++++- functions/db/feedbackDB.js | 50 +++++++++++++++++++ functions/db/issueDB.js | 28 +++++++++++ functions/db/keywordDB.js | 2 +- functions/db/linkFeedbacKeywordDB.js | 19 ++++++- 5 files changed, 138 insertions(+), 3 deletions(-) diff --git a/functions/api/routes/team/teamMemberDELETE.js b/functions/api/routes/team/teamMemberDELETE.js index b5e306b..a3668a0 100644 --- a/functions/api/routes/team/teamMemberDELETE.js +++ b/functions/api/routes/team/teamMemberDELETE.js @@ -4,8 +4,10 @@ const statusCode = require('../../../constants/statusCode'); const responseMessage = require('../../../constants/responseMessage'); const db = require('../../../db/db'); const slackAPI = require('../../../lib/slackAPI'); -const { memberDB } = require('../../../db'); +const { memberDB, feedbackDB, linkFeedbacKeywordDB, keywordDB, issueDB } = require('../../../db'); const { isFunction } = require('lodash'); +const arrayHandler = require('../../../lib/arrayHandler'); +const { user } = require('firebase-functions/v1/auth'); module.exports = async (req, res) => { const { id: userId } = req.user; @@ -18,12 +20,50 @@ module.exports = async (req, res) => { try { client = await db.connect(req); + //^_^// 해당 멤버 get const isMember = await memberDB.checkMemberTeam(client, userId, teamId); if (!isMember) { return res.status(statusCode.FORBIDDEN).send(util.success(statusCode.FORBIDDEN, responseMessage.NO_MEMBER)); } + //^_^// 해당 멤버가 쓴 이슈 조회 및 아이디 추출 + const userIssueList = await issueDB.getAllIssueIdListByUserIdAndTeamId(client, userId, teamId); + const userIssueIdList = arrayHandler.extractValues(userIssueList, 'id'); + + //^_^// 해당 이슈에 포함되는 피드백 아이디 추출 + const userIssueFeedbackList = await feedbackDB.getAllFeedbackByIssueIdList(client, userIssueIdList); + const userIssueFeedbackIdList = arrayHandler.extractValues(userIssueFeedbackList, 'id'); + + //^_^// 해당 팀 멤버가 포함된 또는 쓴 피드백 조회 및 아이디 추출 + const userFeedbackList = await feedbackDB.getAllFeedbackByUserIdAndTeamId(client, userId, teamId); + const userFeedbackIdList = arrayHandler.extractValues(userFeedbackList, 'feedbackId'); + + //^_^// 위의 이슈에 포함된 피드백 아이디 + 해당 멤버가 포함되거나 쓴 피드백 아이디 + const feedbackIdList = [...userIssueFeedbackIdList, ...userFeedbackIdList]; + + if (feedbackIdList.length > 0) { + //^_^// 해당 피드백에 포함된 키워드들 추출 + const linkFeedbackKeywords = await linkFeedbacKeywordDB.getKeywordsWithFeedbackIdList(client, feedbackIdList); + + //^_^// 삭제한 feedback에 담긴 키워드 삭제 + const keywordIdsBeforeUpdate = arrayHandler.extractValues(linkFeedbackKeywords, 'id'); + const deleteLinkFeedbackKeyword = await linkFeedbacKeywordDB.deleteLinkFeedbackListKeyword(client, feedbackIdList, keywordIdsBeforeUpdate); + + //^_^// 삭제한 keyword count-- 업데이트 + const deleteKeywords = await keywordDB.keywordCountDelete(client, keywordIdsBeforeUpdate); + + //^_^// 쓴 피드백 삭제 + const deletedFeedbackList = await feedbackDB.deleteFeedbackList(client, feedbackIdList); + } + + //^_^// 해당 멤버가 쓴 이슈 삭제 + if (userIssueIdList.length > 0) { + const deletedIssueList = await issueDB.deleteIssueList(client, userIssueIdList); + } + + //^_^// 해당 멤버 삭제 const member = await memberDB.deleteMember(client, userId, teamId); + res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.DELETE_MEMBER_SUCCESS, { member })); } catch (error) { functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`); diff --git a/functions/db/feedbackDB.js b/functions/db/feedbackDB.js index 69ae7cb..8e6cc64 100644 --- a/functions/db/feedbackDB.js +++ b/functions/db/feedbackDB.js @@ -141,6 +141,53 @@ const deleteFeedback = async (client, feedbackId) => { return convertSnakeToCamel.keysToCamel(rows[0]); }; +const deleteFeedbackList = async (client, feedbackIdList) => { + const { rows } = await client.query(/*sql*/ ` + UPDATE feedback + SET is_deleted = true, updated_at = now() + WHERE id in (${feedbackIdList.join()}) + AND is_deleted = false + RETURNING *`); + return convertSnakeToCamel.keysToCamel(rows); +}; + +const getAllFeedbackByUserIdAndTeamId = async (client, userId, teamId) => { + const { rows } = await client.query( + ` + SELECT f.id as feedback_id, t.id as team_id, + f.user_id as writer_user_id, u2.name as writer_user_name, + f.tagged_user_id as user_id, u.name as user_name, + f.created_at, f.content, f.is_pinned + FROM feedback f + JOIN "user" u ON u.id = f.tagged_user_id + JOIN "user" u2 ON u2.id = f.user_id + JOIN issue i ON f.issue_id = i.id + JOIN team t ON i.team_id = t.id + WHERE t.id = $2 + AND (f.tagged_user_id = $1 + OR f.user_id = $1 + ) + AND f.is_deleted = false + AND u.is_deleted = false + AND u2.is_deleted = false + AND i.is_deleted = false + AND t.is_deleted = falsE + `, + [userId, teamId], + ); + return convertSnakeToCamel.keysToCamel(rows); +}; + +const getAllFeedbackByIssueIdList = async (client, issueIdList) => { + const { rows } = await client.query(/*sql*/ ` + SELECT f.id + FROM feedback f + WHERE f.issue_id in (${issueIdList.join()}) + AND f.is_deleted = false + `); + return convertSnakeToCamel.keysToCamel(rows); +}; + module.exports = { addFeedback, getFeedbacks, @@ -151,4 +198,7 @@ module.exports = { deleteFeedback, getFeedbackById, editFeedback, + deleteFeedbackList, + getAllFeedbackByUserIdAndTeamId, + getAllFeedbackByIssueIdList, }; diff --git a/functions/db/issueDB.js b/functions/db/issueDB.js index 3cb0d0b..5a0b548 100644 --- a/functions/db/issueDB.js +++ b/functions/db/issueDB.js @@ -246,6 +246,32 @@ const getTeamMemberByIssueId = async (client, issueId) => { return convertSnakeToCamel.keysToCamel(rows); }; +const getAllIssueIdListByUserIdAndTeamId = async (client, userId, teamId) => { + const { rows } = await client.query( + ` + SELECT id + FROM issue + WHERE user_id = $1 + AND team_id = $2 + AND is_deleted=false + `, + [userId, teamId], + ); + return convertSnakeToCamel.keysToCamel(rows); +}; + +const deleteIssueList = async (client, issueIdList) => { + const { rows } = await client.query( + ` + UPDATE issue + SET is_deleted = true + WHERE id IN (${issueIdList.join()}) + RETURNING * + `, + ); + return convertSnakeToCamel.keysToCamel(rows); +}; + module.exports = { getFeedbackIdRecentListByUserId, getIssueIdRecentListByTeamId, @@ -263,4 +289,6 @@ module.exports = { deleteIssue, getTeamIdByIssueId, getTeamMemberByIssueId, + getAllIssueIdListByUserIdAndTeamId, + deleteIssueList, }; diff --git a/functions/db/keywordDB.js b/functions/db/keywordDB.js index 133be30..70d6399 100644 --- a/functions/db/keywordDB.js +++ b/functions/db/keywordDB.js @@ -284,7 +284,7 @@ const updateLinkFeedbackKeywordsForSet = async (client, id, idList) => { AND is_deleted = false RETURNING * `); - return convertSnakeToCamel.keysToCamel(rows); + return convertSnakeToCamel.keysToCamel(rows); }; const getUserKeywordListCount = async (client, userId) => { const { rows } = await client.query(` diff --git a/functions/db/linkFeedbacKeywordDB.js b/functions/db/linkFeedbacKeywordDB.js index 8e81f92..25e1162 100644 --- a/functions/db/linkFeedbacKeywordDB.js +++ b/functions/db/linkFeedbacKeywordDB.js @@ -64,4 +64,21 @@ const getTopKeywordListOnFeedback = async (client, userId) => { return convertSnakeToCamel.keysToCamel(rows); }; -module.exports = { addLinkFeedbackKeyword, deleteLinkFeedbackKeyword, getKeywordsWithFeedbackIdList, getTopKeywordListOnFeedback }; +const deleteLinkFeedbackListKeyword = async (client, feedbackIdList, keywordIds) => { + let rows = { rows: null }; + if (keywordIds.length > 0) { + rows = await client.query(/*sql*/ ` + UPDATE link_feedback_keyword + SET is_deleted = true + WHERE feedback_id IN (${feedbackIdList.join()}) + AND is_deleted = false + AND link_feedback_keyword.keyword_id IN (${keywordIds.join()}) + RETURNING * + + `); + } + + return convertSnakeToCamel.keysToCamel(rows); +}; + +module.exports = { addLinkFeedbackKeyword, deleteLinkFeedbackKeyword, getKeywordsWithFeedbackIdList, getTopKeywordListOnFeedback, deleteLinkFeedbackListKeyword }; From c4db6f5645ef68b5fbffd1657154ea0100de1eb1 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Sun, 28 Aug 2022 02:13:51 +0900 Subject: [PATCH 17/27] =?UTF-8?q?feat:>=20=ED=8C=80=EC=9E=A5=20=EC=9C=84?= =?UTF-8?q?=EC=9E=84=ED=95=98=EA=B3=A0=20=EB=82=98=EA=B0=88=EB=95=8C?= =?UTF-8?q?=EB=8F=84=20=ED=95=B4=EB=8B=B9=20=EC=9C=A0=EC=A0=80=EC=9D=98=20?= =?UTF-8?q?=EA=B8=B0=EB=A1=9D=20=EC=A0=84=EB=B6=80=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=8F=99=EC=9D=BC=ED=95=98=EA=B2=8C=20=EC=A0=81=EC=9A=A9=20#20?= =?UTF-8?q?7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/team/teamHostPUT.js | 38 +++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/functions/api/routes/team/teamHostPUT.js b/functions/api/routes/team/teamHostPUT.js index bacab3e..e960bbb 100644 --- a/functions/api/routes/team/teamHostPUT.js +++ b/functions/api/routes/team/teamHostPUT.js @@ -4,7 +4,8 @@ const statusCode = require('../../../constants/statusCode'); const responseMessage = require('../../../constants/responseMessage'); const db = require('../../../db/db'); const slackAPI = require('../../../lib/slackAPI'); -const { memberDB } = require('../../../db'); +const { memberDB, feedbackDB, linkFeedbacKeywordDB, keywordDB, issueDB } = require('../../../db'); +const arrayHandler = require('../../../lib/arrayHandler'); module.exports = async (req, res) => { const { id: userId } = req.user; @@ -26,6 +27,41 @@ module.exports = async (req, res) => { return res.status(statusCode.FORBIDDEN).send(util.success(statusCode.FORBIDDEN, responseMessage.NO_MEMBER)); } + //^_^// 해당 멤버가 쓴 이슈 조회 및 아이디 추출 + const userIssueList = await issueDB.getAllIssueIdListByUserIdAndTeamId(client, userId, teamId); + const userIssueIdList = arrayHandler.extractValues(userIssueList, 'id'); + + //^_^// 해당 이슈에 포함되는 피드백 아이디 추출 + const userIssueFeedbackList = await feedbackDB.getAllFeedbackByIssueIdList(client, userIssueIdList); + const userIssueFeedbackIdList = arrayHandler.extractValues(userIssueFeedbackList, 'id'); + + //^_^// 해당 팀 멤버가 포함된 또는 쓴 피드백 조회 및 아이디 추출 + const userFeedbackList = await feedbackDB.getAllFeedbackByUserIdAndTeamId(client, userId, teamId); + const userFeedbackIdList = arrayHandler.extractValues(userFeedbackList, 'feedbackId'); + + //^_^// 위의 이슈에 포함된 피드백 아이디 + 해당 멤버가 포함되거나 쓴 피드백 아이디 + const feedbackIdList = [...userIssueFeedbackIdList, ...userFeedbackIdList]; + + if (feedbackIdList.length > 0) { + //^_^// 해당 피드백에 포함된 키워드들 추출 + const linkFeedbackKeywords = await linkFeedbacKeywordDB.getKeywordsWithFeedbackIdList(client, feedbackIdList); + + //^_^// 삭제한 feedback에 담긴 키워드 삭제 + const keywordIdsBeforeUpdate = arrayHandler.extractValues(linkFeedbackKeywords, 'id'); + const deleteLinkFeedbackKeyword = await linkFeedbacKeywordDB.deleteLinkFeedbackListKeyword(client, feedbackIdList, keywordIdsBeforeUpdate); + + //^_^// 삭제한 keyword count-- 업데이트 + const deleteKeywords = await keywordDB.keywordCountDelete(client, keywordIdsBeforeUpdate); + + //^_^// 쓴 피드백 삭제 + const deletedFeedbackList = await feedbackDB.deleteFeedbackList(client, feedbackIdList); + } + + //^_^// 해당 멤버가 쓴 이슈 삭제 + if (userIssueIdList.length > 0) { + const deletedIssueList = await issueDB.deleteIssueList(client, userIssueIdList); + } + const oldHost = await memberDB.updateOldHost(client, userId, teamId); const newHost = await memberDB.updateNewHost(client, memberId, teamId); From 65cc8160aece482f958a59ea702030e2a64fc5d3 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Sun, 28 Aug 2022 02:21:11 +0900 Subject: [PATCH 18/27] =?UTF-8?q?feat:>=20=ED=95=B4=EB=8B=B9=20=ED=8C=80?= =?UTF-8?q?=EC=97=90=20=ED=8F=AC=ED=95=A8=EB=90=9C=20=EC=9D=B4=EC=8A=88,?= =?UTF-8?q?=20=ED=94=BC=EB=93=9C=EB=B0=B1,=20=ED=82=A4=EC=9B=8C=EB=93=9C?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=20#207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/team/teamDELETE.js | 41 ++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/functions/api/routes/team/teamDELETE.js b/functions/api/routes/team/teamDELETE.js index 6697852..66671a0 100644 --- a/functions/api/routes/team/teamDELETE.js +++ b/functions/api/routes/team/teamDELETE.js @@ -4,7 +4,8 @@ const statusCode = require('../../../constants/statusCode'); const responseMessage = require('../../../constants/responseMessage'); const db = require('../../../db/db'); const slackAPI = require('../../../lib/slackAPI'); -const { teamDB } = require('../../../db'); +const { teamDB, memberDB, feedbackDB, linkFeedbacKeywordDB, keywordDB, issueDB } = require('../../../db'); +const arrayHandler = require('../../../lib/arrayHandler'); module.exports = async (req, res) => { const { id: userId } = req.user; @@ -17,13 +18,43 @@ module.exports = async (req, res) => { try { client = await db.connect(req); + //^_^// 팀 삭제 권한 여부 검사 const teamHost = await teamDB.getIsHost(client, userId, teamId); - if (teamHost.isHost) { - const team = await teamDB.deleteTeam(client, teamId); - res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.DELETE_TEAM_SUCCESS, { team })); - } else { + if (!teamHost.isHost) { res.status(statusCode.FORBIDDEN).send(util.success(statusCode.FORBIDDEN, responseMessage.NO_AUTH_MEMBER)); } + + //^_^// 해당 팀에 포함된 이슈 조회 및 아이디 추출 + const teamIssueList = await issueDB.getIssueIdRecentListByTeamId(client, teamId); + const teamIssueIdList = arrayHandler.extractValues(teamIssueList, 'id'); + + //^_^// 해당 이슈에 포함된 피드백 아이디 추출 + const userIssueFeedbackList = await feedbackDB.getAllFeedbackByIssueIdList(client, teamIssueIdList); + const feedbackIdList = arrayHandler.extractValues(userIssueFeedbackList, 'id'); + + if (feedbackIdList.length > 0) { + //^_^// 해당 피드백에 포함된 키워드들 추출 + const linkFeedbackKeywords = await linkFeedbacKeywordDB.getKeywordsWithFeedbackIdList(client, feedbackIdList); + + //^_^// 삭제한 feedback에 담긴 키워드 삭제 + const keywordIdsBeforeUpdate = arrayHandler.extractValues(linkFeedbackKeywords, 'id'); + const deleteLinkFeedbackKeyword = await linkFeedbacKeywordDB.deleteLinkFeedbackListKeyword(client, feedbackIdList, keywordIdsBeforeUpdate); + + //^_^// 삭제한 keyword count-- 업데이트 + const deleteKeywords = await keywordDB.keywordCountDelete(client, keywordIdsBeforeUpdate); + + //^_^// 쓴 피드백 삭제 + const deletedFeedbackList = await feedbackDB.deleteFeedbackList(client, feedbackIdList); + } + + //^_^// 해당 팀에 포함된 이슈 삭제 + if (teamIssueIdList.length > 0) { + const deletedIssueList = await issueDB.deleteIssueList(client, teamIssueIdList); + } + + //^_^// 팀 삭제 + const team = await teamDB.deleteTeam(client, teamId); + res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.DELETE_TEAM_SUCCESS, { team })); } catch (error) { functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`); console.log(error); From 3b7be3ef34eae76e2932f4c81cd118434a221367 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Sun, 28 Aug 2022 02:33:26 +0900 Subject: [PATCH 19/27] =?UTF-8?q?feat:>=20=ED=8C=80=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EC=8B=9C=20=ED=95=B4=EB=8B=B9=20=ED=8C=80=EC=9D=98=20?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=20=EB=AA=A8=EB=91=90=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?#207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/team/teamDELETE.js | 3 +++ functions/db/memberDB.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/functions/api/routes/team/teamDELETE.js b/functions/api/routes/team/teamDELETE.js index 66671a0..1733fb0 100644 --- a/functions/api/routes/team/teamDELETE.js +++ b/functions/api/routes/team/teamDELETE.js @@ -52,6 +52,9 @@ module.exports = async (req, res) => { const deletedIssueList = await issueDB.deleteIssueList(client, teamIssueIdList); } + //^_^// 해당 팀에 포함된 멤버들 전부 삭제 + const deletedMemberList = await memberDB.deleteAllMemberByTeamId(client, teamId); + //^_^// 팀 삭제 const team = await teamDB.deleteTeam(client, teamId); res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.DELETE_TEAM_SUCCESS, { team })); diff --git a/functions/db/memberDB.js b/functions/db/memberDB.js index dfb1323..df982d1 100644 --- a/functions/db/memberDB.js +++ b/functions/db/memberDB.js @@ -273,6 +273,22 @@ const checkUserIsHost = async (client, userId) => { return convertSnakeToCamel.keysToCamel(rows); }; +const deleteAllMemberByTeamId = async (client, teamId) => { + const { rows } = await client.query( + ` + UPDATE member + SET is_deleted = true, + updated_at = NOW() + WHERE team_id = $1 + RETURNING * + `, + + [teamId], + ); + + return convertSnakeToCamel.keysToCamel(rows); +}; + module.exports = { getAllTeamByUserId, getAllTeamMemberByTeamId, @@ -290,4 +306,5 @@ module.exports = { getMemberByTeamId, checkDuplicateMember, checkUserIsHost, + deleteAllMemberByTeamId, }; From 07250869962bda3282f93f76a1bed559bfa71ded Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Mon, 29 Aug 2022 21:27:33 +0900 Subject: [PATCH 20/27] =?UTF-8?q?feat:>=20=EC=9C=A0=EC=A0=80=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8/=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=ED=95=9C=20API=EB=A1=9C=20=ED=86=B5=EC=9D=BC=20#205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/auth/authLoginPOST.js | 23 ++++++++++--------- functions/api/routes/auth/authRegisterPOST.js | 15 +++--------- functions/api/routes/auth/index.js | 3 ++- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/functions/api/routes/auth/authLoginPOST.js b/functions/api/routes/auth/authLoginPOST.js index 4b729f4..4e92482 100644 --- a/functions/api/routes/auth/authLoginPOST.js +++ b/functions/api/routes/auth/authLoginPOST.js @@ -52,18 +52,19 @@ module.exports = async (req, res) => { client = await db.connect(); authUser = await userDB.getUserByAuthenticationCode(client, kakao_profile.data.id); //^_^// kakao id == auth code if (!authUser) { - return res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.NEED_REGISTER, { accesstoken: socialToken.data.access_token, refreshtoken: socialToken.data.refresh_token })); - } - const accesstoken = jwtHandlers.sign(authUser); - const refreshtoken = jwtHandlers.refresh(authUser); - const user = await userDB.updateRefreshTokenById(client, authUser.id, refreshtoken); + const tempUser = await userDB.addUser(client, '', '', kakao_profile.data.id, provider, ''); + const accesstoken = jwtHandlers.sign(tempUser); + const refreshtoken = jwtHandlers.refresh(tempUser); + const user = await userDB.updateRefreshTokenById(client, tempUser.id, refreshtoken); - return res.status(statusCode.OK).send( - util.success(statusCode.OK, responseMessage.READ_USER_SUCCESS, { - user, - accesstoken, - }), - ); + return res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.CREATED_USER, { user, accesstoken })); + } else { + const accesstoken = jwtHandlers.sign(authUser); + const refreshtoken = jwtHandlers.refresh(authUser); + const user = await userDB.updateRefreshTokenById(client, authUser.id, refreshtoken); + + return res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.LOGIN_SUCCESS, { user, accesstoken })); + } } catch (error) { const slackMessage = `[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl} ${req.user ? `uid:${req.user.id}` : 'req.user 없음'} ${JSON.stringify(error)}`; diff --git a/functions/api/routes/auth/authRegisterPOST.js b/functions/api/routes/auth/authRegisterPOST.js index 6e67390..1470625 100644 --- a/functions/api/routes/auth/authRegisterPOST.js +++ b/functions/api/routes/auth/authRegisterPOST.js @@ -8,24 +8,15 @@ const jwtHandlers = require('../../../lib/jwtHandlers'); const slackAPI = require('../../../lib/slackAPI'); module.exports = async (req, res) => { - const { profileId, name, provider, accesstoken, refreshtoken } = req.body; + const { id: userId } = req.user; + const { profileId, name, provider } = req.body; const imageUrls = req.imageUrls; let client; let kakao_profile = ''; - if (!profileId || !name || !provider || !accesstoken || !refreshtoken) { + if (!profileId || !name || !provider) { return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.NULL_VALUE)); } - try { - kakao_profile = await axios.get('https://kapi.kakao.com/v2/user/me', { - headers: { - Authorization: 'Bearer ' + accesstoken, - 'Content-Type': 'application/json', - }, - }); - } catch (error) { - return res.status(statusCode.NOT_FOUND).json(util.fail(statusCode.NOT_FOUND, responseMessage.WRONG_TOKEN)); - } try { client = await db.connect(); const check = await userDB.checkUserProfileId(client, profileId); diff --git a/functions/api/routes/auth/index.js b/functions/api/routes/auth/index.js index a261d4a..f0f0685 100644 --- a/functions/api/routes/auth/index.js +++ b/functions/api/routes/auth/index.js @@ -1,8 +1,9 @@ const express = require('express'); const router = express.Router(); const uploadImage = require('../../../middlewares/uploadImage'); +const { checkUser } = require('../../../middlewares/auth'); router.post('/login', require('./authLoginPOST')); -router.post('/register', uploadImage('user'), require('./authRegisterPOST')); +router.post('/register', checkUser, uploadImage('user'), require('./authRegisterPOST')); module.exports = router; From b38f66f941f588a005d95f3707d83ecc7a043ef6 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Mon, 29 Aug 2022 22:00:57 +0900 Subject: [PATCH 21/27] =?UTF-8?q?feat:>=20=EC=9C=A0=EC=A0=80=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=9E=85=EB=A0=A5=20API=20=EC=8B=A0=EA=B7=9C=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=EB=A7=8C=20=EA=B0=80=EC=9E=85=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20#205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/auth/authRegisterPOST.js | 19 ++++++++----------- functions/constants/responseMessage.js | 1 + 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/functions/api/routes/auth/authRegisterPOST.js b/functions/api/routes/auth/authRegisterPOST.js index 1470625..ecbc1a2 100644 --- a/functions/api/routes/auth/authRegisterPOST.js +++ b/functions/api/routes/auth/authRegisterPOST.js @@ -8,7 +8,7 @@ const jwtHandlers = require('../../../lib/jwtHandlers'); const slackAPI = require('../../../lib/slackAPI'); module.exports = async (req, res) => { - const { id: userId } = req.user; + const { id: userId, profileId: userProfileId } = req.user; const { profileId, name, provider } = req.body; const imageUrls = req.imageUrls; let client; @@ -19,23 +19,20 @@ module.exports = async (req, res) => { try { client = await db.connect(); + if (userProfileId) { + return res.status(statusCode.FORBIDDEN).send(util.fail(statusCode.FORBIDDEN, responseMessage.REGISTERED_USER)); + } const check = await userDB.checkUserProfileId(client, profileId); if (check) { - client.release(); return res.status(statusCode.NO_CONTENT).send(util.fail(statusCode.NO_CONTENT, responseMessage.DUPLICATE_USER_PROFILE_ID)); } const tempUser = await userDB.addUser(client, profileId, name, kakao_profile.data.id, provider, imageUrls); - const accessToken = jwtHandlers.sign(tempUser); - const refreshToken = jwtHandlers.refresh(tempUser); - const user = await userDB.updateRefreshTokenById(client, tempUser.id, refreshToken); + const accesstoken = jwtHandlers.sign(tempUser); + const refreshtoken = jwtHandlers.refresh(tempUser); + const user = await userDB.updateRefreshTokenById(client, tempUser.id, refreshtoken); - return res.status(statusCode.OK).send( - util.success(statusCode.OK, responseMessage.CREATED_USER, { - user, - accesstoken: accessToken, - }), - ); + return res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.CREATED_USER, { user, accesstoken })); } catch (error) { const slackMessage = `[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl} ${req.user ? `uid:${req.user.id}` : 'req.user 없음'} ${JSON.stringify(error)}`; diff --git a/functions/constants/responseMessage.js b/functions/constants/responseMessage.js index 9e178c4..1c7ed2a 100644 --- a/functions/constants/responseMessage.js +++ b/functions/constants/responseMessage.js @@ -6,6 +6,7 @@ module.exports = { // 회원가입 CREATED_USER: '회원 가입 성공', NEED_REGISTER: '회원 가입 필요', + REGISTERED_USER: '이미 유저 정보를 입력한 유저입니다.', // 로그인 LOGIN_SUCCESS: '로그인 성공', From 965a4db5366b093389658a762c367d768a75251c Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Tue, 30 Aug 2022 02:16:57 +0900 Subject: [PATCH 22/27] =?UTF-8?q?feat:>=20=EC=9C=A0=EC=A0=80=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=9E=85=EB=A0=A5=20API=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=20#205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/auth/authRegisterPOST.js | 14 ++++++++------ functions/constants/responseMessage.js | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/functions/api/routes/auth/authRegisterPOST.js b/functions/api/routes/auth/authRegisterPOST.js index ecbc1a2..5413c28 100644 --- a/functions/api/routes/auth/authRegisterPOST.js +++ b/functions/api/routes/auth/authRegisterPOST.js @@ -12,27 +12,29 @@ module.exports = async (req, res) => { const { profileId, name, provider } = req.body; const imageUrls = req.imageUrls; let client; - let kakao_profile = ''; if (!profileId || !name || !provider) { return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.NULL_VALUE)); } try { client = await db.connect(); - if (userProfileId) { + if (userId && userProfileId) { return res.status(statusCode.FORBIDDEN).send(util.fail(statusCode.FORBIDDEN, responseMessage.REGISTERED_USER)); } - const check = await userDB.checkUserProfileId(client, profileId); - if (check) { + const checkUser = await userDB.checkUserProfileId(client, profileId); + if (checkUser && checkUser.id != userId) { return res.status(statusCode.NO_CONTENT).send(util.fail(statusCode.NO_CONTENT, responseMessage.DUPLICATE_USER_PROFILE_ID)); } - const tempUser = await userDB.addUser(client, profileId, name, kakao_profile.data.id, provider, imageUrls); + let tempUser; + if (imageUrls) tempUser = await userDB.updateUserInformationIncludeImage(client, userId, profileId, name, imageUrls); + else tempUser = await userDB.updateUserInformationWithoutImage(client, userId, profileId, name); + const accesstoken = jwtHandlers.sign(tempUser); const refreshtoken = jwtHandlers.refresh(tempUser); const user = await userDB.updateRefreshTokenById(client, tempUser.id, refreshtoken); - return res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.CREATED_USER, { user, accesstoken })); + return res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.REGISTER_USER_SUCCESS, { user, accesstoken })); } catch (error) { const slackMessage = `[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl} ${req.user ? `uid:${req.user.id}` : 'req.user 없음'} ${JSON.stringify(error)}`; diff --git a/functions/constants/responseMessage.js b/functions/constants/responseMessage.js index 1c7ed2a..0446109 100644 --- a/functions/constants/responseMessage.js +++ b/functions/constants/responseMessage.js @@ -7,6 +7,7 @@ module.exports = { CREATED_USER: '회원 가입 성공', NEED_REGISTER: '회원 가입 필요', REGISTERED_USER: '이미 유저 정보를 입력한 유저입니다.', + REGISTER_USER_SUCCESS: '유저 정보 입력 성공', // 로그인 LOGIN_SUCCESS: '로그인 성공', From 54b674cb97ff9988ccd2a4c1d6dd24915fc995f7 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Tue, 30 Aug 2022 02:39:40 +0900 Subject: [PATCH 23/27] =?UTF-8?q?feat:>=20=ED=86=A0=ED=81=B0=20=EB=A7=8C?= =?UTF-8?q?=EB=A3=8C=20=EC=8B=9C=20=EB=A6=AC=ED=94=84=EB=A0=88=EC=8B=9C=20?= =?UTF-8?q?=EB=B0=8F=20=EC=83=88=20=ED=86=A0=ED=81=B0=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=20#205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/auth/authRefreshPUT.js | 48 +++++++++++++++++++++ functions/api/routes/auth/index.js | 1 + functions/constants/responseMessage.js | 1 + 3 files changed, 50 insertions(+) create mode 100644 functions/api/routes/auth/authRefreshPUT.js diff --git a/functions/api/routes/auth/authRefreshPUT.js b/functions/api/routes/auth/authRefreshPUT.js new file mode 100644 index 0000000..076087d --- /dev/null +++ b/functions/api/routes/auth/authRefreshPUT.js @@ -0,0 +1,48 @@ +const functions = require('firebase-functions'); +const util = require('../../../lib/util'); +const statusCode = require('../../../constants/statusCode'); +const responseMessage = require('../../../constants/responseMessage'); +const db = require('../../../db/db'); +const slackAPI = require('../../../lib/slackAPI'); +const { userDB } = require('../../../db'); +const jwtHandlers = require('../../../lib/jwtHandlers'); +const { TOKEN_INVALID, TOKEN_EXPIRED } = require('../../../constants/jwt'); + +module.exports = async (req, res) => { + const { refreshToken } = req.body; + + if (!refreshToken) { + return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.NULL_VALUE)); + } + + let client; + + try { + client = await db.connect(req); + + const tokenUser = jwtHandlers.verify(refreshToken); + if (tokenUser == TOKEN_EXPIRED) { + return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.TOKEN_EXPIRED)); + } + if (tokenUser == TOKEN_INVALID) { + return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.TOKEN_INVALID)); + } + + const tempUser = await userDB.getUserById(client, tokenUser.id); + const accesstoken = jwtHandlers.sign(tempUser); + const refreshtoken = jwtHandlers.refresh(tempUser); + const user = await userDB.updateRefreshTokenById(client, tempUser.id, refreshtoken); + + res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.TOKEN_REFRESH_SUCCESS, { user, accesstoken })); + } catch (error) { + functions.logger.error(`[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl}`, `[CONTENT] ${error}`); + console.log(error); + + const slackMessage = `[ERROR] [${req.method.toUpperCase()}] ${req.originalUrl} ${req.user ? `uid:${req.user.id}` : 'req.user 없음'} + ${JSON.stringify(error)}`; + slackAPI.sendMessageToSlack(slackMessage, slackAPI.DEV_WEB_HOOK_ERROR_MONITORING); + res.status(statusCode.INTERNAL_SERVER_ERROR).send(util.fail(statusCode.INTERNAL_SERVER_ERROR, responseMessage.INTERNAL_SERVER_ERROR)); + } finally { + client.release(); + } +}; diff --git a/functions/api/routes/auth/index.js b/functions/api/routes/auth/index.js index f0f0685..cb0356d 100644 --- a/functions/api/routes/auth/index.js +++ b/functions/api/routes/auth/index.js @@ -5,5 +5,6 @@ const { checkUser } = require('../../../middlewares/auth'); router.post('/login', require('./authLoginPOST')); router.post('/register', checkUser, uploadImage('user'), require('./authRegisterPOST')); +router.put('/refresh', require('./authRefreshPUT')); module.exports = router; diff --git a/functions/constants/responseMessage.js b/functions/constants/responseMessage.js index 0446109..18cab2f 100644 --- a/functions/constants/responseMessage.js +++ b/functions/constants/responseMessage.js @@ -19,6 +19,7 @@ module.exports = { TOKEN_EXPIRED: '만료된 토큰입니다.', TOKEN_INVALID: '잘못된 토큰입니다.', DUPLICATE_USER_PROFILE_ID: '*중복된 아이디입니다.', + TOKEN_REFRESH_SUCCESS: '토큰 리프레시 성공', // 유저 READ_PROFILE_SUCCESS: '프로필 조회 성공', From 7c217bd095c4c318d8b4ab8b1cf4a85fcdf8997a Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Wed, 7 Sep 2022 15:47:44 +0900 Subject: [PATCH 24/27] =?UTF-8?q?refactor:=20=EB=82=B4=EA=B0=80=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=ED=95=9C=20=EB=84=88=EA=B0=80=EC=86=8C?= =?UTF-8?q?=EA=B0=9C=EC=84=9C=20=EC=A1=B0=ED=9A=8C=20my,=20myAll=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=EC=9C=A0=EC=A0=80=EA=B0=80=20=ED=8F=BC=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=ED=95=9C=20=EB=82=A0=EC=A7=9C=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#210?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/form/formMyAllGET.js | 8 +++++--- functions/api/routes/form/formMyGET.js | 8 +++++--- functions/db/answerDB.js | 8 ++++---- functions/db/formDB.js | 4 +++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/functions/api/routes/form/formMyAllGET.js b/functions/api/routes/form/formMyAllGET.js index 6af9216..fbec6e7 100644 --- a/functions/api/routes/form/formMyAllGET.js +++ b/functions/api/routes/form/formMyAllGET.js @@ -23,18 +23,20 @@ module.exports = async (req, res) => { client = await db.connect(req); //^_^// formId 답변 유무, 최신순 정렬 - const myFormIdRecentList = await answerDB.getRecentFormIdListByUserId(client, userId); + const myFormIdRecentList = await answerDB.getFormIdListByUserId(client, userId); myFormIdRecentList.sort(function (a, b) { if (b.cnt === '0') return -1; + else if (b.createdAt < a.createdAt) return -1; }); if (myFormIdRecentList.length === 0) { return res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.NO_MY_FORM_CONTENT)); } const idUnique = myFormIdRecentList.filter((form, index, arr) => { - return arr.findIndex((item) => item.formId === form.formId) === index; + return arr.findIndex((item) => item.id === form.id) === index; }); - let idList = extractValues(idUnique, 'formId'); + + let idList = extractValues(idUnique, 'id'); const count = idList.length; //^_^// form id로 form, answer 정보 가져오기 diff --git a/functions/api/routes/form/formMyGET.js b/functions/api/routes/form/formMyGET.js index 4427c30..5563cc9 100644 --- a/functions/api/routes/form/formMyGET.js +++ b/functions/api/routes/form/formMyGET.js @@ -23,18 +23,20 @@ module.exports = async (req, res) => { client = await db.connect(req); //^_^// formId 답변 유무, 최신순 정렬 - const myFormIdRecentList = await answerDB.getRecentFormIdListByUserId(client, userId); + const myFormIdRecentList = await answerDB.getFormIdListByUserId(client, userId); myFormIdRecentList.sort(function (a, b) { if (b.cnt === '0') return -1; + else if (b.createdAt < a.createdAt) return -1; }); if (myFormIdRecentList.length === 0) { return res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.NO_MY_FORM_CONTENT)); } const idUnique = myFormIdRecentList.filter((form, index, arr) => { - return arr.findIndex((item) => item.formId === form.formId) === index; + return arr.findIndex((item) => item.id === form.id) === index; }); - let idList = extractValues(idUnique, 'formId'); + + let idList = extractValues(idUnique, 'id'); const count = idList.length; if (idList.length > 2) idList = idList.slice(0, 2); diff --git a/functions/db/answerDB.js b/functions/db/answerDB.js index 71c2bcf..755be4a 100644 --- a/functions/db/answerDB.js +++ b/functions/db/answerDB.js @@ -78,16 +78,16 @@ const getAnswerByFormIdAndUserIdForFormDetailTopKeyword = async (client, formId, return convertSnakeToCamel.keysToCamel(rows); }; -const getRecentFormIdListByUserId = async (client, userId) => { +const getFormIdListByUserId = async (client, userId) => { const { rows } = await client.query( ` - SELECT l.form_id, l.created_at, COUNT(a.id) as cnt + SELECT l.form_id as id, l.created_at, COUNT(a.id) as cnt FROM "link_user_form" l LEFT JOIN "answer" a ON l.id = a.link_user_form_id WHERE l.user_id = $1 + AND l.is_deleted = false GROUP BY l.form_id, l.created_at - ORDER BY created_at DESC `, [userId], ); @@ -249,7 +249,7 @@ module.exports = { addAnswer, getAnswerByFormIdListAndUserID, getAnswerUserIdByAnswerId, - getRecentFormIdListByUserId, + getFormIdListByUserId, getAnswerByFormIdList, getAnswerByFormIdAndUserId, getAnswerCountByFormIdAndUserId, diff --git a/functions/db/formDB.js b/functions/db/formDB.js index 01212ac..faf263d 100644 --- a/functions/db/formDB.js +++ b/functions/db/formDB.js @@ -175,13 +175,15 @@ const getFormDetail = async (client, formId, userId) => { const getFormByFormIdList = async (client, formIdList, userId) => { const { rows } = await client.query( ` - SELECT f.id, f.title, f.subtitle, f.dark_icon_image, f.created_at + SELECT f.id, f.title, f.subtitle, f.dark_icon_image, l.created_at FROM "form" f JOIN "link_user_form" l ON l.form_id = f.id WHERE f.is_deleted = false + AND l.is_deleted = false AND l.user_id = $1 AND f.id in (${formIdList.join(',')}) + ORDER BY l.created_at DESC `, [userId], ); From b39f12d2e39b79f455038b59cb70bd0cacf18423 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Wed, 7 Sep 2022 15:58:51 +0900 Subject: [PATCH 25/27] =?UTF-8?q?fix:=20=EA=B8=B0=EC=A1=B4=EA=B3=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EB=A1=9C=EC=A7=81=20=EB=8B=AC=EB=9D=BC?= =?UTF-8?q?=EC=A7=90=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=8C=80=EC=9D=91=20#210?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/team/teamIssueGET.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/functions/api/routes/team/teamIssueGET.js b/functions/api/routes/team/teamIssueGET.js index b342432..765106e 100644 --- a/functions/api/routes/team/teamIssueGET.js +++ b/functions/api/routes/team/teamIssueGET.js @@ -7,6 +7,7 @@ const db = require('../../../db/db'); const { issueDB } = require('../../../db'); const resizeImage = require('../../../lib/resizeImage'); const slackAPI = require('../../../lib/slackAPI'); +const { result } = require('lodash'); const extractValues = (arr, key) => { if (!Array.isArray(arr)) return [arr[key] || null]; @@ -37,6 +38,7 @@ module.exports = async (req, res) => { for (const issue of myIssue) { issue.createdAt = dayjs(issue.createdAt).format('YYYY-MM-DD'); } + console.log(myIssue); const myTeam = await issueDB.getTeamByIssueIdList(client, idList); myTeam.forEach((item) => (item.image = resizeImage(item.image))); @@ -63,9 +65,12 @@ module.exports = async (req, res) => { myTeam.forEach((team) => map.set(team.issueId, { ...map.get(team.issueId), team })); const resultList = Array.from(map.values()); + let i = 0; resultList.forEach((item) => { - item.feedback.forEach((o) => delete o.issueId); - delete item.team.issueId; + if (item.feedback) { + item.feedback.forEach((o) => delete o.issueId); + delete item.team.issueId; + } }); res.status(statusCode.OK).send(util.success(statusCode.OK, responseMessage.READ_MY_ISSUE_SUCCESS, resultList)); From e6bc09b3d5a19ddb3c80992e329cce1fc32163ed Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Sun, 11 Sep 2022 21:49:52 +0900 Subject: [PATCH 26/27] =?UTF-8?q?chore:=20status=20code=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20#210?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/auth/authLoginPOST.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/api/routes/auth/authLoginPOST.js b/functions/api/routes/auth/authLoginPOST.js index 4e92482..15d98a2 100644 --- a/functions/api/routes/auth/authLoginPOST.js +++ b/functions/api/routes/auth/authLoginPOST.js @@ -34,7 +34,7 @@ module.exports = async (req, res) => { }); } catch (error) { console.log(error); - return res.status(statusCode.NOT_FOUND).json(util.fail(statusCode.NOT_FOUND, responseMessage.WRONG_AUTH)); + return res.status(statusCode.BAD_REQUEST).json(util.fail(statusCode.BAD_REQUEST, responseMessage.WRONG_AUTH)); } try { @@ -45,7 +45,7 @@ module.exports = async (req, res) => { }, }); } catch (error) { - return res.status(statusCode.NOT_FOUND).json(util.fail(statusCode.NOT_FOUND, responseMessage.WRONG_TOKEN)); + return res.status(statusCode.BAD_REQUEST).json(util.fail(statusCode.BAD_REQUEST, responseMessage.WRONG_TOKEN)); } try { From 10752ae66256a9251df56b74dfd9d3bf42cfcd90 Mon Sep 17 00:00:00 2001 From: eojinsarang joo Date: Wed, 14 Sep 2022 11:04:56 +0900 Subject: [PATCH 27/27] =?UTF-8?q?add:>=20provider=20=ED=95=84=EC=88=98=20?= =?UTF-8?q?=EA=B0=92=20#210?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/auth/authLoginPOST.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/api/routes/auth/authLoginPOST.js b/functions/api/routes/auth/authLoginPOST.js index 15d98a2..41efd5c 100644 --- a/functions/api/routes/auth/authLoginPOST.js +++ b/functions/api/routes/auth/authLoginPOST.js @@ -14,7 +14,7 @@ module.exports = async (req, res) => { let kakao_profile; let authUser; let client; - if (!authenticationCode) { + if (!provider || !authenticationCode) { return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.NULL_VALUE)); } try {