Skip to content

31th-SOPKATHON-2/Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

42 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‘ถ์žผ๋ฏผ์–ด ๋ฒˆ์—ญ๊ธฐ


image

์‹ ์กฐ์–ด์™€ ์œ ํ–‰์–ด๋ฅผ ์ต์ˆ™ํ•œ ํ‘œํ˜„์œผ๋กœ ๋ฒˆ์—ญํ•ด์ฃผ๋Š” ์„œ๋น„์Šค. (์•ผ ๋„ˆ๋‘ ์žผ๋ฏผ์ด ๋  ์ˆ˜ ์žˆ์–ด!)

๐Ÿ‘ฒ Contributors ์žผ๋ฏผ์ด๋“ค

๊น€๊ฒฝ๋ฆฐ ์ •์ค€์„œ
kkl4846 sunseo18


API Docs

๐Ÿ”— API Docs

ERD

image

Architecture

image

Role

Route Func Role Done
TRANSLATOR ์žผ๋ฏผ์–ด ๋ฒˆ์—ญํ•˜๊ธฐ ์ •์ค€์„œ โœ…
QUIZ ํ€ด์ฆˆ ๋ฌธ์ œ ๋ฐ ์ •๋‹ต ์ฃผ๊ธฐ ๊น€๊ฒฝ๋ฆฐ โœ…


Commit Convention

  • [Commit Convention] git commit message convention

ex) Feat: User API ํŒŒ์ผ ์ถ”๊ฐ€

- Chore : ์ฝ”๋“œ ์ˆ˜์ •, ๋‚ด๋ถ€ ํŒŒ์ผ ์ˆ˜์ •
- Feat : ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ ๊ตฌํ˜„
- Add : Feat ์ด์™ธ์˜ ๋ถ€์ˆ˜์ ์ธ ์ฝ”๋“œ ์ถ”๊ฐ€, ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ถ”๊ฐ€, ์ƒˆ๋กœ์šด ํŒŒ์ผ ์ƒ์„ฑ ์‹œ
- Fix : ๋ฒ„๊ทธ, ์˜ค๋ฅ˜ ํ•ด๊ฒฐ
- Del : ์“ธ๋ชจ์—†๋Š” ์ฝ”๋“œ ์‚ญ์ œ
- Docs : README๋‚˜ WIKI ๋“ฑ์˜ ๋ฌธ์„œ ๊ฐœ์ •
- Move : ํ”„๋กœ์ ํŠธ ๋‚ด ํŒŒ์ผ์ด๋‚˜ ์ฝ”๋“œ์˜ ์ด๋™
- Rename : ํŒŒ์ผ ์ด๋ฆ„์˜ ๋ณ€๊ฒฝ
- Merge: ๋‹ค๋ฅธ๋ธŒ๋ Œ์น˜๋ฅผ mergeํ•˜๋Š” ๊ฒฝ์šฐ
- Style : ์ฝ”๋“œ๊ฐ€ ์•„๋‹Œ ์Šคํƒ€์ผ ๋ณ€๊ฒฝ์„ ํ•˜๋Š” ๊ฒฝ์šฐ
- Init : Initial commit์„ ํ•˜๋Š” ๊ฒฝ์šฐ

Code Convention

๐Ÿ’ก ๋™๋ฃŒ๋“ค๊ณผ ๋งํˆฌ๋ฅผ ํ†ต์ผํ•˜๊ธฐ ์œ„ํ•ด ์ปจ๋ฒค์…˜์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. ์˜คํ•ฉ์ง€์กธ์˜ ์ฝ”๋“œ๊ฐ€ ์•„๋‹Œ, ํ•œ ์‚ฌ๋žŒ์ด ์ง  ๊ฒƒ๊ฐ™์€ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์ด ์ถ”ํ›„ ์œ ์ง€๋ณด์ˆ˜๋‚˜ ํ˜‘์—…์—์„œ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค. ๋‚ด๊ฐ€ ์ฝ”๋“œ๋ฅผ ์ƒ๊ฐํ•˜๋ฉด์„œ ์งค ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ฃผ๋Š” ๋ฃฐ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ด๋„ ์ข‹์Šต๋‹ˆ๋‹ค!

