Skip to content

๐Ÿญ ํ•ธ๋””์บ”๋”” ์„œ๋ฒ„

Notifications You must be signed in to change notification settings

handy-candy/HandyCandy_Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

img

๐Ÿญ Project

  • ๋ฐ”์œ ํ˜„๋Œ€์ธ๋“ค์„ ์œ„ํ•ด ๋‚˜๋งŒ์˜ ๋ณด์ƒ์„ ์„ ์‚ฌํ•˜๋Š” ๋ณด์ƒ ์•„์นด์ด๋น™ ์„œ๋น„์Šค

    ์‰ฝ๊ฒŒ ์ €์žฅํ•˜๊ณ ! ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ๋Œ€๋กœ ๋ชจ์œผ๊ณ ! ๋ณด์ƒ์„ ๊ณจ๋ผ ๊ธฐ๋‹ค๋ฆฌ๋Š” ์„ค๋ ˜๊นŒ์ง€!

    ์žŠ์—ˆ๋˜ ๋‚˜๋ฅผ ์œ„ํ•œ ์‹œ๊ฐ„์„ ํ•ธ๋””์บ”๋””๋กœ ์Œ“์•„๊ฐ€์„ธ์š”.

    ๋ณด์ƒ, ๋ณด์ƒ๋‚  ์ €์žฅ-์›ํ•  ๋•Œ ์—ด๋žŒ ๊ฐ€๋Šฅ-๋ณด์ƒ์„ ํ†ตํ•œ ๋งŒ์กฑ๊ฐ

  • SOPT 28th APPJAM, HANDY-CANDY

  • ํ”„๋กœ์ ํŠธ ๊ธฐ๊ฐ„: 2021.06.26~2021.07.17

๋‚ด ์† ์•ˆ์˜ ๋‹ฌ์ฝคํ•œ ๋ณด์ƒ, HANDY-CANDY

โœจ Base URL


๐Ÿ—ƒ Server Architecture

image

๐Ÿ›  ๊ฐœ๋ฐœ ํ™˜๊ฒฝ

img img img img img img img img

๐Ÿ“งAPI ๋ช…์„ธ์„œ

API ๋ช…์„ธ์„œ ๋งํฌ


Desktop - 1

๐Ÿ‘€ ERD Diagram

๐Ÿ“œ Coding Convention

๐Ÿ“‚ ํด๋”๊ตฌ์กฐ

  • src
    • Logger
    • api
    • config
    • interfaces
    • middleware
    • models
    • jobs
    • services
    • controllers
  • Dockerfile
  • eslint
  • prettierrc
  • commitlint
  • tsconfig

๐Ÿ–‹ ๋„ค์ด๋ฐ

Class & Constructor

  • ํด๋ž˜์Šค/์ƒ์„ฑ์ž ์ด๋ฆ„์€ UpperCamelCase๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • ๊ธ€์ž์˜ ๊ธธ์ด๋Š” 20์ž ์ด๋‚ด๋กœ ์ œํ•œํ•ฉ๋‹ˆ๋‹ค.

์ข‹์€ ์˜ˆ >

  class HandyCandy

๋‚˜์œ ์˜ˆ >

  class handycandy {}

ํ•จ์ˆ˜ & ๋ณ€์ˆ˜ & ์ธ์Šคํ„ด์Šค

  • ํ•จ์ˆ˜์™€ ๋ณ€์ˆ˜, ์ธ์Šคํ„ด์Šค์—๋Š” lowerCamelCase๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

๐Ÿท ์ฃผ์„

  • // MARK: ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์—ฐ๊ด€๋œ ์ฝ”๋“œ๋ฅผ ๊ตฌ๋ถ„์ง“์Šต๋‹ˆ๋‹ค.
  • /** */ ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ฝ”๋“œ ์ž‘์„ฑ์ž์˜ ์ด๋ฆ„์„ ๋ช…์‹œํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ“Ž ๊ธฐํƒ€

  • , ๋’ค์— ๋ฐ˜๋“œ์‹œ ๋„์–ด์“ฐ๊ธฐ๋ฅผ ํ•ฉ๋‹ˆ๋‹ค.
  • ํ•จ์ˆ˜๋ผ๋ฆฌ 1์ค„ ๊ฐœํ–‰ํ•ฉ๋‹ˆ๋‹ค.
  • ์ค‘๊ด„ํ˜ธ๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ํ˜•์‹์œผ๋กœ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
if (condition) {
  Statements;
  /*
  ...
  */
}

โœ‰๏ธ Commit Messge Rules

