Skip to content

Latest commit

ย 

History

History
203 lines (154 loc) ยท 5.82 KB

README.md

File metadata and controls

203 lines (154 loc) ยท 5.82 KB

backend

๐ŸŽž WE-SOPT client & server seminar "NETFLIX"

1. ์—ญํ•  ๋ถ„๋‹ด

๐Ÿ’ก ์ฃผํ˜„: ์ดˆ๊ธฐ ํ™˜๊ฒฝ ์„ธํŒ…, DB ์„ค๊ณ„, API ๊ตฌํ˜„, README ์ž‘์„ฑ, WIKI ์ž‘์„ฑ

๐Ÿ’ก ์œ ๋ฆผ: DB ์„ค๊ณ„, API ๊ตฌํ˜„


API ๋ช…์„ธ์„œ ๋ณด๋Ÿฌ๊ฐ€๊ธฐ <-- click!

URI ๋ฉ”์„œ๋“œ ์„ค๋ช… ๋‹ด๋‹น
/watching GET ์‹œ์ฒญ ์ค‘์ธ ์ฝ˜ํ…์ธ  ๊ฐ€์ ธ์˜ค๊ธฐ ์ฃผํ˜„
/content/rank GET ๋žญํ‚น ์ˆœ์œผ๋กœ ์ฝ˜ํ…์ธ  ๊ฐ€์ ธ์˜ค๊ธฐ ์ฃผํ˜„
/content/:categoryNum GET ์นดํ…Œ๊ณ ๋ฆฌ ๋ณ„๋กœ ๊ฐ€์ ธ์˜ค๊ธฐ ์ฃผํ˜„
/like/:id POST ์ข‹์•„์š”, ์ข‹์•„์š” ์ทจ์†Œ ์œ ๋ฆผ
/like GET ์ข‹์•„์š” ๋ˆ„๋ฅธ ์ฝ˜ํ…์ธ  ๊ฐ€์ ธ์˜ค๊ธฐ ์œ ๋ฆผ


2. ์ฝ”๋“œ ์ปจ๋ฒค์…˜

๐Ÿ“Œย ๋ณ€์ˆ˜๋ช…

  1. Camel Case ์‚ฌ์šฉ
    โ€ข lower Camel Case
  2. ํ•จ์ˆ˜์˜ ๊ฒฝ์šฐ ๋™์‚ฌ+๋ช…์‚ฌ ์‚ฌ์šฉ
    โ€ข ex) getInformation()
  3. ๊ธธ์ด๋Š” 20์ž๋กœ ์ œํ•œํ•œ๋‹ค.
    โ€ข ๋ถ€๋“์ดํ•œ ๊ฒฝ์šฐ ํŒ€์›๊ณผ์˜ ์ƒ์˜๋ฅผ ๊ฑฐ์นœ๋‹ค.
  4. flag๋กœ ์‚ฌ์šฉ ๋˜๋Š” ๋ณ€์ˆ˜๋Š” ์กฐ๋™์‚ฌ + flag ์ข…๋ฅ˜๋กœ ๊ตฌ์„ฑ
    โ€ข ex) isNum
  5. ์•ฝ์–ด๋Š” ๋˜๋„๋ก ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค.

๐Ÿ“Œย ์ฃผ์„

  • ํ•œ ์ค„ ์ฃผ์„์€ // ์„ ์‚ฌ์šฉํ•œ๋‹ค.

  • ๊ทธ ์ด์ƒ์€ /** */ ์„ ์‚ฌ์šฉํ•œ๋‹ค.

  • ํ•จ์ˆ˜ ์„ค๋ช… ์ฃผ์„์€ /** */ ์„ ์‚ฌ์šฉํ•œ๋‹ค.

    /**
     *  @route GET /user/:userId
     *  @desc GET one user
     *  @access Private
     */

๐Ÿ“Œย Bracket

// ํ•œ์ค„ if ๋ฌธ - ์—ฌ๋Ÿฌ ์ค„๋กœ ์ž‘์„ฑ
 if(trigger) {
   return;
 }

// ๊ด„ํ˜ธ ์‚ฌ์šฉ ํ•œ์นธ ๋„์šฐ๊ณ  ์‚ฌ์šฉํ•œ๋‹ค.
 if (left == true) {
    return;
 }

// ๋„์–ด์“ฐ๊ธฐ
 if (a == 5) { // ์–‘์ชฝ ์‚ฌ์ด๋กœ ๋„์–ด์“ฐ๊ธฐ
    return;  
 }