๋ช…๋ช…๊ทœ์น™(Naming Conventions)
  1. ์ด๋ฆ„์œผ๋กœ๋ถ€ํ„ฐ ์˜๋„๊ฐ€ ์ฝํ˜€์งˆ ์ˆ˜ ์žˆ๊ฒŒ ์“ด๋‹ค.
  • ex)

    // bad
    function q() {
        // ...stuff...
    }
    
    // good
    function query() {
        // ..stuff..
    }
  1. ์˜ค๋ธŒ์ ํŠธ, ํ•จ์ˆ˜, ๊ทธ๋ฆฌ๊ณ  ์ธ์Šคํ„ด์Šค์—๋Š” camelCase๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
  • ex)
    // bad
    const OBJEcttsssss = {};
    const this_is_my_object = {};
    function c() {}
    
    // good
    const thisIsMyObject = {};
    function thisIsMyFunction() {}
  1. ํด๋ž˜์Šค๋‚˜ constructor์—๋Š” PascalCase๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
  • ex)
    // bad
    function user(options) {
        this.name = options.name;
    }
    
    const bad = new user({
        name: 'nope',
    });
    
    // good
    class User {
        constructor(options) {
            this.name = options.name;
        }
    }
    
    const good = new User({
        name: 'yup',
    });
  1. ํ•จ์ˆ˜ ์ด๋ฆ„์€ ๋™์‚ฌ + ๋ช…์‚ฌ ํ˜•ํƒœ๋กœ ์ž‘์„ฑํ•œ๋‹ค. ex) postUserInformation( )
  2. ์•ฝ์–ด ์‚ฌ์šฉ์€ ์ตœ๋Œ€ํ•œ ์ง€์–‘ํ•œ๋‹ค.
  3. ์ด๋ฆ„์— ๋„ค ๋‹จ์–ด ์ด์ƒ์ด ๋“ค์–ด๊ฐ€๋ฉด ํŒ€์›๊ณผ ์ƒ์˜๋ฅผ ๊ฑฐ์นœ ํ›„ ์‚ฌ์šฉํ•œ๋‹ค
๋ธ”๋ก(Blocks)
  1. ๋ณต์ˆ˜ํ–‰์˜ ๋ธ”๋ก์—๋Š” ์ค‘๊ด„ํ˜ธ({})๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
  • ex)
    // bad
    if (test)
      return false;
    
    // good
    if (test) return false;
    
    // good
    if (test) {
      return false;
    }
    
    // bad
    function() { return false; }
    
    // good
    function() {
      return false;
    }
  1. ๋ณต์ˆ˜ํ–‰ ๋ธ”๋ก์˜ if ์™€ else ๋ฅผ ์ด์šฉํ•˜๋Š” ๊ฒฝ์šฐ else ๋Š” if ๋ธ”๋ก ๋์˜ ์ค‘๊ด„ํ˜ธ( } )์™€ ๊ฐ™์€ ํ–‰์— ์œ„์น˜์‹œํ‚จ๋‹ค.
  • ex) ```java // bad if (test) { thing1(); thing2(); } else { thing3(); }

    // good
    if (test) {
      thing1();
      thing2();
    } else {
      thing3();
    }
    
    ```
    
์ฝ”๋ฉ˜ํŠธ(Comments)
  1. ๋ณต์ˆ˜ํ˜•์˜ ์ฝ”๋ฉ˜ํŠธ๋Š” /** ... */ ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
  • ex)
    // good
    /**
     * @param {String} tag
     * @return {Element} element
     */
    function make(tag) {
        // ...stuff...
    
        return element;
    }
  1. ๋‹จ์ผ ํ–‰์˜ ์ฝ”๋ฉ˜ํŠธ์—๋Š” // ์„ ์‚ฌ์šฉํ•˜๊ณ  ์ฝ”๋ฉ˜ํŠธ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์‹ถ์€ ์ฝ”๋“œ์˜ ์ƒ๋ถ€์— ๋ฐฐ์น˜ํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ฝ”๋ฉ˜ํŠธ์˜ ์•ž์— ๋นˆ ํ–‰์„ ๋„ฃ๋Š”๋‹ค.
  • ex) ```jsx // bad const active = true; // is current tab

    // good
    // is current tab
    const active = true;
    
    // good
    function getType() {
      console.log('fetching type...');
    
      // set the default type to 'no type'
      const type = this._type || 'no type';
    
      return type;
    }
    
    ```
    
๋ฌธ์ž์—ด(Strings)
  1. ๋ฌธ์ž์—ด์—๋Š” ์‹ฑํฌ์ฟผํŠธ '' ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
  • ex)
    // bad
    const name = 'Capt. Janeway';
    
    // good
    const name = 'Capt. Janeway';
  1. ํ”„๋กœ๊ทธ๋žจ์—์„œ ๋ฌธ์ž์—ด์„ ์ƒ์„ฑํ•˜๋Š” ๊ฒฝ์šฐ๋Š” ๋ฌธ์ž์—ด ์—ฐ๊ฒฐ์ด ์•„๋‹Œ template strings๋ฅผ ์ด์šฉํ•œ๋‹ค.
  • ex) ```jsx // bad function sayHi(name) { return 'How are you, ' + name + '?'; }

    // bad
    function sayHi(name) {
      return ['How are you, ', name, '?'].join();
    }
    
    // good
    function sayHi(name) {
      return `How are you, ${name}?`;
    }
    
    ```
    