์„œ๋ฒ„์บ”๋”” ๋“ค์˜ Git Commit Message Rules

  • ๋ฐ˜์˜์‚ฌํ•ญ์„ ๋ฐ”๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋„๋ก ์ž‘์€ ๊ธฐ๋Šฅ ํ•˜๋‚˜๋ผ๋„ ๊ตฌํ˜„๋˜๋ฉด ์ปค๋ฐ‹์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.
  • ์ปค๋ฐ‹ํ•  ๋• ์„œ๋ฒ„์Šฌ๋ž™์— ๋…ธํ‹ฐ, pr ํ•„์ˆ˜, review request ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค.
  • ๊ธฐ๋Šฅ ๊ตฌํ˜„์ด ์™„๋ฒฝํ•˜์ง€ ์•Š์„ ๋•, ๊ฐ์ž ๋ธŒ๋žœ์น˜์— ์ปค๋ฐ‹์„ ํ•ด์ฃผ์„ธ์š”.

๐Ÿ“œ ์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€ ๋ช…๋ น์–ด ๋ชจ์Œ

์ปค๋ฐ‹ ๊ทœ์น™์„ ์ง€ํ‚ค์ง€ ์•Š์œผ๋ฉด commitlint์—์„œ ์ž๋™์œผ๋กœ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.
- feat    : ๊ธฐ๋Šฅ (์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ)
- fix     : ๋ฒ„๊ทธ (๋ฒ„๊ทธ ์ˆ˜์ •)
- refactor: ๋ฆฌํŒฉํ† ๋ง
- style   : ์Šคํƒ€์ผ (์ฝ”๋“œ ํ˜•์‹, ์„ธ๋ฏธ์ฝœ๋ก  ์ถ”๊ฐ€: ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์— ๋ณ€๊ฒฝ ์—†์Œ)
- docs    : ๋ฌธ์„œ (๋ฌธ์„œ ์ถ”๊ฐ€, ์ˆ˜์ •, ์‚ญ์ œ)
- test    : ํ…Œ์ŠคํŠธ (ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ถ”๊ฐ€, ์ˆ˜์ •, ์‚ญ์ œ: ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์— ๋ณ€๊ฒฝ ์—†์Œ)
- chore   : ๊ธฐํƒ€ ๋ณ€๊ฒฝ์‚ฌํ•ญ (๋นŒ๋“œ ์Šคํฌ๋ฆฝํŠธ ์ˆ˜์ • ๋“ฑ)

โ„น๏ธ ์ปค๋ฐ‹ ๋ฉ”์„ธ์ง€ ํ˜•์‹

  • ์ปค๋ฐ‹๋ฉ”์„ธ์ง€: ์„ค๋ช… ํ˜•์‹์œผ๋กœ ์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.
  • ์ปค๋ฐ‹ ์„ค๋ช…์€ ๋ฌด์กฐ๊ฑด ์˜์–ด๋กœ ํ•œ๋‹ค๊ณ  ์ข‹์€๊ฒŒ ์•„๋‹™๋‹ˆ๋‹ค.
  • ์ตœ๋Œ€ํ•œ ๋‚ด์šฉ ํฌํ•จ๊ณผ ์ž์„ธํ• ์ˆ˜๋ก ์ข‹์Šต๋‹ˆ๋‹ค.
  • ํ•˜์ง€๋งŒ ๋„ˆ๋ฌด ๊ธธ๊ฒŒ๋Š” ์•ˆ๋ฉ๋‹ˆ๋‹ค.

์ข‹์€ ์˜ˆ >

  feat: search api ์ถ”๊ฐ€

๋‚˜์œ ์˜ˆ >

  ๊ฒ€์ƒ‰ api ์ถ”๊ฐ€

์ข‹์€ ์˜ˆ >

  test: ํšŒ์›๊ฐ€์ž… ๋กœ์ง test code ์ž‘์„ฑ

๋‚˜์œ ์˜ˆ >

  test code ์ž‘์„ฑ,
  test: test code ์ž‘์„ฑ

๐Ÿ’ป Github mangement