๐Ÿ“Œย ๋น„๋™๊ธฐ ํ•จ์ˆ˜์˜ ์‚ฌ์šฉ

  • async await ํ•จ์ˆ˜ ์‚ฌ์šฉ์„ ์ง€ํ–ฅํ•œ๋‹ค.
  • Promise ์‚ฌ์šฉ์€ ์ง€์–‘ํ•œ๋‹ค.

๐Ÿ“Œ Database

  1. DB ์ด๋ฆ„ (์Šคํ‚ค๋งˆ)
    • ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ช…์€ ์˜์–ด ๋Œ€๋ฌธ์ž๋กœ ๊ตฌ์„ฑํ•œ๋‹ค.
    • ๊ธธ์ด๋Š” 8์ž ์ด๋‚ด๋กœ ๊ตฌ์„ฑํ•œ๋‹ค.
  2. ์ปฌ๋ ‰์…˜
    • ์†Œ๋ฌธ์ž๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค
    • 's' ๋ฅผ ์‚ฌ์šฉ(ex, users profiles)
    • ์ปฌ๋ ‰์…˜ ๋ช…์˜ ๊ตฌ์„ฑ์€ ์ตœ๋Œ€ 3๋‹จ์–ด๊นŒ์ง€ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
    • ์ตœ๋Œ€ ๊ธธ์ด๋Š” 26์ž ์ด๋‚ด๋กœ ๊ตฌ์„ฑํ•œ๋‹ค.
  3. ์ปฌ๋Ÿผ
    • ์ปฌ๋Ÿผ์€ snake ํ‘œ๊ธฐ๋ฒ•์„ ๋”ฐ๋ฅด๊ณ , ์˜๋ฏธ์žˆ๋Š” ์ปฌ๋Ÿผ๋ช…_์ ‘๋ฏธ์‚ฌ ํ˜•ํƒœ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
    • ์ปฌ๋Ÿผ์˜ ์„ฑ์งˆ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ ‘๋ฏธ์‚ฌ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. (์‚ฌ์šฉํ•˜๋Š” ๋ฐ์ดํ„ฐ์˜ ํƒ€์ž…์„ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฒƒ์ด ์•„๋‹˜์— ์œ ์˜)

๐Ÿ“Œ ๋ฌธ์ž์—ด

  • ๋ฌธ์ž์—ด์„ ์“ธ ๋•Œ๋Š”ย ''ย ๋”ฐ์˜ดํ‘œ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

๐Ÿ“Œ ์Šคํƒ€์ผ

  • ํƒ€์ž… ์•ž์— ๊ณต๋ฐฑ์„ ๋„ฃ๋Š”๋‹ค.

    ์˜ˆ) const foo: string = "hello";

  • ์„ธ๋ฏธ์ฝœ๋ก , ์ฝœ๋ก , ์ปด๋งˆ ๋’ค์—๋Š” ํ•ญ์ƒ ๊ณต๋ฐฑ์„ ๋‘”๋‹ค.

    ์˜ˆ)ย for (var i = 0, n = str.length; i < 10; i++) { }

  • ๋ณ€์ˆ˜๋Š” ๋‹จ์ผ ์„ ์–ธ์„ ํ•œ๋‹ค.

    • useย var x = 1; var y = 2;ย overย var x = 1, y = 2;
  • ์•ž์˜ ๊ณต๋ฐฑ(indentation)์€ ์ŠคํŽ˜์ด์Šค 2๊ฐœ๋กœ ๋งž์ถ˜๋‹ค.

  • ํ™”์‚ดํ‘œ ํ•จ์ˆ˜

    • (x) => x + xย (X) x => x + x (O)
    • (x,y) => x + y (O) <T>(x: T, y: T) => x === y (O)


3. GIT ๋ธŒ๋žœ์น˜ ์ „๋žต

๐ŸŒˆ Git Workflow

main โ†’ develop โ†’ juhyeon_feature/#3

main์€ ๋ชจ๋“  ์ž‘์—…์ด ๋๋‚œ ํ›„ develop์—์„œ merge ์‹œํ‚จ๋‹ค.

โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”

  • main - ์ดˆ๊ธฐ ์„ธํŒ… ์กด์žฌ
  • develop - local ์ž‘์—… ์™„๋ฃŒ ํ›„ merge ๋ธŒ๋žœ์น˜
  • juhyeon - ์ฃผํ˜„ local ๋ธŒ๋žœ์น˜
  • yoorim - ์œ ๋ฆผ local ๋ธŒ๋žœ์น˜
  • localdevelop_feature/#issue - ๊ฐ์ž์˜ ๊ธฐ๋Šฅ ์ถ”๊ฐ€ ๋ธŒ๋žœ์น˜

โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”

  1. local - feature ์—์„œ ๊ฐ์ž ๊ธฐ๋Šฅ ์ž‘์—…
  2. ์ž‘์—… ์™„๋ฃŒ ํ›„ remote - develop ์— PR ํ›„ Merge
  3. ์ฝ”๋“œ ๋ฆฌ๋ทฐ ํ›„ Confirm ๋ฐ›๊ณ  Merge
  4. remote - develop ์— Merge ๋  ๋•Œ ๋งˆ๋‹ค ๋ชจ๋“  ํŒ€์› remote - develop pull ๋ฐ›์•„ ์ตœ์‹  ์ƒํƒœ ์œ ์ง€

๐Ÿ“Œ Commit Convention

ํƒœ๊ทธ: ์ œ๋ชฉ์˜ ํ˜•ํƒœ

ํƒœ๊ทธ ์ด๋ฆ„ ์„ค๋ช…
FEAT ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•  ๊ฒฝ์šฐ
FIX ๋ฒ„๊ทธ๋ฅผ ๊ณ ์นœ ๊ฒฝ์šฐ
!BREAKING CHANGE ์ปค๋‹ค๋ž€ API ๋ณ€๊ฒฝ์˜ ๊ฒฝ์šฐ
!HOTFIX ๊ธ‰ํ•˜๊ฒŒ ์น˜๋ช…์ ์ธ ๋ฒ„๊ทธ๋ฅผ ๊ณ ์ณ์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ
STYLE ์ฝ”๋“œ ํฌ๋งท ๋ณ€๊ฒฝ, ์„ธ๋ฏธ ์ฝœ๋ก  ๋ˆ„๋ฝ, ์ฝ”๋“œ ์ˆ˜์ •์ด ์—†๋Š” ๊ฒฝ์šฐ
COMMENT ํ•„์š”ํ•œ ์ฃผ์„ ์ถ”๊ฐ€ ๋ฐ ๋ณ€๊ฒฝ
DOCS ๋ฌธ์„œ๋ฅผ ์ˆ˜์ •ํ•œ ๊ฒฝ์šฐ (ex. README ์ˆ˜์ •)
RENAME ํŒŒ์ผ ํ˜น์€ ํด๋”๋ช…์„ ์ˆ˜์ •ํ•˜๊ฑฐ๋‚˜ ์˜ฎ๊ธฐ๋Š” ์ž‘์—…์ธ ๊ฒฝ์šฐ
REMOVE ํŒŒ์ผ์„ ์‚ญ์ œํ•˜๋Š” ์ž‘์—…๋งŒ ์ˆ˜ํ–‰ํ•œ ๊ฒฝ์šฐ
CHORE ๋นŒ๋“œ ํƒœ์Šคํฌ ์—…๋ฐ์ดํŠธ, ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €๋ฅผ ์„ค์ •ํ•˜๋Š” ๊ฒฝ์šฐ



4. ํ”„๋กœ์ ํŠธ ํด๋”๋ง

|-๐Ÿ“‹ firebaserc
|-๐Ÿ“‹ firebase.json
|-๐Ÿ“‹ .gitignore
|-๐Ÿ“ functions_
               |- ๐Ÿ“‹ index.js
               |- ๐Ÿ“‹ package.json
               |- ๐Ÿ“‹ .gitignore
               |- ๐Ÿ“‹ .env
               |- ๐Ÿ“ api_ 
               |         |- ๐Ÿ“‹ index.js
               |         |- ๐Ÿ“ routes_
               |                      |- ๐Ÿ“‹ index.js
               |
               |- ๐Ÿ“ config_ 
               |            |- ๐Ÿ“‹ dbConfig.js
               |
               |- ๐Ÿ“ constants_ 
               |               |- ๐Ÿ“‹ responseMessage.js
               |               |- ๐Ÿ“‹ statusCode.js
               |
               |- ๐Ÿ“ db_ 
               |        |- ๐Ÿ“‹ db.js
               |        |- ๐Ÿ“‹ index.js
               |
               |- ๐Ÿ“ lib_
                         |- ๐Ÿ“‹ convertSnakeToCamel.js
                         |- ๐Ÿ“‹ util.js
               



5. ERD

Untitled (2)