Skip to content

Commit

Permalink
#229 [feat] 버전 조회하기
Browse files Browse the repository at this point in the history
#229 [feat] 버전 조회하기
  • Loading branch information
hyeonjeongs authored Oct 23, 2023
2 parents 8817a04 + c73f692 commit c341f70
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 62 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.306.0",
"@prisma/client": "^4.8.0",
"@prisma/client": "^5.4.2",
"axios": "^1.3.4",
"dayjs": "^1.11.7",
"dotenv": "^16.0.3",
Expand All @@ -25,22 +25,22 @@
"multer": "^1.4.5-lts.1",
"multer-s3": "^3.0.1",
"nodemailer": "^6.9.1",
"prisma": "^4.8.0"
"prisma": "^5.4.2"
},
"devDependencies": {
"@types/chai": "^4.3.4",
"@types/express": "^4.17.15",
"@types/express": "^4.17.19",
"@types/express-validator": "^3.0.0",
"@types/jsonwebtoken": "^9.0.1",
"@types/mocha": "^10.0.1",
"@types/multer": "^1.4.7",
"@types/multer-s3": "^3.0.0",
"@types/node": "^18.11.18",
"@types/node": "^20.8.6",
"@types/supertest": "^2.0.12",
"chai": "^4.3.7",
"husky": "^8.0.0",
"mocha": "^10.2.0",
"nodemon": "^2.0.20",
"nodemon": "^3.0.1",
"supertest": "^6.3.3",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
Expand Down
10 changes: 9 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ model Recommend {
recommendTo Int
bookId Int
createdAt DateTime @default(now())
Book Book @relation(fields: [bookId], references: [id], onDelete: NoAction, map: "recommend_book_id_fk")
Book Book @relation(fields: [bookId], references: [id], onDelete: Cascade, map: "recommend_book_id_fk")
recommendedByToUser User @relation("Recommend_recommendedByToUser", fields: [recommendedBy], references: [id], onDelete: Cascade, map: "recommend_user_id_fk")
recommendToToUser User @relation("Recommend_recommendToToUser", fields: [recommendTo], references: [id], onDelete: Cascade, map: "recommend_user_id_fk_2")
RecommendAlarm RecommendAlarm[]
Expand Down Expand Up @@ -125,3 +125,11 @@ model Report {
User_Report_userIdToUser User @relation("Report_userIdToUser", fields: [userId], references: [id], onDelete: Cascade, map: "report_user_id_fk")
User_Report_friendIdToUser User @relation("Report_friendIdToUser", fields: [friendId], references: [id], onDelete: Cascade, map: "report_user_id_fk_2")
}

model Version {
id Int @id @default(autoincrement())
androidForceVersion String? @db.VarChar(255)
imageUrl String? @db.VarChar(500)
text String? @db.VarChar(255)
iosForceVersion String? @db.VarChar(255)
}
1 change: 1 addition & 0 deletions src/constants/responseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default {
FAIL_CHECK_NICKNAME: "닉네임 중복 검사 실패",
SUCCESS_CHECK_NICKNAME: "닉네임 중복 검사 성공",
UPDATE_USER_PRIFILE_SUCCESS: "프로필 수정 성공",
GET_USER_VERSION_SUCCESS: "유저 강제 버전 조회 성공",

// 이미지
NO_IMAGE: "이미지가 없습니다.",
Expand Down
27 changes: 27 additions & 0 deletions src/controller/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,35 @@ const postDuplicateNickname = async (req: Request, res: Response) => {

}

const getUserVersion = async (req: Request, res:Response) => {
const userId = req.body.userId;
if (!userId) {
return res.status(sc.BAD_REQUEST).send(fail(sc.BAD_REQUEST, rm.BAD_REQUEST));
}

try {
const data = await userService.getUserVersion(+userId);

if(!data) {
return res.status(sc.BAD_REQUEST).send(fail(sc.BAD_REQUEST, rm.BAD_REQUEST))
}

return res.status(sc.OK).send(success(sc.OK, rm.GET_USER_VERSION_SUCCESS, data));

} catch (error) {
const errorMessage = slackErrorMessage(req.method.toUpperCase(), req.originalUrl, error, req.statusCode);

sendWebhookMessage(errorMessage);

res.status(sc.INTERNAL_SERVER_ERROR)
.send(fail(sc.INTERNAL_SERVER_ERROR, rm.INTERNAL_SERVER_ERROR));
}

}

const userController = {
postDuplicateNickname,
getUserVersion
}

export default userController;
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import express, { NextFunction, Request, Response } from "express";
import router from "./router";

const app = express(); // express 객체 받아옴
const PORT = 3000; // 사용할 port를 3000번으로 설정
const PORT = 3001; // 사용할 port를 3000번으로 설정

app.use(express.json()); // express 에서 request body를 json 으로 받아오겠다.

Expand Down
3 changes: 3 additions & 0 deletions src/router/userRouter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Router } from "express";
import { userController } from "../controller";
import { auth } from "../middlewares";

const router: Router = Router();

//* 닉네임 중복 검사 POST /user/duplicate
router.post("/duplicate", userController.postDuplicateNickname);
//* 유저 업데이트 버전 확인하기 GET /user/version
router.get("/v1/version", auth, userController.getUserVersion)

export default router;
18 changes: 17 additions & 1 deletion src/service/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,28 @@ const getUserByRfToken = async (refreshToken: string) => {
return user;
}

const getUserVersion = async (userId: number) => {
const versionData = await prisma.version.findUnique({
where: {
id: 1
},
select: {
imageUrl: true,
iosForceVersion: true,
androidForceVersion: true,
text: true
}
});

return versionData;
}

const userService = {
getUser,
getUserIntro,
postDuplicateNickname,
getUserByRfToken
getUserByRfToken,
getUserVersion
};

export default userService;
108 changes: 54 additions & 54 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -987,22 +987,22 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"

"@prisma/client@^4.8.0":
version "4.8.1"
resolved "https://registry.npmjs.org/@prisma/client/-/client-4.8.1.tgz"
integrity sha512-d4xhZhETmeXK/yZ7K0KcVOzEfI5YKGGEr4F5SBV04/MU4ncN/HcE28sy3e4Yt8UFW0ZuImKFQJE+9rWt9WbGSQ==
"@prisma/client@^5.4.2":
version "5.4.2"
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-5.4.2.tgz#786f9c1d8f06d955933004ac638d14da4bf14025"
integrity sha512-2xsPaz4EaMKj1WS9iW6MlPhmbqtBsXAOeVttSePp8vTFTtvzh2hZbDgswwBdSCgPzmmwF+tLB259QzggvCmJqA==
dependencies:
"@prisma/engines-version" "4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe"
"@prisma/engines-version" "5.4.1-2.ac9d7041ed77bcc8a8dbd2ab6616b39013829574"

"@prisma/engines-version@4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe":
version "4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe"
resolved "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe.tgz"
integrity sha512-MHSOSexomRMom8QN4t7bu87wPPD+pa+hW9+71JnVcF3DqyyO/ycCLhRL1we3EojRpZxKvuyGho2REQsMCvxcJw==
"@prisma/engines-version@5.4.1-2.ac9d7041ed77bcc8a8dbd2ab6616b39013829574":
version "5.4.1-2.ac9d7041ed77bcc8a8dbd2ab6616b39013829574"
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-5.4.1-2.ac9d7041ed77bcc8a8dbd2ab6616b39013829574.tgz#ff14f2926890edee47e8f1d08df7b4f392ee34bf"
integrity sha512-wvupDL4AA1vf4TQNANg7kR7y98ITqPsk6aacfBxZKtrJKRIsWjURHkZCGcQliHdqCiW/hGreO6d6ZuSv9MhdAA==

"@prisma/engines@4.8.1":
version "4.8.1"
resolved "https://registry.npmjs.org/@prisma/engines/-/engines-4.8.1.tgz"
integrity sha512-93tctjNXcIS+i/e552IO6tqw17sX8liivv8WX9lDMCpEEe3ci+nT9F+1oHtAafqruXLepKF80i/D20Mm+ESlOw==
"@prisma/engines@5.4.2":
version "5.4.2"
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-5.4.2.tgz#ba2b7faeb227c76e423e88f962afe6a031319f3f"
integrity sha512-fqeucJ3LH0e1eyFdT0zRx+oETLancu5+n4lhiYECyEz6H2RDskPJHJYHkVc0LhkU4Uv7fuEnppKU3nVKNzMh8g==

"@tsconfig/node10@^1.0.7":
version "1.0.9"
Expand Down Expand Up @@ -1049,15 +1049,6 @@
resolved "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.2.tgz"
integrity sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==

"@types/express-serve-static-core@^4.17.31":
version "4.17.32"
resolved "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.32.tgz"
integrity sha512-aI5h/VOkxOF2Z1saPy0Zsxs5avets/iaiAJYznQFm5By/pamU31xWKL//epiF4OfUA2qTOc9PV6tCUjhO8wlZA==
dependencies:
"@types/node" "*"
"@types/qs" "*"
"@types/range-parser" "*"

"@types/express-serve-static-core@^4.17.33":
version "4.17.33"
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz#de35d30a9d637dc1450ad18dd583d75d5733d543"
Expand All @@ -1084,13 +1075,13 @@
"@types/qs" "*"
"@types/serve-static" "*"

"@types/express@^4.17.15":
version "4.17.15"
resolved "https://registry.npmjs.org/@types/express/-/express-4.17.15.tgz"
integrity sha512-Yv0k4bXGOH+8a+7bELd2PqHQsuiANB+A8a4gnQrkRWzrkKlb6KHaVvyXhqs04sVW/OWlbPyYxRgYlIXLfrufMQ==
"@types/express@^4.17.19":
version "4.17.19"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.19.tgz#6ff9b4851fda132c5d3dcd2f89fdb6a7a0031ced"
integrity sha512-UtOfBtzN9OvpZPPbnnYunfjM7XCI4jyk1NvnFhTVz5krYAnW4o5DCoIekvms+8ApqhB4+9wSge1kBijdfTSmfg==
dependencies:
"@types/body-parser" "*"
"@types/express-serve-static-core" "^4.17.31"
"@types/express-serve-static-core" "^4.17.33"
"@types/qs" "*"
"@types/serve-static" "*"

Expand Down Expand Up @@ -1126,11 +1117,18 @@
dependencies:
"@types/express" "*"

"@types/node@*", "@types/node@^18.11.18":
"@types/node@*":
version "18.11.18"
resolved "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz"
integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==

"@types/node@^20.8.6":
version "20.8.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.6.tgz#0dbd4ebcc82ad0128df05d0e6f57e05359ee47fa"
integrity sha512-eWO4K2Ji70QzKUqRy6oyJWUeB7+g2cRagT3T/nxYibYcT4y2BDL8lqolRXjTHmkZCdJfIPaY73KbJAZmcryxTQ==
dependencies:
undici-types "~5.25.1"

"@types/qs@*":
version "6.9.7"
resolved "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz"
Expand Down Expand Up @@ -1623,7 +1621,7 @@ express-validator@*, express-validator@^6.15.0:

express@^4.18.2:
version "4.18.2"
resolved "https://registry.npmjs.org/express/-/express-4.18.2.tgz"
resolved "https://registry.yarnpkg.com/express/-/express-4.18.2.tgz#3fabe08296e930c796c19e3c516979386ba9fd59"
integrity sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==
dependencies:
accepts "~1.3.8"
Expand Down Expand Up @@ -2143,18 +2141,18 @@ nodemailer@^6.9.1:
resolved "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.1.tgz"
integrity sha512-qHw7dOiU5UKNnQpXktdgQ1d3OFgRAekuvbJLcdG5dnEo/GtcTHRYM7+UfJARdOFU9WUQO8OiIamgWPmiSFHYAA==

nodemon@^2.0.20:
version "2.0.20"
resolved "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz"
integrity sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==
nodemon@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-3.0.1.tgz#affe822a2c5f21354466b2fc8ae83277d27dadc7"
integrity sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==
dependencies:
chokidar "^3.5.2"
debug "^3.2.7"
ignore-by-default "^1.0.1"
minimatch "^3.1.2"
pstree.remy "^1.1.8"
semver "^5.7.1"
simple-update-notifier "^1.0.7"
semver "^7.5.3"
simple-update-notifier "^2.0.0"
supports-color "^5.5.0"
touch "^3.1.0"
undefsafe "^2.0.5"
Expand Down Expand Up @@ -2239,12 +2237,12 @@ picomatch@^2.0.4, picomatch@^2.2.1:
resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==

prisma@^4.8.0:
version "4.8.1"
resolved "https://registry.npmjs.org/prisma/-/prisma-4.8.1.tgz"
integrity sha512-ZMLnSjwulIeYfaU1O6/LF6PEJzxN5par5weykxMykS9Z6ara/j76JH3Yo2AH3bgJbPN4Z6NeCK9s5fDkzf33cg==
prisma@^5.4.2:
version "5.4.2"
resolved "https://registry.yarnpkg.com/prisma/-/prisma-5.4.2.tgz#7eac9276439ec7073ec697c6c0dfa259d96e955e"
integrity sha512-GDMZwZy7mysB2oXU+angQqJ90iaPFdD0rHaZNkn+dio5NRkGLmMqmXs31//tg/qXT3iB0cTQwnGGQNuirhSTZg==
dependencies:
"@prisma/engines" "4.8.1"
"@prisma/engines" "5.4.2"

process-nextick-args@~2.0.0:
version "2.0.1"
Expand Down Expand Up @@ -2359,22 +2357,19 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1:
resolved "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz"
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==

semver@^5.7.1:
version "5.7.1"
resolved "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==

semver@^7.3.8:
version "7.3.8"
resolved "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz"
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
dependencies:
lru-cache "^6.0.0"

semver@~7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz"
integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==
semver@^7.5.3:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
dependencies:
lru-cache "^6.0.0"

[email protected]:
version "0.18.0"
Expand Down Expand Up @@ -2426,12 +2421,12 @@ side-channel@^1.0.4:
get-intrinsic "^1.0.2"
object-inspect "^1.9.0"

simple-update-notifier@^1.0.7:
version "1.1.0"
resolved "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz"
integrity sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==
simple-update-notifier@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz#d70b92bdab7d6d90dfd73931195a30b6e3d7cebb"
integrity sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==
dependencies:
semver "~7.0.0"
semver "^7.5.3"

[email protected]:
version "2.0.1"
Expand Down Expand Up @@ -2612,6 +2607,11 @@ undefsafe@^2.0.5:
resolved "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz"
integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==

undici-types@~5.25.1:
version "5.25.3"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.25.3.tgz#e044115914c85f0bcbb229f346ab739f064998c3"
integrity sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==

[email protected], unpipe@~1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz"
Expand Down

0 comments on commit c341f70

Please sign in to comment.