์„œ๋ฒ„์บ”๋”” ๋“ค์˜ WorkFlow : Gitflow Workflow

  • Main๊ณผ Develop ๋ธŒ๋žœ์น˜

    ๋ฉ”์ธ(main): ๋ฉ”์ธ ๋ธŒ๋žœ์น˜ -> product

    ๊ฐœ๋ฐœ(development): ๊ธฐ๋Šฅ๋“ค์˜ ํ†ตํ•ฉ ๋ธŒ๋žœ์น˜ ์—ญํ• โ—๏ธ ์ด ๋ธŒ๋žœ์น˜์—์„œ ๊ธฐ๋Šฅ๋ณ„๋กœ ๋ธŒ๋žœ์น˜๋ฅผ ๋”ฐ ๋ชจ๋“  ๊ตฌํ˜„์ด ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค. -> alpha

  • Main์— ์ง์ ‘์ ์ธ commit, push๋Š” ๊ฐ€๊ธ‰์  ๊ธˆ์ง€ํ•ฉ๋‹ˆ๋‹ค. (X)

  • ์ปค๋ฐ‹ ๋ฉ”์„ธ์ง€๋Š” ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์ด ๋ด๋„ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๊ฒŒ ์จ์ฃผ์„ธ์š”.

  • ํ’€๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ํ†ตํ•ด ์ฝ”๋“œ ๋ฆฌ๋ทฐ๋ฅผ ํ•ด๋ณด์•„์š”.

development์— ๋ฐ”๋กœ mergeํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
pr์„ development๋กœ ํ•ด์ฃผ์„ธ์š”.
development์—์„œ ์™„์„ฑ์ด ๋˜๋ฉด main์œผ๋กœ ๊ทธ๋•Œ ๊ทธ๋•Œ mergeํ•ฉ๋‹ˆ๋‹ค.

merge๋Š” github์—์„œ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
merge pull request ๊ธˆ์ง€ -> squash and merge ํด๋ฆญ
rebase ๋˜๋Š” conflict ํ•ด๊ฒฐ์€ github์—์„œ ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

local code์—์„œ git status๋กœ ํ™•์ธํ•ด๊ฐ€๋ฉฐ ์ ์šฉ ํ›„ force push ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
force push ์ •๋ง ์กฐ์‹ฌํ•ด์ฃผ์„ธ์š”.

์ด์Šˆ ์—ฐ๋™ ๋ฐฉ๋ฒ•

  • ์ด์Šˆ ์ƒ์„ฑ

    Github์˜ issue ํƒญ์— ๋“ค์–ด๊ฐ€์„œ ๊ธฐ๋Šฅ ์ •์˜์„œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ issue๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
    commit message rules์™€ ๋™์ผํ•˜๊ฒŒ ์ด์Šˆ๋ฅผ ์ƒ์„ฑํ•ด์ฃผ์„ธ์š”.
    ์ด์Šˆ๋ฅผ ์ƒ์„ฑํ•˜๋ฉด ์ž๋™์œผ๋กœ ๋ฒˆํ˜ธ๊ฐ€ ๋ฐœ๊ธ‰๋ฉ๋‹ˆ๋‹ค. ์ด ๋ฒˆํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ feature ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
    
  • ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ํ•ด๋‹น ๋ธŒ๋žœ์น˜์— commit, push ํ•ฉ๋‹ˆ๋‹ค.

  • PR์„ ๋‚ ๋ฆด ๋•Œ ์ž‘์„ฑ์ž์™€ ๋ฆฌ๋ทฐ์–ด๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

  • ์ด ๋•Œ resolved #์ด์Šˆ๋ฒˆํ˜ธ๋กœ ์ž‘์„ฑํ•˜๋ฉด merge๋  ๋•Œ ํ•ด๋‹น issue๋Š” ์ž๋™ ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค.

  • ์ด๋ ‡๊ฒŒ PR์ด ์ƒ์„ฑ๋˜๋ฉด ์ƒˆ๋กœ์šด issue๋ฒˆํ˜ธ๊ฐ€ ๋ถ€์—ฌ๋ฉ๋‹ˆ๋‹ค. ์ฆ‰, PR๋„ issue์ž…๋‹ˆ๋‹ค.

๊ฐ์ž ์ž์‹ ์ด ๋งก์€ ๊ธฐ๋Šฅ ๊ตฌํ˜„์— ์„ฑ๊ณต์‹œ! ๋ธŒ๋žœ์น˜ ๋‹ค ์“ฐ๊ณ  ๋ณ‘ํ•ฉํ•˜๋Š” ๋ฐฉ๋ฒ•

  • ๋ธŒ๋žœ์น˜ ๋งŒ๋“ฆ
git branch feature/issue-๋ฒˆํ˜ธ
  • ๋ธŒ๋žœ์น˜ ์ „ํ™˜
git checkout feature/issue-๋ฒˆํ˜ธ
  • ๋ธŒ๋žœ์น˜ ๋งŒ๋“ฆ๊ณผ ๋™์‹œ์— ์ „ํ™˜