ํ•จ์ˆ˜(Functions)
  1. ํ™”์‚ดํ‘œ ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.
  • ex)
    var arr1 = [1, 2, 3];
    var pow1 = arr.map(function (x) {
        // ES5 Not Good
        return x * x;
    });
    
    const arr2 = [1, 2, 3];
    const pow2 = arr.map((x) => x * x); // ES6 Good
์กฐ๊ฑด์‹๊ณผ ๋“ฑ๊ฐ€์‹(Comparison Operators & Equality)
  1. == ์ด๋‚˜ != ๋ณด๋‹ค === ์™€ !== ์„ ์‚ฌ์šฉํ•œ๋‹ค.
  2. ๋‹จ์ถ•ํ˜•์„ ์‚ฌ์šฉํ•œ๋‹ค.
  • ex)
    // bad
    if (name !== '') {
        // ...stuff...
    }
    
    // good
    if (name) {
        // ...stuff...
    }
  1. ๋น„๋™๊ธฐ ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ Promiseํ•จ์ˆ˜์˜ ์‚ฌ์šฉ์€ ์ง€์–‘ํ•˜๊ณ  async, await๋ฅผ ์“ฐ๋„๋ก ํ•œ๋‹ค


Branch

๐ŸŒฑ git branch ์ „๋žต

main branch : ๋ฐฐํฌ ๋‹จ์œ„ branch

develop branch : ์ฃผ์š” ๊ฐœ๋ฐœ branch, main merge ์ „ ๊ฑฐ์น˜๋Š” branch

feature branch: ๊ฐ์ž ๊ฐœ๋ฐœ branch

  • ํ•  ์ผ issue ๋“ฑ๋ก ํ›„ ๋ณธ์ธ์˜ ๋‹‰๋„ค์ž„ branch ์ƒ์„ฑ ํ›„ ์ž‘์—…
    • ex) feature/'๋‹‰๋„ค์ž„'
  • ํ•ด๋‹น branch ์ž‘์—… ์™„๋ฃŒ ํ›„ PR ๋ณด๋‚ด๊ธฐ
    • ํ•ญ์ƒ local์—์„œ ์ถฉ๋Œ ํ•ด๊ฒฐ ํ›„ โ†’ remote์— ์˜ฌ๋ฆฌ๊ธฐ
    • reviewer์— ์„œ๋กœ tagํ›„ code-review
    • comment ์ „ merge ๋ถˆ๊ฐ€!

branch ๊ตฌ์กฐ

- main
- develop
- feature
   โ”œโ”€โ”€ kkl
   โ””โ”€โ”€ jjs


Project Foldering

๐Ÿ—‚ prisma
    - schema.prisma
๐Ÿ—‚ src
    ๐Ÿ—‚ config
        - index.ts
    ๐Ÿ—‚ controller
        - index.ts
        - translatorController.ts
        - quizController.ts
    ๐Ÿ—‚ constants
        - index.ts
        - response.ts
        - responseMessage.ts
        - statusCode.ts
    ๐Ÿ—‚ route
        - index.ts
        - translatorRouter.ts
        - quizRouter.ts
    ๐Ÿ—‚ services
        - index.ts
        - translatorService.ts
        - quizService.ts
    - index.ts


package.json

{
    "name": "soptkathon",
    "version": "1.0.0",
    "main": "index.js",
    "license": "MIT",
    "scripts": {
        "dev": "nodemon",
        "build": "tsc && node dist",
        "db:pull": "npx prisma db pull",
        "db:push": "npx prisma db push",
        "generate": "npx prisma generate"
    },
    "devDependencies": {
        "@types/express": "^4.17.14",
        "@types/node": "^18.11.9",
        "nodemon": "^2.0.20",
        "prettier": "2.7.1"
    },
    "dependencies": {
        "@prisma/client": "^4.6.1",
        "express": "^4.18.2",
        "prisma": "^4.6.1"
    }
}


schema.prisma

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Example {
  id                           Int    @id @default(autoincrement())
  text                         String @db.VarChar(50)
  quiz_id                      Int
  Quiz_Example_quiz_idToQuiz   Quiz   @relation("Example_quiz_idToQuiz", fields: [quiz_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "example_quiz_id_fk")
  Quiz_ExampleToQuiz_answer_id Quiz[] @relation("ExampleToQuiz_answer_id")
}

model Quiz {
  id                              Int       @id @default(autoincrement())
  question                        String    @db.VarChar(100)
  answer_id                       Int?
  Example_ExampleToQuiz_answer_id Example?  @relation("ExampleToQuiz_answer_id", fields: [answer_id], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "quiz_example_id_fk")
  Example_Example_quiz_idToQuiz   Example[] @relation("Example_quiz_idToQuiz")
}

model Translator {
  input       String  @id @db.VarChar(50)
  result      String? @db.VarChar(100)
  description String  @db.VarChar(500)
  example     String? @db.VarChar(500)
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published