๐ย ๋ค์ด๋ฐ ๊ท์น
- lowerCamelCase ์ฌ์ฉ
- ํด๋์ค, ์ธํฐํ์ด์ค, db์คํค๋ง์ ๊ฒฝ์ฐ UpperCamelCase
- ํจ์๋ช
: ๋์ฌ+๋ช
์ฌ
- API์ ์ง๊ฒฐ๋๋ ํจ์๋ CRUD ๋ช
์นญ์ ์์ ๋ฌ๊ธฐ
- ex. Create โ create000
Read โ get000 (getUserById, getUsers)
Update โ update000
Delete โ delete000
- ๋ณ์๋ช
: ๋ช
์ฌ+๋ช
์ฌ or ํ์ฉ์ฌ+๋ช
์ฌ
- ๋ณ์ ์ต๋ ๊ธธ์ด 20์
- ๋ช
์ฌ๋ ๋จ์๋ก ์ฐ์ง ์๋ ๊ฐ์๋ฅผ ๋ํ๋ด๋ ๋จ์ด ๊ผญ ์ ์ด์ฃผ๊ธฐ
- ex. ๋ณต์ : getUsers() / ๋จ์ : getUser()
๐ย ํ๋ก์ ํธ ํด๋๋ง๋ช
- ํด๋๋ช
- ํ์ผ๋ช
- index.ts๋ ๊ทธ๋๋ก ์ฌ์ฉ
- middleware, modules, loaders, errors ๋ด ํ์ผ๋ช
์ lowerCamelCase๋ฅผ ์ฌ์ฉ
- ๊ทธ ์ธ์ ํ์ผ์ UpperCamelCase ์ฌ์ฉ
๐ย ๊ทธ ์ธ ์ฝ๋ ์์ฑ ์ ์ ์ ์ฌํญ
-
Exception
- ์๋น์ค ๋ก์ง์ ๊ด๋ จ๋ ์์ธ๋ ์๋น์ค ๋จ์์ ๋์ง๊ธฐ
- validation ๊ด๋ จ ์์ธ๋ ์ปจํธ๋กค๋ฌ ๋จ์์ ๋์ง๊ธฐ
-
Type Assertion
- type ์ง์ ํ์
- ์๋น์ค ๋จ์์ ์คํค๋ง์ ๊ด๋ จ๋ ๋ณ์ ๋ฐ ํจ์ ํ์
๋จ์ธ์ ๊ฒฝ์ฐ์ ๋ฐ๋ผ ๋จ์ธ์ ํ์ง ์์ ์ ์๋ค.
-
์ต๋ํ any ์ฐ์ง ๋ง๊ธฐ
-
controller์ ์ด๋ค API ์ธ์ง ์ฃผ์ ๋ช
์
/**
* @route Post /movie
* @desc Create Movie
* @access Public
*/
-
์ฃผ์ ์์ฑ ์ ๋์ด์ฐ๊ธฐ ๋ฃ๊ธฐ
// ์ด๋ ๊ฒ
/**
* ์ฌ๊ธฐ์ ์ด๋ ๊ฒ ํฉ์๋ค
*/
module.exports = {
env: {
es6: true,
node: true
},
extends: [
'airbnb-typescript/base',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
],
parser: ['@typescript-eslint/parser', 'prettier'],
ignorePatterns: ['dist/', 'node_modules/'],
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
project: './tsconfig.json'
},
plugins: ['@typescript-eslint'],
rules: {
'prettier/prettier': ['error'],
'no-param-reassign': [
'error',
{
props: false
}
]
}
};