git checkout -b feature/issue-๋ฒˆํ˜ธ
  • ์ฝ”๋“œ ๋ณ€๊ฒฝ (ํ˜„์žฌ feature/issue-๋ฒˆํ˜ธ ๋ธŒ๋žœ์น˜)
git add .
git commit -m "์ปค๋ฐ‹ ๋ฉ”์„ธ์ง€" -a // ์ด์Šˆ๋ณด๋“œ ์ด๋ฆ„๋Œ€๋กœ ์ปค๋ฐ‹
- git add . ๋ฅผ ๊ธฐ๋Šฅ๋ณ„๋กœ ๋ชจ์•„๋‘”๊ฒŒ ์•„๋‹ˆ๋ผ๋ฉด ์ž์ฃผ ์“ฐ์ง€ ๋ง์•„์ฃผ์„ธ์š”.

- ํ•ด๋‹น ๊ธฐ๋Šฅ๋ผ๋ฆฌ ๋ฌถ์–ด์„œ ์ปค๋ฐ‹ํ•ด์ฃผ์„ธ์š”.
  • ํ‘ธ์‹œ (ํ˜„์žฌ feature/issue-๋ฒˆํ˜ธ ๋ธŒ๋žœ์น˜)
git push origin feature/issue-๋ฒˆํ˜ธ ๋ธŒ๋žœ์น˜
  • feature/๊ธฐ๋Šฅ ์ด์Šˆ ๋ฒˆํ˜ธ ๋ธŒ๋žœ์น˜์—์„œ ํ•  ์ผ ๋‹ค ํ—€์œผ๋ฉด pr์—์„œ ๋จธ์ง€ ํ›„ development ๋ธŒ๋žœ์น˜๋กœ ์ „ํ™˜
git checkout development
  • ๋‹ค ์“ด ๋ธŒ๋žœ์น˜ ์‚ญ์ œ (local) (ํ˜„์žฌ development ๋ธŒ๋žœ์น˜)
git branch -d feature/issue-๋ฒˆํ˜ธ
  • ๋‹ค ์“ด ๋ธŒ๋žœ์น˜ ์‚ญ์ œ (remote) (ํ˜„์žฌ development ๋ธŒ๋žœ์น˜)
git push origin :feature/issue-๋ฒˆํ˜ธ
  • development pull (ํ˜„์žฌ development ๋ธŒ๋žœ์น˜)
git pull origin development
  • ์ตœ์‹  development ์ปค๋ฐ‹ ๋ฐ˜์˜ rebase
git rebase development
git status
-> conflict ์žˆ์œผ๋ฉด ํ•ด๊ฒฐ

ํ•ด๊ฒฐํ•œ ํŒŒ์ผ๋งˆ๋‹ค git add services/UserService ์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ add
git rebase --continue (๋‹ค ๋ฐ˜์˜ํ–ˆ์œผ๋ฉด ๋‹ค์Œ conflict๋กœ ๋„˜์–ด๊ฐ)

๐Ÿน Dependencies module

{
  "name": "handycandy",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "ts-node src",
    "start": "tsc && node dist",
    "build": "tsc && node dist",
    "test": "echo \"Error: no test specified\" && exit 1",
    "postinstall": "husky install"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@commitlint/cli": "^12.1.4",
    "@commitlint/config-conventional": "^12.1.4",
    "@types/cors": "^2.8.12",
    "@types/node": "^15.12.5",
    "@typescript-eslint/eslint-plugin": "^4.28.1",
    "@typescript-eslint/parser": "^4.28.1",
    "eslint": "^7.29.0",
    "eslint-config-airbnb-base": "^14.2.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-import": "^2.23.4",
    "eslint-plugin-prettier": "^3.4.0",
    "husky": "^7.0.0",
    "lint-staged": "^11.0.0",
    "prettier": "2.3.2",
    "ts-node": "^10.0.0",
    "typescript": "^4.3.4"
  },
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "cookie-parser": "^1.4.5",
    "cors": "^2.8.5",
    "dotenv": "^10.0.0",
    "express": "^4.17.1",
    "express-validator": "^6.12.0",
    "gravatar": "^1.8.1",
    "jsonwebtoken": "^8.5.1",
    "moment": "^2.29.1",
    "moment-timezone": "^0.5.33",
    "mongoose": "^5.12.15",
    "nodemailer": "^6.6.2",
    "nodemailer-smtp-transport": "^2.7.4"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },
  "commitlint": {
    "extends": [
      "@commitlint/config-conventional"
    ]
  },
  "lint-staged": {
    "**/*.{js,ts}": "eslint"
  }
}