{
"name": "seminar4",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"dev": "nodemon",
"build": "tsc && node dist"
},
"devDependencies": {
"@types/express": "^4.17.14",
"@types/node": "^18.11.9",
"nodemon": "^2.0.20"
},
"dependencies": {
"@prisma/client": "^4.6.1",
"express": "^4.18.2",
"prisma": "^4.6.1"
}
}
{
"name": "seminar4",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"dev": "nodemon",
"build": "tsc && node dist"
},
"devDependencies": {
"@types/express": "^4.17.14",
"@types/node": "^18.11.9",
"nodemon": "^2.0.20"
},
"dependencies": {
"@prisma/client": "^4.6.1",
"express": "^4.18.2",
"prisma": "^4.6.1"
}
}
{
"compilerOptions": {
"target": "es6", // 어떤 버전으로 컴파일
"allowSyntheticDefaultImports": true, // default export가 없는 모듈에서 default imports를 허용
"experimentalDecorators": true, // decorator 실험적 허용
"emitDecoratorMetadata": true, // 데코레이터가 있는 선언에 대해 특정 타입의 메타 데이터를 내보내는 실험적인 지원
"skipLibCheck": true, // 정의 파일 타입 체크 여부
"moduleResolution": "node", // commonJS -> node 에서 동작
"module": "commonjs", // import 문법
"strict": true, // 타입 검사 엄격하게
"pretty": true, // error 메시지 예쁘게
"sourceMap": true, // 소스맵 파일 생성 -> .ts가 .js 파일로 트랜스 시 .js.map 생성
"outDir": "./dist", // 트랜스 파일 (.js) 저장 경로
"allowJs": true, // js 파일 ts에서 import 허용
"noImplicitAny": true, // any 쓰면 손절
"noFallthroughCasesInSwitch": true, // switch문에서 break되지 않고 통과되는 것 방지
"esModuleInterop": true, // ES6 모듈 사양을 준수하여 CommonJS 모듈을 가져올 수 있게 허용
"forceConsistentCasingInFileNames": true, // 파일 참조시 대소문자 구분 엄격
"noUnusedLocals": true, // 안쓰는 로컬 변수 체크
"noUnusedParameters": true, // 함수 파라미터 중 안쓰는 것 체크
"typeRoots": [
"./src/types/express.d.ts", // 타입(*.d.ts)파일을 가져올 디렉토리 설정
"./node_modules/@types" // 설정 안할시 기본적으로 ./node_modules/@types
]
},
"include": [
"./src/**/*" // build 시 포함
],
"exclude": [
"node_modules", // build 시 제외
"tests"
]
}
💡 동료들과 말투를 통일하기 위해 컨벤션을 지정합니다. 오합지졸의 코드가 아닌, 한 사람이 짠 것같은 코드를 작성하는 것이 추후 유지보수나 협업에서 도움이 됩니다. 내가 코드를 생각하면서 짤 수 있도록 해주는 룰이라고 생각해도 좋습니다!
명명규칙(Naming Conventions)
- 이름으로부터 의도가 읽혀질 수 있게 쓴다.
-
ex)
// bad function q() { // ...stuff... } // good function query() { // ..stuff.. }
- 오브젝트, 함수, 그리고 인스턴스에는
camelCase
를 사용한다.
-
ex)
// bad const OBJEcttsssss = {}; const this_is_my_object = {}; function c() {} // good const thisIsMyObject = {}; function thisIsMyFunction() {}
- 클래스나 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', });
- 함수 이름은 동사 + 명사 형태로 작성한다.
ex)
postUserInformation( )
- 약어 사용은 최대한 지양한다.
- 이름에 네 단어 이상이 들어가면 팀원과 상의를 거친 후 사용한다
블록(Blocks)
- 복수행의 블록에는 중괄호({})를 사용한다.
-
ex)
// bad if (test) return false; // good if (test) return false; // good if (test) { return false; } // bad function() { return false; } // good function() { return false; }
- 복수행 블록의
if
와else
를 이용하는 경우else
는if
블록 끝의 중괄호( } )와 같은 행에 위치시킨다.
-
ex)
// bad if (test) { thing1(); thing2(); } else { thing3(); } // good if (test) { thing1(); thing2(); } else { thing3(); }
코멘트(Comments)
- 복수형의 코멘트는
/** ... */
를 사용한다.
-
ex)
// good /** * @param {String} tag * @return {Element} element */ function make(tag) { // ...stuff... return element; }
- 단일 행의 코멘트에는
//
을 사용하고 코멘트를 추가하고 싶은 코드의 상부에 배치한다. 그리고 코멘트의 앞에 빈 행을 넣는다.
-
ex)
// 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)
- 문자열에는 싱크쿼트
''
를 사용한다.
-
ex)
// bad const name = "Capt. Janeway"; // good const name = 'Capt. Janeway';
- 프로그램에서 문자열을 생성하는 경우는 문자열 연결이 아닌
template strings
를 이용한다.
-
ex)
// 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)
- 화살표 함수를 사용한다.
-
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)
==
이나!=
보다===
와!==
을 사용한다.- 단축형을 사용한다.
-
ex)
// bad if (name !== '') { // ...stuff... } // good if (name) { // ...stuff... }
- 비동기 함수를 사용할 때
Promise
함수의 사용은 지양하고async
,await
를 쓰도록 한다
🌱 git branch 전략
main branch
: 배포 단위 branch
develop branch
: 주요 개발 branch, main merge 전 거치는 branch
feature branch
: 각자 개발 branch
- 할 일 issue 등록 후 issue 번호로 branch 생성 후 작업
- ex) feature/#
issue num
- ex) feature/#
- 해당 branch 작업 완료 후 PR 보내기
- 항상 local에서 충돌 해결 후 → remote에 올리기
- reviewer에 서로 tag후 code-review
- comment 전 merge 불가!
- main
- develop
- feature
├── #1
└── #2
👻 git commit message convention
ex) Feat/#
issue num User API 파일 추가
- Chore : 코드 수정, 내부 파일 수정
- Feat : 새로운 기능 구현
- Add : Feat 이외의 부수적인 코드 추가, 라이브러리 추가, 새로운 파일 생성 시
- Fix : 버그, 오류 해결
- Del : 쓸모없는 코드 삭제
- Docs : README나 WIKI 등의 문서 개정
- Move : 프로젝트 내 파일이나 코드의 이동
- Rename : 파일 이름의 변경
- Merge: 다른브렌치를 merge하는 경우
- Style : 코드가 아닌 스타일 변경을 하는 경우
- Init : Initial commit을 하는 경우