äžæç | ENGLISH | íêµìŽ | РУССÐÐÐ | Português
éçºäžã®æ°ããªãããžã§ã¯ãã¯èåã®ããã§ãããã¡ã³ããã³ã¹ã¯èª°ã«ãšã£ãŠãæªå€¢ã«ãªããŸãã ããã«ã¯ç§ãã¡ãèŠã€ãèšèŒããéãèããã¬ã€ãã©ã€ã³ããããŸãã ãã®ã¬ã€ãã©ã€ã³ã¯ã»ãšãã©ã®elsewhenã®JavaScriptã®ãããžã§ã¯ãã§æ©èœããŠããŸãã ããããã¹ããã©ã¯ãã£ã¹ãæã ãšå ±æãããã£ããããã®ã¬ã€ãã©ã€ã³ã®é ç®ã¯åé€ããæ¹ãè¯ããšæã£ããæ°è»œã«ç§ãã¡ã«å ±åããŠãã ããã
- Git
- ããã¥ã¡ã³ã
- éçºç°å¢
- äŸåé¢ä¿
- ãã¹ã
- ãããžã§ã¯ãã®æ§é ãšååä»ã
- ã³ãŒãã¹ã¿ã€ã«
- ãã°
- API
- ã©ã€ã»ã³ã¹
ããã€ãã®Gitã®ã«ãŒã«ãèŠããŠãããŸãããã
-
featureãã©ã³ãã§äœæ¥ããŸãããã
Why:
å šäœæ¥ãã¡ã€ã³ãã©ã³ãã§ã¯ãªããŠç¬ç«ããäœæ¥å°çšã®ãã©ã³ãã§å®çµããããã§ããããããããšã«ãã£ãŠæ··ä¹±ããããããšãªãè€æ°ã®ãã«ãªã¯ãšã¹ããäœæããããšãã§ããŸããäœæ¥éäžã®ã³ãŒããäžå®å®ãªã³ãŒããmasterãã©ã³ããæ°ã«ããããšãªãç¹°ãè¿ãäœããŸãããã£ãšèªã...
-
develop
ãã©ã³ããããã©ã³ããåããŸãããWhy:
ããããããšã§masterã®ã³ãŒããåé¡ãªããã«ãã§ããããšãã§ããmasterã¯ãªãªãŒã¹çšã«ã»ãšãã©ãã®ãŸãŸå©çšã§ããŸãã(ãããžã§ã¯ãã«ãã£ãŠã¯ãããããããããŸããã)
-
develop
ãšmaster
ãã©ã³ãã«çŽæ¥Pushããã®ã¯ãããŸãããããã«ãªã¯ãšã¹ããäœæããŸããããWhy:
develop
ãšmaster
ãã©ã³ããæŽæ°ããããšããããšã¯ããŒã ã¡ã³ããŒã«ãã®æ©èœãå®è£ ãçµãã£ããšäŒããããšãšå矩ã§ããçŽæ¥Pushããããªããã°ãã³ãŒãã¬ãã¥ãŒãæ°ããªæ©èœã®è°è«ããããããªããŸãã -
featureãã©ã³ããPushããŠãã«ãªã¯ãšã¹ããäœæããåã«ããŒã«ã«ã®
develop
ãã©ã³ããææ°ã«ããŠãfeatureãã©ã³ããã€ã³ã¿ã©ã¯ãã£ããªããŒã¹ããŸããããWhy:
ãªããŒã¹ã¯ãã©ã³ãïŒ
master
ãdevelop
ãïŒãããŒãžããŸãããŸãlocalã«äœã£ãã³ããããããŒãžã³ããããäœæããã«Gitã®ãã¹ããªãŒã®ãããã«äžŠã¹æ¿ããŸããã³ã³ããªã¯ãããªããã°ãããããããšã§ç¶ºéºã§çŽ æŽããããã¹ããªãŒãæ®ããŸãããã£ãšèªã... -
ãªããŒã¹ããéããã«ãªã¯ãšã¹ããäœãåã«ã³ã³ããªã¯ãã解æ¶ããŸãããã
-
ããŒãžããåŸã®ãã©ã³ãã¯localãremoteå ±ã«åé€ããŸãããã
Why:
äžèŠã«ãªã£ããã©ã³ãããå«ãŸããããšã§èªèº«localã®ãã©ã³ãã®ãªã¹ããä¹±éã«ãªãã§ãããããŸãããŒãžããæã«ã®ã¿äžåã ããã©ã³ãïŒ
master
ãdevelop
ïŒã«æ»ãããšãä¿èšŒããŸããfeature ãã©ã³ãã¯äœæ¥äžã ãååšãã¹ãã§ãã -
ãã«ãªã¯ãšã¹ããåã«ãfeatureãã©ã³ãã®ãã«ãã®æåã確èªããŠå šãŠã®ãã¹ããéããŸãããã(ã³ãŒãã®ã¹ã¿ã€ã«ãå«ããŠç¢ºèªããŸãããã)
Why:
å®å®çãªã³ãŒããè¿œå ããããšããæãããfeatureãã©ã³ãã®ãã¹ãã倱æãããšãããšãæçµçãªããŒãžåŸã®ãã¹ãã倱æããå¯èœæ§ãé«ãã§ããå ããŠãã«ãªã¯ãšã¹ããäœæããåã«ãã¹ã¿ã€ã«ãã§ãã¯ãè¡ãå¿ èŠããããŸããã¹ã¿ã€ã«ãã§ãã¯ãè¡ãããšã§å¯èªæ§ãäžãããå®éã®ã³ãŒããšäžç·ã«ãã©ãŒãããã«ããä¿®æ£ãæžããããšã«ç¹ãããŸãã
-
ãã¡ãã®
.gitignore
ãã¡ã€ã«ã䜿ããŸããããWhy:
ãã®.gitignoreãã¡ã€ã«ã«ã¯remoteã®ãªããžããªã«å«ããããªãã·ã¹ãã ãã¡ã€ã«ã®ãªã¹ããåæããŠããŸãããŸããŠãŒã¶ãŒãå€ãã®äººã䜿ããšãã£ã¿çšã®ãã©ã«ãããã¡ã€ã«(äŸåãã©ã«ããåãããã«)ãå«ããŠãŸãã
-
develop
ãšmaster
ãã©ã³ããä¿è·ããŸããããWhy:
ãããã¯ã·ã§ã³ã«åããŠãããã©ã³ãã«äºæããªãç Žå£çãªã³ããããPushãããããšãé²ããŸãã
äžèšã®çç±ã®ããã«ãç§éã¯Feature-branch-workflowãšInteractive RebasingãGitflow ã®èŠçŽ ã®ããã€ã(ååä»ãšdevelopãã©ã³ããæã€ããš)ã䜿ããŸããäž»ãªã¹ãããã¯ä»¥äžã®éãã§ãã
-
æ°ãããããžã§ã¯ãã«ãšã£ãŠã¯åæã®gitã®èšå®ãfeatures/changesãã©ã³ãã®äœæ㯠ã®æ¬¡ã®ã¹ããããªã®ã§ç¡èŠããŸãããã
cd <project directory> git init
-
feature/bug-fix ãã©ã³ããäœæããã
git checkout -b <branchname>
-
ã³ãŒããå€æŽããã
git add git commit -a
Why:
git commit -a
ã䜿ããšæ¬æããäž»é¡ãåãé¢ããŠå§ããããšãã§ããŸãã詳ããã¯section 1.3ãèªã¿ãŸãããã -
åã蟌ãŸããŠããªãå€æŽãååŸããçºã«ãªã¢ãŒãã®ãªããžããªãšåæããŸãããã
git checkout develop git pull
Why:
ããããããšã§ã³ã³ããªã¯ããå«ããªãããã«ãªã¯ãšã¹ããäœæããã®ã§ã¯ãªããŠãªããŒã¹(ã®ã¡ã«)ãã€ã€ãã³ã³ããªã¯ãã«å¯ŸåŠã§ããå¯èœæ§ãé«ãŸããŸãã
-
featureãã©ã³ãã«ã€ã³ã¿ã©ã¯ãã£ããªããŒã¹ãããããšã§åžžã«developã®å€æŽãåã蟌ã¿ãŸãããã
git checkout <branchname> git rebase -i --autosquash develop
Why:
--autosquashã¯å šãŠã®ã³ããããäžã€ã«ãŸãšããããšãã§ããŸããäžã€ã®featureã«å¯ŸããŠè€æ°ã®ã³ããããããç¶æ ã¯æãŸãããããŸããããã£ãšèªã...
-
ããã³ã³ããªã¯ãããŠãªãã£ãããã®ç« ã¯é£ã°ããŠå€§äžå€«ã§ãããã ãããã³ã³ããªã¯ããèµ·ããŠãã解決ããŸãããããããŠãªããŒã¹ãç¶ããŸãããã
git add <file1> <file2> ... git rebase --continue
-
èªåã®ãã©ã³ããPushããŸãããããªããŒã¹ã¯ãã¹ããªãŒãæ¹å€ããŸãã®ã§ããªã¢ãŒãã«Pushããéã¯
-f
ã®ãªãã·ã§ã³ãã€ããŠPushããå¿ èŠããããŸããããä»ã®äººãåããã©ã³ãã§äœæ¥ãããŠãããããç Žå£çã§ãªã--force-with-lease
ã䜿ããŸããããgit push -f
Why:
ãªããŒã¹ããããšãäœæ¥ãã©ã³ãã®ã³ããããã¹ããªãŒãå€ããããšã«ãªããŸããçµæãšããŠGitã«æ®éã®
git push
ã¯æåŠãããã®ã§ä»£ããã« -f ã--force ãã©ã°ã䜿ãã°å€§äžå€«ã§ãããã£ãšèªã... -
ãã«ãªã¯ãšã¹ããäœããŸãããã
-
ãã«ãªã¯ãšã¹ããåãå ¥ããããããã¬ãã¥ã¯ãŒã«ãã£ãŠããŒãžãããŠèª²é¡ãéããããŸãã
-
ããŒãžãå®äºãããããŒã«ã«ã®ãã©ã³ããæ¶ããŸãããã
git branch -d <branchname>
å¿ èŠã®ãªããªã¢ãŒããã©ã³ããå šãŠåé€ããã³ãã³ãã
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
ã³ããããäœæããŠç¶æããããã®è¯ãæéãæã€ãšãGitãããŸã䜿ãããšãã§ãä»ã®éçºè ãšã®å ±åäœæ¥ããšãŠãç°¡åã«ããŸããããã«ããã€ãã®çµéšåããããŸãã(ãœãŒã¹)
-
æ¬æãæ¹è¡ããããšã§äž»é¡ãšåãé¢ããŸãããã
Why:
Gitã¯æåã®è¡ããã®ã³ãããã®ãµããªãšããŠåºå¥ããŸããå®é
git log
ã®ä»£ããã«git shortlog
ã䜿ããšãã³ãããIDãšãµããªãŒã®ã¿ã§æ§æãããé·ãã³ãããã¡ãã»ãŒãžã®ãªã¹ããèŠãããšãã§ããŸãã -
äž»é¡ã¯50æå以å ãæ¬æãå«ããŠã72æå以å ã«å¶éããŸãããã
why
ã³ãããã¯ã§ããéããã现ããã§å®çµããã¹ãã§ãã³ãããã¡ãã»ãŒãžãåé·ã«ããããšã¯é¿ããŸãããã詳ããèªã
-
äž»é¡ã®å é ã¯å€§æåã«ããŸãããã
-
ããªãªãã§çµããã®ããããŸãããã
-
äž»é¡éšåã§ã¯åœä»€æ³ ã䜿ããŸãããã
Why:
ã³ããã¿ãäœãè¡ã£ããããããããã¡ãã»ãŒãžãæžããŸããããã³ããããããŒãžãããåŸã«ãã®ã³ããããäœãããã®ããããŸã説æã§ããããã«èãããšããã§ãããããã£ãšèªã...
-
æ¬æ㯠How ã§ã¯ãªã㊠What ãš Whyã説æããŸãããã
- ãã¡ãã®ãã³ãã¬ãŒãã䜿ã£ãŠ
README.md
ãäœæããŸãããã空çœã®ã»ã¯ã·ã§ã³ããã£ãŠãæ°ã«ããªããŠã倧äžå€«ã§ãã - äžã€ä»¥äžã®Gitãªããžããªããããããªãããžã§ã¯ãã§ã¯ãåã
ã®
README.md
ãã¡ã€ã«ããªã³ã¯ãããŠãããŸãããã - ãããžã§ã¯ãã®æé·ã«åãããŠ
README.md
ã®æ å ±ãææ°ã«ä¿ã¡ãŸãããã - ã³ãŒãã«ã¯ã³ã¡ã³ããæžããŸãããããã®éã«ã¯èªåã®æå³ãã§ããéãç°¡æœã«æžãããã«å¿ãããŸãããã
- ããã³ãŒããè©Šã¿ãŠããã¢ãããŒãã«ã€ããŠgithubãstackoverllowã§ãªãŒãã³ãªè°è«ãããã°ããã®ãªã³ã¯ãã³ã¡ã³ãã«å«ããŸãããã
- ãã¡ãªã³ãŒãã«å¯Ÿããèšãèš³ãæžãã®ã¯ãããŸããããã³ãŒãã綺éºã«ä¿ã¡ãŸãããã
- 綺éºãªã³ãŒããå šãã³ã¡ã³ãããªãããšã«å¯Ÿããèšãèš³ã«ããã®ã¯ãããŸãããã
- ã³ãŒãã®æé·ã«åãããŠã³ã¡ã³ããææ°ã«ä¿ã¡ãŸãããã
-
å¿ èŠãªã
development
,test
ãšproduction
ã®ç°å¢ãåããŠå®çŸ©ããŸããããWhy:
ããŒã¿ãããŒã¯ã³ãAPIãããŒããªã©ç°å¢ã«ãã£ãŠå¿ èŠãšããããã®ã¯æ§ã ã§ãããããã¹ãã®èªååãšæåã®ãã¹ããç°¡åã«ãããããã«ã
development
ã¢ãŒãã¯äºæž¬å¯èœãªããŒã¿ãè¿ããã§ã€ã¯ã®APIã欲ãããããããŸããããããã¯Google Analyticsã¯production
ã§ã ãæå¹ã«ãããã£ããæ§ã ã§ãããããã£ãšèªã... -
ç°å¢å¥ã®Configãã¡ã€ã«ãç°å¢æ¯ã«é©çšããããã«ããŠãã³ãŒãããŒã¹ã«å®æ°ãšããŠæ±ºããŠæžã蟌ãŸãªãã§ãã ããããµã³ãã«
Why:
ããŒã¯ã³ããã¹ã¯ãŒããªã©æ§ã ãªéèŠãªå人æ å ±ãæã£ãŠããŸãã ãã®æ å ±ã¯ã³ãŒãããŒã¹ããã€å ¬éãããŠãããããã«ãã³ãŒãããŒã¹ãšã¯åãé¢ããªããšãããŸããã
How:
.env
ãã¡ã€ã«ãæ å ±ãä¿æããããã«äœ¿ããŸãããããã®ãã¡ã€ã«ã¯.gitignore
ã«å ããŠãGitãªããžããªããã¯é€å€ãããããã«ããŸãããã®ä»£ããã«.env.example
ã®ãããªãµã³ãã«ãä»ã®éçºè åãã®ã¬ã€ããšããŠã³ãããããŠãããŸããããproductionç°å¢çšã«ãç°å¢èšå®ã¯æšæºçãªããæ¹ã§èšå®ããããã«ããŸãããã ãã£ãšèªã... -
ã¢ããªã±ãŒã·ã§ã³ãéå§ããåã«ç°å¢å€æ°ãvalidateããããšããªã¹ã¹ã¡ããŸãããµã³ãã«ãåç § å€æ°ãValidateããããã«
joi
ã䜿ã£ãŠããŸããWhy:
ãã©ãã«ã·ã¥ãŒãã£ã³ã°ã«è²»ããæéãç¯çŽããããšã«ç¹ãããŸãã
-
nodeã®ããŒãžã§ã³ã
package.json
ã®äžã®engines
ã«èšå®ããŸããããWhy:
ã©ã®ããŒãžã§ã³ã®nodeããã®ãããžã§ã¯ãã§äœ¿ãã¹ããã瀺ãããšãã§ããŸãããã£ãšèªã...
-
ããã«
nvm
ã䜿ã£ãŠ.nvmrc
ããããžã§ã¯ãã«ãŒãã«äœæããŸããããããã¥ã¡ã³ãå ã«èšè¿°ãæ®ãããšãå¿ããªãããã«ããŸããããWhy:
nvm
ã䜿ã人ã¯èª°ã§ã誰ã§ãnvm use
ã䜿ãããšã§nodeã®ããŒãžã§ã³ãåãæ¿ããããšãã§ããŸãããã£ãšèªã... -
preinstall
ã¹ã¯ãªããã䜿ã£ãŠnodeãšnpmã®ããŒãžã§ã³ã確ãããã®ãããã§ããããWhy:
npmã®æ°ããªããŒãžã§ã³ã§ã€ã³ã¹ããŒã«ãããšäŸåé¢ä¿ã®ã©ã€ãã©ãªã倱æããããšããããŸãã
-
ã§ãããªãã°Dockerã€ã¡ãŒãžã䜿ããŸãããã
Why:
Dockerã€ã¡ãŒãžã¯å šãŠã®ã¯ãŒã¯ãããŒãè·šãã§åãç°å¢ãæäŸããŠãããŸããäŸåé¢ä¿ãã³ã³ãã£ã°ãã¡ã€ã«ã«æ©ãå¿ èŠãããŸããªãããã«ãªããŸãããã£ãšèªã...
-
ã°ããŒãã«ã®ã¢ãžã¥ãŒã«ã䜿ãã®ã§ã¯ãªãããŒã«ã«ã®ã¢ãžã¥ãŒã«ã䜿ããŸãããã
Why:
ååãç¹å®ã®ã¢ãžã¥ãŒã«ã圌ãã®ãã·ã³ã«ãã§ã«ã€ã³ã¹ããŒã«ããŠããããšãæåŸ ããã®ã§ã¯ãªãã䜿ãã©ã€ãã©ãªã¯å ±æã§ããããã«ããŠãããŸãããã
-
ããŒã ã¡ã³ããŒãåãäŸåé¢ä¿ãååŸã§ããããšã確èªããŸãããã
Why:   > ã³ãŒãã«ã¯ã©ããªéçºãã·ã³ã§ãåãæåãããŠã»ããããã§ãããã£ãšèªã...
how:
npm@5
以äžã§package-lock.json
ã䜿ããŸããããnpm@5ã¯äœ¿ã£ãŠãªã:
Yarn
ã䜿ãREADME.md
ã確ãããããšã§ä»£æ¿æ段ãšããããšãã§ããŸããåã©ã€ãã©ãªãã¢ããããŒãããåŸã«ããã¯ãã¡ã€ã«ãšpackage.json
ã¯åãããŒãžã§ã³ãä¿æããŠããã§ããããYarn
ãšããååãæ°ã«ãããªã:ããã¯æ®å¿µã§ãã å€ãããŒãžã§ã³ã®
npm
çšã«ããããªãã·ã¥ããåã«æ°ããã©ã€ãã©ãªãã€ã³ã¹ããŒã«ãããnpm-shrinkwrap.json
ãäœããšãã«ã¯ãâsave --save-exact
ã䜿ããŸãããããã£ãšèªã...
-
䜿çšå¯èœãªææ°ã®ããã±ãŒãžãä¿ã¡ãŸãããã e.g.,
npm ls --depth=0
. ãã£ãšèªã... -
ç¡é¢ä¿ã§ãã£ãã䜿ã£ãŠããªãããã±ãŒãžã確èªããŸããã:
depcheck
. ãã£ãšèªã...Why:
ãããããã䜿ã£ãŠããªãã©ã€ãã©ãªãproductionã®ãµã€ãºãå¢å ãããŠãããããããŸããã䜿ã£ãŠããªãäŸåé¢ä¿ãèŠã€ããŠãããæ¶ãããã«ããŸãããã
-
ã©ã€ãã©ãªãã€ã³ã¹ããŒã«ããåã«ããã®ã©ã€ãã©ãªãã³ãã¥ããã£ã§ãã䜿ãããŠãããã©ããã確èªããŸãããã
npm-stat
ããã£ãšèªã...Why:
å€ã䜿ãããŠãããšããããšã¯å€ãã®ã³ã³ããªãã¥ãŒã¿ãŒããããšããããšã§ãããã¯è¯ãã¡ã³ããã³ã¹ãè¡ãããŠãããšããããšã«ãªããŸãããã®ããšã¯ãã°ãéçºè ã«ãã£ãŠãã¡æ©ãçºèŠãããä¿®æ£ãããããšã«ç¹ãããŸã
-
ã©ã€ãã©ãªãã€ã³ã¹ããŒã«ããåã«ããããããæ©èœãæã£ãŠããããå€ãã®ã¡ã³ãããŒãããŠæçããããŒãžã§ã³ãé »ç¹ã«ãªãªãŒã¹ããŠããã©ã€ãã©ãªãã確èªããŸãããã: e.g.,
npm view async
. ãã£ãšèªã...Why:
ããã¡ã³ãããŒãä¿®æ£ãããŒãžããªãã£ããããããçŽ æ©ãåœãŠãªããšãã³ã³ããªãã¥ãŒã¿ãå¹ççãªéçºãè¡ããªããªãã§ãããã
-
ããã»ã©ç¥ãããŠãªãã©ã€ãã©ãªãå¿ èŠãªå Žåã«ã¯ã䜿çšããåã«ããŒã ã¡ã³ããŒãšè°è«ããŸãããã
-
ã©ã€ãã©ãªã¯ãã«ããç Žå£ããªãéãã¯åžžã«ææ°ã§åããã確ãããŸããã:
npm outdated
ãã£ãšèªã...Why:
äŸåããã±ãŒãžã®æŽæ°ã¯ããŸã«ç Žå£çå€æŽãå«ãŸããŠããããšããããŸããã¢ããããŒããåºããšãã«ã¯åžžã«ãªãªãŒã¹ããŒãã確èªããŸããããäœããã£ããšãã«ãã©ãã«ã·ã¥ãŒãã£ã³ã°ãç°¡åã«ããããã«ãäŸåã©ã€ãã©ãªãäžã€äžã€æŽæ°ããŸããããnpm-check-updatesã®ããã«çŽ æŽãããããŒã«ã䜿ããŸãããã
-
äŸåããã±ãŒãžã«å ¬éãããŠããè匱æ§ãå«ãŸããŠããå Žåãããã®ã§ãã§ãã¯ããŸãããã e.g.,Snyk
-
å¿ èŠã§ããã°
test
ã®ç°å¢ãçšæããŸããããWhy:
éåžžã¯end to endã®ãã¹ãã
production
ã«è¡ãã ãã§ååãªã§ãããäŸå€ãããã€ããããŸããçµ±èšããŒã¿ãproduction
ç°å¢ã§æå¹ã«ããããªãããã¹ãããŒã¿ã§ããã·ã¥ããŒããæ±ããããªãå Žåã§ããããšã¯production
ã®APIã«å¶éããã£ãŠããã¹ããããéã®ãªã¯ãšã¹ãæ°ãå¶éã«éããŠãããã¯ãããŠããŸãå Žåã§ãã -
åäœãã¹ãã³ãŒãã¯ãã¹ãããããã¡ã€ã«ã®é£ã«ãããŸãããã
moduleName.spec.js
ã®ããã«*.test.js
ã*.spec.js
ã®ãããªãã¡ã€ã«åãæ £äŸãšãªã£ãŠããŸããWhy:
ãŠããããã¹ããæ¢ãããã«ãã©ã«ãæ§é ãæãé²ããããªãã§ãããããã£ãšèªã...
-
è¿œå ã®ãã¹ããã¡ã€ã«ãã©ãã«ãããæ··ä¹±ãé¿ããããã«éé¢ããããã©ã«ãã«å ¥ããŸããã
Why:
ããã€ãã®ãã¹ãã³ãŒãã¯å®è£ ã³ãŒããšé¢é£ããŠãªãããšããããŸããä»ã®éçºè ãèŠã€ãããããã©ã«ã(
__test__
ãã©ã«ãã®ãããª)ã«ãã¹ãã³ãŒãããããŸãããã__test__
ãã©ã«ãã¯ã¹ã¿ã³ããŒãã§ãããæ§ã ãªJavaScriptãã¬ãŒã ã¯ãŒã¯ã®ãã¹ãã§äœ¿çšãããŠããŸããã -
ãã¹ãã®æžããããã³ãŒããæžããŸããããå¯äœçšãé¿ããŸããããå¯äœçšãæœåºããŸããããçŽç²ãªé¢æ°ãæžããŸãããã
Why:
çµåãåããŠããžãã¯ã®ãã¹ãããããå Žåãã©ã³ãã ã§é決å®æ§ã®ããã»ã¹ãã³ãŒãã®ä¿¡é Œæ§ã«äžãã圱é¿ãæå°ã«ããå¿ èŠããããŸãããã£ãšèªã...
çŽç²é¢æ°ã¯åãå ¥åã«å¯ŸããŠåžžã«åãçµæãåºåããŸããéã«èšãã°çŽç²ã§ãªãé¢æ°ã¯å¯äœçšããã£ãŠãããçµæãåºåããéã«å€éšã®ç¶æ³ã«å·Šå³ãããŸãããã®ãããªé¢æ°ã¯äºæ³éãã®çµæãè¿ã£ãŠãã«ãããªããŸãããã£ãšèªã...
-
éç解æããŒã«ã䜿ããŸãããã
Why:
éç解æããŒã«ãå¿ èŠãªå Žé¢ããããããããŸãããã³ãŒããä¿¡é Œã§ããåºæºããããããŠãããŸããâš
-
develop
ãã©ã³ãã«ãããªã¯ãšã¹ããæããåã«ããŒã«ã«ã§ãã¹ããå®è¡ããŸããããWhy:
誰ãããããã¯ã·ã§ã³æºåäžã®ãã«ãã倱æãããç¯äººã«ãªãããããã§ãããã
rebase
ããåŸããªã¢ãŒãã®featureãã©ã³ãã«ãªããžããªã«Pushããåã«ãã¹ããå®è¡ããããã«ããŸãããã -
ãã¹ãã®å®è¡æ¹æ³ãªã©ã®æ å ±ãå«ããŠãããã¥ã¡ã³ããšããŠ
README.md
ãã¡ã€ã«ã«èšè¿°ããŸããããWhy:
ããã¥ã¡ã³ããæ®ãããšã§ä»ã®éçºè ãDevOpsã®æ åœè ãããã¯QAã«ãããžã§ã¯ããåŒãç¶ãã æã«ã圌ããããªãã®ã³ãŒãã§ä»äºããããããªããŸãã
-
ãã¡ã€ã«ã圹å²ã§ã¯ãªãååãããŒãžãã³ã³ããŒãã³ãã®ããã«éçŽããŸãããããã¹ããã¡ã€ã«ãå®è£ ã®é£ã«é 眮ããŸããããâš
Bad
. âââ controllers | âââ product.js | âââ user.js âââ models | âââ product.js | âââ user.js
Good
. âââ product | âââ index.js | âââ product.js | âââ product.test.js âââ user | âââ index.js | âââ user.js | âââ user.test.js
Why:
é·ããã¡ã€ã«ã®ãªã¹ãã®ä»£ããã«ããã¹ãã³ãŒããå«ããã«ãã»ã«åãããåäžè²¬ä»»ã®å°ããã¢ãžã¥ãŒã«ãåºæ¥äžãããŸããããããããšã§ã³ãŒãã®ã¬ã€ãããããããªããäžç®ã§èŠã€ããããšãã§ããããã«ãªããŸããâš
-
è¿œå ã®ãã¹ããã¡ã€ã«ã¯æ··ä¹±ãé¿ããããã«testãã©ã«ãã«çœ®ããŸããããâš
Why:
ä»ã®éçºè ãããŒã ã®DevOpsã®æ åœè ã®æéãç¯çŽããããšã«ã€ãªãããŸããâš
-
./config
ãã©ã«ããäœæããŸããããéãç°å¢ã®ããã®éãconfigãã¡ã€ã«ãäœããªãããã«ããŸããããWhy:
ç°ãªãç®ç(äŸãã°ããŒã¿ããŒã¹ãAPIçã )ã®ããã«è€æ°ã®configãã¡ã€ã«ã«åå²ããæã¯ãåããã©ã«ãã«
config
ã®ãããªããããããååã§ãŸãšããŠãããŸãããããã ããç°ãªãç°å¢ããšã«ç°ãªãconfigãã¡ã€ã«ãäœæããªãããã«æ°ãã€ããŠãã ãããæ°ããªãããã€å ãå¢ããæã«æ°ããªç°å¢ã®ååãå¿ èŠãšãªãã綺éºã«ã¹ã±ãŒã«ããããšãã§ããªãããã§ãã configãã¡ã€ã«å ã®å€æ°ã¯ç°å¢å€æ°ããäžããã®ãè¯ãæ¹æ³ã§ãããã£ãšèªã... -
ã¹ã¯ãªããã¯
./scripts
ãã©ã«ãã«çœ®ããŸããããããã«ã¯nodeãbashã®ã¹ã¯ãªãããå«ãŸããŸããWhy:
ãããã¯ã·ã§ã³ããããããã®ãã«ããããŒã¿ããŒã¹ã®æ§ç¯ãšåæçã ãè¡ãéã«å°ãªããšãäžã€ä»¥äžã®ã¹ã¯ãªããããããžã§ã¯ãã§å¿ èŠãšãããå¯èœæ§ãé«ãã§ãããã
-
ãã«ãã®ææç©ã¯
./build
ã«åºåããããã«ããŸããããbuild/
ã.gitignore
ã«å ããŸããããWhy:   > ååã¯ãªãã§ããããŠãdistãšããååã§ããã£ãããã§ãããªãã§ããããšã¯ãããããŒã ã®ã¡ã³ããŒãççŸãªãç解ã§ããååã§ãªããã°ãªããŸãããäŸãã°äœããã®ãã©ã«ãã§ååŸã§ããã®ããäœæããããã®ãªã®ããã³ãã«ããããã®ãªã®ããã³ã³ãã€ã«ããããã®ãªã®ãããããã¯ãã 移åãããŠãããã®ãªã®ãããªã«ãåºåããã®ããããŒã ã¡ãŒããããã«ãªã«ãåºåã§ããã®ããããã§ããã ãããã®ãã©ã«ãã¯ç¹æ®ãªäºæ ããªãéãã§ãããªã¢ãŒããªããžããªã«ã³ãããããå¿ èŠããããŸããã
-
PascalCase
ãšcamelCase
ããã¡ã€ã«ãšãã£ã¬ã¯ããªã®ååã«äœ¿çšããŸããããPascalCase
ã¯ã³ã³ããŒãã³ãã®ã¿ã«äœ¿çšããŸãããã -
CheckBox/index.js
ã¯CheckBox
ã®ã³ã³ããŒãã³ããæã£ãŠããã¹ãã§ããCheckBox.js
ãããã§ãããããããCheckBox/CheckBox.js
ãcheckbox/CheckBox.js
ã®ãããªååã¯åé·ãªã®ã§é¿ããã¹ãã§ãã -
çæ³çã«ã¯ãã©ã«ãã®ååã¯
index.js
ã®ããã©ã«ãexportã®ååãšäžèŽãããã¹ãã§ããWhy:
ããããããšã§èŠªãã©ã«ããã·ã³ãã«ã«importããã ãã§ã¢ãžã¥ãŒã«ãã³ã³ããŒãã³ããæ³åã§ããŸããâš
-
æ°ãããããžã§ã¯ãã§ã¯stage-2ãããããããŒãžã§ã³ã®æ°ããã¢ãã³ãªJavaScriptã䜿çšããããã«ããŸããããå€ããããžã§ã¯ãã«ã€ããŠã¯ãã¢ãã³ãªJavaScriptãåããããžã§ã¯ãã«ããããå Žåã¯å¥ãšããŠæ¢åã®ããŒãžã§ã³ãšäºææ§ã®ããããŒãžã§ã³ã«ãšã©ããŠãããŸãããã
Why:
ããŒã 次第ã§ã¯ãããŸãããç§ãã¡ã¯ãã©ã³ã¹ãã€ã©ã䜿çšããããšã§ãæ°ããã·ã³ã¿ãã¯ã¹ã®å©ç¹ã掻çšããŠããŸããstage-2ã¯æ®ãããããªæ¹èšã§ä»æ§ã®äžéšã«ãªãå¯èœæ§ãåŸã ã«é«ããªã£ãŠããŸããâš
-
ã³ãŒãã¹ã¿ã€ã«ãã§ãã¯ããã«ãããã»ã¹ã«å«ããŸãããã
Why:
ãã«ããå£ãããšã¯ã³ãŒãã¹ã¿ã€ã«ãç¯æ£ããäžã€ã®æ¹æ³ã«ãªããŸããããªããã ãã ãã³ãŒãã¹ã¿ã€ã«ãçå£ã«æããªããªããšããããšãé²ãã§ãããŸããã¯ã©ã€ã¢ã³ããšãµãŒããŒãµã€ãã®ã³ãŒãäž¡æ¹ã«å°å ¥ããŸãããããã£ãšèªã...
-
ã³ãŒãã¹ã¿ã€ã«ã匷å¶ããããã«ESLint - Pluggable JavaScript linterã䜿ããŸãããã
Why:
ç§ãã¡ã¯ã·ã³ãã«ãª
eslint
ã奜ããªã ããªã®ã§ãããªããããã§ããå¿ èŠã¯ãªãã§ããeslint
èªäœããããã®ã«ãŒã«ããµããŒãããŠããŸããã«ãŒã«ãèšå®ã§ããã«ã¹ã¿ã ã«ãŒã«ãè¿œå ããããšãã§ããŸãã -
ç§ãã¡ã¯Airbnb JavaScript Style GuideãJavaScriptã«äœ¿ã£ãŠããŸãããã£ãšèªã...ãããªãã®ããŒã ã«æ±ããããJavaScriptã®ã¹ã¿ã€ã«ã¬ã€ãã䜿çšããŸãããã
-
ç§ãã¡ã¯FlowTypeã䜿çšããæã«ã¯Flow type style check rules for ESLintã䜿ã£ãŠããŸãã
Why:
Flowã«ã¯ãç¹å®ã®ã³ãŒãã¹ã¿ã€ã«ã«åŸã£ãŠãã§ãã¯ããå¿ èŠãããæ§æãã»ãšãã©ãããŸããâš
-
ç¹å®ã®ãã©ã«ãããã¡ã€ã«ãã³ãŒãã¹ã¿ã€ã«ãã§ãã¯ããé€å€ããããã«
.eslintignore
ã䜿ããŸããããWhy:
è€æ°ã®ãã¡ã€ã«ãã¹ã¿ã€ã«ãã§ãã¯ããé€å€ããæã«ã
eslint-disable
ã®ã³ã¡ã³ãã§ã³ãŒããæ±ãå¿ èŠããããŸããã -
ãã«ãªã¯ãšã¹ããäœæããåã«ã¯
eslint
ã®ã³ã¡ã³ãã¢ãŠããåé€ããŸããããWhy:
ããžãã¯ã®å®è£ ã«æ³šåããŠããæã¯ã¹ã¿ã€ã«ãã§ãã¯ãç¡å¹ã«ããã®ã¯äžè¬çã§ããã
eslint-disable
ã®ã³ã¡ã³ããåé€ããŠã«ãŒã«ã«åŸãããšãå¿ããªãããã«ããŸãããã -
ã¿ã¹ã¯ã®ãµã€ãºã«ãã£ãŠã
//TODO:
ã³ã¡ã³ã䜿ããããã±ããã起祚ããããéžæããŸããããWhy:
ããŒã ã¡ãŒãã«ã¯å°ããªã¿ã¹ã¯ã®äº(é¢æ°ã®ãªãã¡ã¯ã¿ãªã³ã°ãã³ã¡ã³ãã®ã¢ããããŒããªã©)ãå®çŸ©ããŠãããŸãããã倧ããã®ã¿ã¹ã¯ã«ã¯ãªã³ãã«ãŒã«éãã«
//TODO(#3456)
ãšæžãããã±ããã®çªå·ãèšèŒããŸãããã -
ã³ã¡ã³ãã¯åžžã«ã³ãŒãã®å€æŽã«é¢é£ãããããã«ããŸããããã³ã¡ã³ãã¢ãŠããããã³ãŒãã¯åãé€ããŸãããã
Why:
ã³ãŒãã¯å¯èœãªéãèªã¿ãããããå¿ èŠããããšåæã«ãäœåãªéšåã¯é€å»ããŠããã¹ãã§ãããªãã¡ã¯ã¿ãªã³ã°ããæã¯æ¢åã³ãŒããã³ã¡ã³ãã¢ãŠãããã®ã§ã¯ãªããåé€ããŸãããã
-
ç¡é¢ä¿ã§ãã£ããããããªã³ãŒãããã°ãååä»ãã¯é¿ããŸãããã
Why:
ãã«ãããã»ã¹ã§ããããé€å»ã§ãããã(ãã¹ã)ã§ããããªãã®ã³ãŒãã¯å¥äŒç€Ÿãå¥ã¯ã©ã€ã¢ã³ãã®æž¡ãããå¯èœæ§ããããŸãããããªãã®ã³ãŒããã©ããã®èª°ãã«èŠãããŠç¬ãããªãããã«ããŸãããã
-
çãååãé¿ããŠãæå³ãšããŠåºå¥ããããæ€çŽ¢ããããååãã€ããŸããããé¢æ°ã«ã¯é·ããŠèšè¿°çãªååã䜿ããŸããããé¢æ°ã®ååã¯åè©ãããã¯åè©ã®ãã¬ãŒãºã«ããŸãããããã®é¢æ°ã®æå³ãäŒããå¿ èŠããããŸãã
Why:
ãœãŒã¹ã³ãŒããããèªç¶ã«ããèªã¿ããããããããã§ãã
-
ãã¡ã€ã«å ã®é¢æ°ãéé ã«ãã£ãŠãŸãšããŠãããŸããããé«ãã¬ãã«ã®é¢æ°ã¯äžéšãžãäœãã¬ãã«ã®é¢æ°ã¯äžéšãžäœçœ®ãããŸãããã
Why:
èªãã®ã«é©ãããœãŒã¹ã³ãŒãã«ãªãããã«ããããã§ãã
-
.editorconfigãã¡ã€ã«ã䜿ã£ãŠéçºè ãç°ãªããšãã£ã¿ãIDEã®ãããžã§ã¯ãéã§äžè²«ããã³ãŒãã£ã³ã°ã¹ã¿ã€ã«ãå®çŸ©ãç¶æããããšãã§ããããã«ããŸãããã
Why:
EditorConfigãããžã§ã¯ãã¯ã³ãŒãã£ã³ã°ã¹ã¿ã€ã«å®çŸ©ãšãšãã£ã¿ããã¡ã€ã«ãã©ãŒãããèªã¿èŸŒãã§ã¹ã¿ã€ã«å®çŸ©ãæå¹ã«ãããšãã£ã¿ãã©ã°ã€ã³ãããªããŸããEditorConfigãã¡ã€ã«ã¯å¯èªæ§ãé«ãããŒãžã§ã³ã³ã³ãããŒã«ã·ã¹ãã ãšãããŸãæ©èœããŸãã
-
ã³ãŒãã¹ã¿ã€ã«ã®ãšã©ãŒãäŒããŠããããšãã£ã¿ã䜿ããŸããããæ¢åã®ESLintã®èšå®ãšäžç·ã«eslint-plugin-prettierãšeslint-config-prettierã䜿ããŸãããããã£ãšèªã...
-
Git hookã®äœ¿çšãèããŸãããã
Why:
Git hookã¯éçºè ã®çç£æ§ã倧ããé«ããŠãããŸãããã«ãã®ç Žå£ãæããããšãªããã¹ããŒãžã³ã°ããããã¯ã·ã§ã³ç°å¢ã«å€æŽãäœæãã³ããããPushã§ããŸãããã£ãšèªã...
-
Prettierã
precommit hook
ãšãšãã«äœ¿ããŸããããWhy:
prettier
èªäœã¯ãšãŠãå匷ããã®ã§ã¯ãããŸãããæ¯åã®ã³ãŒããã©ãŒãããã«å¯ŸããŠåå¥ã®npm taskãšããŠã·ã³ãã«ã«å®è¡ããããšã¯ããŸãçç£çã§ã¯ãããŸãããããã§ã¯lint-staged
(ãšhusky
)ã掻èºããŸããlint-staged
hereã®husky
hereã®èšå®ãããèªã¿ãŸãããã
-
ã¯ã©ã€ã¢ã³ããµã€ãã®console ãã°ããããã¯ã·ã§ã³ç°å¢ã§åºåããã®ã¯é¿ããŸãããã
Why:
ãã«ãããã»ã¹ãéããŠConsoleãã°ãåãé€ãããšãã§ããŸã(ãã¹ãã§ã)ããã³ãŒãã¹ã¿ã€ã«ãã§ãã¯ãåãåºãconsole logã«ã€ããŠã®warningã®æ å ±ã確èªããŸãããã
-
ãããã¯ã·ã§ã³ã®ãã°ã¯èªã¿ãããããã«åºåããŸããããçæ³çã«ã¯ãããã¯ã·ã§ã³ã¢ãŒãã§äœ¿ãããŠãããã®ã³ã°ã©ã€ãã©ãªã䜿ããŸããã(winston ããã㯠node-bunyanã®ãããªãã®ããããŸãã)
Why:
ãã°ã®ã«ã©ãŒåãã¿ã€ã ã¹ã¿ã³ãããã°ãã¡ã€ã«ã®åºåãæ¥ã ã®ãã°ãã¡ã€ã«ã®ããŒããŒããããã©ãã«ã·ã¥ãŒãã£ã³ã°ã®äžå¿«æãå°ãªãããŠãããŸãã
Why:
ç§ãã¡ã¯æå¿«ã«æ§ç¯ãããRESTfulã®ã€ã³ã¿ãŒãã§ãŒã¹ã§ã®éçºã匷å¶ããããšã§ãããŒã ã¡ã³ããŒãã¯ã©ã€ã¢ã³ããã·ã³ãã«ã«ççŸãªãããã䜿ããããšãã§ããŸãã
Why:
äžè²«æ§ãã·ã³ãã«ãããªãAPIã¯ã·ã¹ãã ã®çµåãã¡ã³ããã³ã¹ã®ã³ã¹ããå¢å ãããŸããã ãã
API design
ããã®ããã¥ã¡ã³ãã«å«ããŠèª¬æããŠããŸãã
-
ç§ãã¡ã¯å€ãã®å Žé¢ã§ãªãœãŒã¹å¿åã¢ãŒããã¯ãã£ã«åŸã£ãŠããŸãããªãœãŒã¹å¿åã¢ãŒããã¯ãã£ãšã¯äž»ã«ãªãœãŒã¹ãéåãURLã®èŠçŽ ã§æ§æãããŸãã
- ãªãœãŒã¹ã¯ããŒã¿ãæã£ãŠããŠããã¹ããååŸã§ãããããã®ãªãœãŒã¹ãæäœã§ããã¡ãœããããããŸãã
- ãªãœãŒã¹ã®éåã¯ã³ã¬ã¯ã·ã§ã³ãšåŒã°ããŸãã
- URLã¯ãªã³ã©ã€ã³ã®ãªãœãŒã¹ã®å Žæã¯ãªãœãŒã¹ãã³ã¬ã¯ã·ã§ã³ã§è¡šããŸãã
Why:
äžèšã®ããšã¯éçºè (ããªãã®APIã䜿ã人ãã¡)ã«åšç¥ãããŠããããšã§ããå¯èªæ§ã䜿ãããããå¥ãšããŠããREST APIã§ã¯ãã®APIã®è©³çŽ°ãç¥ãããšãæ±çšãªã©ã€ãã©ãªãã³ãã¯ã¿ãæžããã§ããŸãã
-
URLã«ã¯kebab-caseã䜿ããŸãããã
-
ãªã¯ãšã¹ãå ã®ãã©ã¡ãŒã¿ããªãœãŒã¹å ã®ãã©ã¡ãŒã¿ã«ã¯camelCaseã䜿ããŸãããã
-
URLå ã®ãªãœãŒã¹åã¯è€æ°åœ¢ã®kebab-caseã«ããŸããã
-
ã³ã¬ã¯ã·ã§ã³ãè¡šãurlã«ã¯åžžã«è€æ°åœ¢ã®åè©ã䜿ããŸãããã
/users
Why:
åºæ¬çã«ã¯ããããããšã§èªã¿ãããã®åäžURLã®äžè²«æ§ãç¶æããããšã«ãªãã§ãããããã£ãšèªã...
-
ãœãŒã¹ã³ãŒãå ã§ã®å€æ°ãããããã£åã®è€æ°åœ¢ã¯ãªã¹ãã®ãµãã£ãã¯ã¹ã«ããŸãããã
Why:
è€æ°åœ¢ã¯URLã«ãããŠã¯è¯ããã®ã§ããããœãŒã¹ã³ãŒãå ã§ã¯åããã«ãããšã©ãŒã®åå ã«ãªãåŸãŸãã
-
ã³ã¬ã¯ã·ã§ã³ã§å§ãŸãèå¥åã«çµããåäžã®ãã¹ãåžžã«äœ¿çšããŸãããã
/students/245743 /airports/kjfk
-
以äžã®ãããªURLã¯é¿ããŸãããã
GET /blogs/:blogId/posts/:postId/summary
Why:
ãã®URLã¯ãªãœãŒã¹ã§ã¯ãªããããããã£ããããŠããŸããããããã£ã¯ã¬ã¹ãã³ã¹ãæŽããããã«ãã©ã¡ãŒã¿ã«æž¡ããŸãããã
-
ãªãœãŒã¹ã瀺ãURLããã¯åè©ãå«ããªãããã«ããŸãããã
Why:
åãªãœãŒã¹ã®æäœã«åè©ãå«ãããšãåã ã®ãªãœãŒã¹ã®æäœã«ã€ããŠå€§éã®URLãåºæ¥ãŠããŸããéçºè ã«ãšã£ãŠç解ããã®ãé£ããäžè²«æ§ã®ãªããã¿ãŒã³ã«ãªã£ãŠããŸãããã§ããç§ãã¡ã¯ä»ã®ç®æã«åè©ã䜿ã£ãŠããŸãã
-
ãªãœãŒã¹ã§ã¯ãªãéšåã«åè©ã䜿çšããŸãããããã®ã±ãŒã¹ã§ã¯ãã®APIã¯ãªãœãŒã¹ãè¿ããã«ãæäœãå®è¡ããŠçµæãåãåãã®ã¿ã§ããCRUD(Create Retrieve Update Delete)ã®æäœã§ã¯ãªãããšã«æ³šæããŸãããã
/translate?text=Hallo
Why:
CRUDã«ã€ããŠã¯ãªãœãŒã¹ãã³ã¬ã¯ã·ã§ã³ã®URLã«å¯ŸããŠHTTPã¡ãœããã䜿çšããããã§ãã説æããŠããåè©ã¯ãããã
Controller
ãšãªããŸããéåžžãããã®URLãããããäœæããããšã¯ãªãã§ãããããã£ãšèªã... -
ãªã¯ãšã¹ãããã£ãã¬ã¹ãã³ã¹ã¿ã€ãã¯
JSON
ã«ããŸãããããããŠäžè²«æ§ããã¡ã³ããã³ã¹ãããããããããã«ãããããã£åã¯camelCase
ã䜿çšããããã«ããŸããããWhy:
ãã®ããã¥ã¡ã³ãã¯JavaScriptãããžã§ã¯ãã®ã¬ã€ãã©ã€ã³ã§ãããããJSONã®èªã¿æžãã«ã¯JavaScriptã䜿çšãããŠãããšãæ³å®ããŠããŸããâš
-
ãªãœãŒã¹ãªããžã§ã¯ãã€ã³ã¹ã¿ã³ã¹ãDBã®ã¬ã³ãŒããšåããããªåäžãªãã®ã§ãã£ããšããŠãã
table_name
ãcolumn_name
ã¯ãªãœãŒã¹åãããããã£åã«ããªãããã«ããŸããããWhy:
ãããŸã§ãªãœãŒã¹ãå ¬éããã®ã§ãã£ãŠDBã®ã¹ããŒãã®è©³çŽ°ãå ¬éããããã®ãã®ã§ã¯ãªãããã§ãã
-
念ã®ããã«ããäžåºŠãURLã«ã¯åè©ã®ã¿ã䜿ããæ©èœã説æãããããªååä»ãã¯é¿ããŸããããâš
Why:
åè©ã®ã¿ããªãœãŒã¹ã®URLã«ã¯äœ¿çšããŸãããã
/addNewUser
ã/updateUse
ã®ãããªãšã³ããã€ã³ããçšæããã®ã¯ãããŸããããåæ§ã«ãªãœãŒã¹æäœããã©ã¡ãŒã¿ãéãã®ãé¿ããŸãããã -
CRUDã®æ©èœç説æã«ã¯HTTPã®ã¡ãœããã䜿ããŸãããã
How:
GET
: ååšãããªãœãŒã¹ã®ååŸãPOST
: æ°ãããªãœãŒã¹ãšãµããªãœãŒã¹ã®äœæãPUT
: æ¢åã®ãªãœãŒã¹ã®æŽæ°ãPATCH
: æ¢åã®ãªãœãŒã¹ã®æŽæ°ãæäŸããããã£ãŒã«ãã®ã¿ãæŽæ°ããä»ã®ãã£ãŒã«ãã¯ãã®ãŸãŸã«ããŠãããŸããDELETE
: ååšãããªãœãŒã¹ã®åé€ã -
ãã¹ãããŠãããªãœãŒã¹ã®ããã«é¢é£ããURLéã«ãªã¬ãŒã·ã§ã³ã䜿çšããŸããããäŸãã°äŒç€Ÿã®åŸæ¥å¡ãé¢é£ãããããã«ãidã䜿çšããŸãã
Why:
åãªãœãŒã¹ãæ¢çŽ¢ããããããããã®èªç¶ãªããæ¹ã§ãã
How:
GET /schools/2/students
ã2ã®åŠæ ¡ã®ãã¹ãŠã®çåŸãååŸã§ããã¯ãã§ããGET /schools/2/students/31
ã2ã®åŠæ ¡ã«æå±ããã31ã®çåŸã®è©³çŽ°ãååŸã§ããã¯ãã§ããDELETE /schools/2/students/31
ã2ã®åŠæ ¡ã«æå±ãã31ã®çåŸãåé€ã§ããã¯ãã§ããPUT /schools/2/students/31
ã31ã®çåŸã®æ å ±ãæŽæ°ããã¯ãã§ãããŸãPUTã¯ã³ã¬ã¯ã·ã§ã³ã«ã¯äœ¿çšããã«ãªãœãŒã¹URLã®ã¿ã«äœ¿çšããããã«ããŸããããPOST /schools
ãæ°ããªåŠæ ¡ãäœæããŠããã®äœæãããåŠæ ¡ã®æ å ±ãè¿åŽããã¯ãã§ããPOSTã¯ã³ã¬ã¯ã·ã§ã³ã®URLã«äœ¿çšããŸãããã -
ããŒãžã§ã³ã«ã¯
v
ããã¬ãã£ãã¯ã¹ãšããåçŽãªæŽæ°ã䜿çšããŸããã(v1,v2)ãå šãŠã®URLãæ®ãããŸãŸç§»åããããã«ãããŒãžã§ã³ã¯äžçªäžã®ã¹ã³ãŒãã«äœ¿çšããŸããããhttp://api.domain.com/v1/schools/3/students
Why:
APIããµãŒãããŒãã£ã®ããã«å ¬éãããæã«ã¯ãAPIã®ç Žå£çå€æŽã䌎ãããŒãžã§ã³ã¢ããã¯æ¢åã®ãããã¯ããAPIã䜿ããµãŒãã¹ã«å€å€§ãªåœ±é¿ãäžããŸããããŒãžã§ã³ãURLã«å«ããããšã§ããããã®åé¡ãèµ·ããããšãé²ãã§ãããŸãããã£ãšèªã...
-
ã¬ã¹ãã³ã¹ã¡ãã»ãŒãžã¯èªå·±èšè¿°çã§ãªããã°ãªããŸãããè¯ããšã©ãŒã¬ã¹ãã³ã¹ã¯ä»¥äžã®ãããªãã®ã«ãªããŸãã
{ "code": 1234, "message" : "Something bad happened", "description" : "More details" }
ãŸãããªããŒã·ã§ã³ãšã©ãŒãªãããã§ãã
{ "code" : 2314, "message" : "Validation Failed", "errors" : [ { "code" : 1233, "field" : "email", "message" : "Invalid email" }, { "code" : 1234, "field" : "password", "message" : "No password provided" } ] }
Why:
APIã䜿çšããã¢ããªã±ãŒã·ã§ã³ããã®ãŠãŒã¶ãŒã®æå ã«å±ããããããšãåé¡è§£æ±ºããã©ãã«ã·ã¥ãŒãã£ã³ã°ãããéèŠãªæã«ãéçºè ã¯è¯ããã¶ã€ã³ã®ãšã©ãŒã¡ãã»ãŒãžã«é Œãããšã«ãªããŸãã
Note: ã»ãã¥ãªãã£ã®äŸå€ã®ã¡ãã»ãŒãžã¯æ¥µåäžè¬åããŸããããäŸãã°"ãã¹ã¯ãŒããééã£ãŠããŸã"ãšèšã代ããã«ã"ãŠãŒã¶ãŒåãããã¯ãã¹ã¯ãŒããééã£ãŠããŸã"ãšèšããŸããããç§ãã¡ã®å Žåã¯ãŠãŒã¶ãŒåãæ£ãããŠããã¹ã¯ãŒãã ãééã£ãŠãããšäŒããããšã¯ããªãããã«ããŠããŸãã
-
å šãŠãããŸãåããŠãããã¯ã©ã€ã¢ã³ãã¢ããªãããŸãåããŠãªãã£ã ãAPIãããŸãåããŠãªãã£ã ç ã¬ã¹ãã³ã¹ã®èª¬æã«ã¯8åã®ã¹ããŒã¿ã¹ã®ã¿ãéãããã«ããŸãããã
äžèŠ§:
200 OK
GET
ãPUT
ãPOST
ãªã¯ãšã¹ããæåããããšãè¡šããŸãã201 Created
æ°ããã€ã³ã¹ã¿ã³ã¹ãäœæãããæã«è¿åŽãããŸããæ°ããã€ã³ã¹ã¿ã³ã¹ã®äœæãPOST
ã¡ãœããã®äœ¿çšã¯201
ã®ã¹ããŒã¿ã¹ã³ãŒããè¿ããŸãã304 Not Modified
ãŠãŒã¶ãŒããã§ã«ã¬ã¹ãã³ã¹ã®ãã£ãã·ã¥ãæã£ãŠããå Žåã«è¿åŽãããŸããæå°ã®è»¢éã«æããããšã«ãªããŸãã400 Bad Request
ãªã¯ãšã¹ããåŠçãããªãã£ãå Žåã«è¿åŽãããŸãããµãŒããŒãã¯ã©ã€ã¢ã³ãã®èŠæ±ãããªã¯ãšã¹ããç解ã§ããªãã£ããããªæã§ãã401 Unauthorized
ãªã¯ãšã¹ãã®èªèšŒæ å ±ãäžè¶³ããŠããæã«è¿åŽãããŸããèŠæ±ãããèªèšŒæ å ±ã§åãªã¯ãšã¹ããè¡ãããšã«ãªãã§ãããã403 Forbidden
ãµãŒããŒã¯ãªã¯ãšã¹ãã解éã§ããŠããŸãããèªèšŒãæåŠãããšããæå³ã§ãã404 Not Found
ãªã¯ãšã¹ããããªãœãŒã¹ãèŠã€ãããªãã£ãããšã瀺ããŸãã500 Internal Server Error
ãªã¯ãšã¹ãã¯æ£ãããããµãŒããŒãäºæãã¬äºæ ã«ããåäœããªãã£ãããšã瀺ããŸããWhy:
å€ãã®APIã®æäŸè ã¯å°æ°ã®HTTPã®ã¹ããŒã¿ã¹ã³ãŒãã䜿çšããŸããäŸãã°Googleã®Gdata APIã¯10åã®ã¹ããŒã¿ã¹ã³ãŒããã䜿ã£ãŠããŸãããNetflixã¯9ã€ã§ããDiggã¯8ã€ã ãã§ãããã¡ãããªãããããã®ã¬ã¹ãã³ã¹ã¯è¿œå ã®æ å ±ãbodyã«å«ããŠããŸãã70ãè¶ ããHTTPã®ã¹ããŒã¿ã¹ãååšããŸãããããŸãäžè¬çã§ãªãã¹ããŒã¿ã¹ã³ãŒããéžæãããšãã¢ããªã±ãŒã·ã§ã³ã®éçºè ã¯éçºãé¢ããŠãã¹ããŒã¿ã¹ã³ãŒããäœã瀺ããŠããã®ããç解ããããšwikipediaçã§èª¿ã¹ãããåŸãªããªããŸãããã£ãšèªã...
-
ã¬ã¹ãã³ã¹ã«ã¯ãªãœãŒã¹ã®æ°ã®åèšãæäŸããŸãããã
-
limit
ãšoffset
ã®ãã©ã¡ãŒã¿ãåãã€ããŸãããã -
ãªãœãŒã¹ã®å ¬éããããŒã¿éã¯ããèããå¿ èŠããããŸããAPIã®å©çšè ã¯åžžã«ãªãœãŒã¹ã®å šãŠã®è¡šçŸãå¿ èŠãšããããã§ã¯ãããŸããããã£ãŒã«ãã®ã«ã³ãåºåããªã¹ããå«ããã£ãŒã«ãã¯ãšãªãã©ã¡ãŒã¿ã䜿çšããŸãã
GET /student?fields=id,name,age,class
-
ããŒãžããŒã·ã§ã³ããã£ã«ã¿ãªã³ã°ããœãŒãã¯åãããå šãŠã®ãªãœãŒã¹ããµããŒãããå¿ èŠã¯ãããŸããããã£ã«ã¿ãªã³ã°ããœãŒãã®ããšã«ãããã®ãªãœãŒã¹ãèšè¿°ããŸãããã
ããã€ãã®ã»ãã¥ãªãã£ã®ãã¹ããã©ã¯ãã£ã¹ãã玹ä»ããŸãã
-
ã»ãã¥ã¢ãªéä¿¡(HTTPS)以å€ã§ã¯ããŒã·ãã¯èªèšŒã䜿ããªãããã«ããŸããããèªèšŒããŒã¯ã³ãURLã«å«ããŠã¯ãããŸããã
GET /users/123?token=asdf....
Why:
ããŒã¯ã³ããŠãŒã¶ãŒIDããã¹ã¯ãŒããå¹³æãšããŠãããã¯ãŒã¯ãè¶ ããŠããã®ã§ïŒbase64ã«ãšã³ã³ãŒããããŠããã§ãããããbase64ã¯å¯éãªãšã³ã³ãŒãæ¹æ³ã§ããïŒãããŒã·ãã¯èªèšŒæ©æ§ã¯ã»ãã¥ã¢ã§ã¯ãªãã§ãããã£ãšèªã...
-
ããŒã¯ã³ã¯æ¯åã®ãªã¯ãšã¹ãã®èªèšŒããããŒã«ä¹ããŠéä¿¡ãããªããã°ãªããŸããã
Authorization: Bearer xxxxxx, Extra yyyyy
-
èªèšŒã³ãŒãã®çåæéã¯çãèšå®ãããã¹ãã§ãã
-
å®å šã§ã¯ãªãããŒã¿ã®åãæž¡ããé¿ããããã«HTTPãªã¯ãšã¹ãã«å¿çããªãããšã§TLSã§ã¯ãªããªã¯ãšã¹ããæåŠããããã«ããŸãããããã®éã«ã¯
403 Forbidden
ã§å¿çããŸãããã -
ãªã¯ãšã¹ãå¶éã䜿ãããšãèããŸãããã
Why:
äžæéãããäœåãã®ãªã¯ãšã¹ããéãã€ããŠããããããã身ãå®ãããã«ããªã¯ãšã¹ãå¶éãæ©ããã¡ããèããŠããã¹ãã§ãããã
-
HTTPããããé©åã«èšå®ããããšã¯Webã¢ããªã±ãŒã·ã§ã³ããã匷åºã«ãããå®å šã«ããã®ã«åœ¹ç«ã¡ãŸãããã£ãšèªã...
-
APIã¯æšæºçãªãã©ãŒã ã®ããŒã¿ãåãåã£ãŠããŒã¿ãå å·¥ããŸããããã§ããªããã°ãªã¯ãšã¹ããæåŠããããã«ããŸãããã400 Bad Requestãšãšãã«ããŒã¿ã®äžè¶³ããšã©ãŒã«ã€ããŠã®è©³çŽ°ãè¿åŽããŸãããã
-
RESTãªAPIã§äº€æãããå šãŠã®ããŒã¿ã¯APIäžã§Validateããããã«ããŸãããã
-
JSONãã·ãªã¢ã©ã€ãºããŸãããã
Why:
JSONãšã³ã³ãŒãã®æ©ã¿ã®çš®ã¯ããã©ãŠã¶å ã§ãªã¢ãŒãããã®ä»»æã®JavaScriptã®å®è¡ãé²ãããšã§ãããããã¯node.jsã䜿çšããŠããã®ã§ããã°ããµãŒããŒãµã€ããåæ§ã§ãããŠãŒã¶ãŒããäžããããå ¥åããã©ãŠã¶å ã§å®è¡ãããªãããã«ããŠãŒã¶ãŒããã®æ å ±ããšã³ã³ãŒãã§ããé©åãªJSONã·ãªã¢ã©ã€ã¶ãŒã䜿çšããããšãéèŠã§ãã
-
Content-TypeãValidateããããã«ããŸããããå€ãã®å Žåã§
application/*json
(Content-Typeããã)ã䜿ããŸããããWhy:
äŸãã°ã
application/x-www-form-urlencoded
ã®mime-typeãåãå ¥ããããšã¯ãæ»æè ã«ãã©ãŒã ãäœæãããã·ã³ãã«ãªPOSTãªã¯ãšã¹ããèªåŒãããããšãèš±ãããšã«ãªããŸãããµãŒãã¯åãå ¥ããContent-Typeã決ããŠæšå®ãããªãã¹ãã§ããContent-Typeããããããã¯äºæããªãContent-Typeãããã«å¯ŸããŠã¯4XX
ã®ã¬ã¹ãã³ã¹ã§ãªã¯ãšã¹ããæåŠããçµæãè¿åŽããŸãããã -
APIã®ã»ãã¥ãªãã£ããã§ãã¯ãªã¹ããèŠãŠç¢ºèªããŸãããããã£ãšèªã...
- README.md templateã®
API Reference
ã®ã»ã¯ã·ã§ã³ãåããŸãããã - ã³ãŒãã®ãµã³ãã«ãšãšãã«APIã®èªèšŒæ¹æ³ã«ã€ããŠèšè¿°ããŸãããã
- URLã®æ§é (pathã«ã€ããŠã®ã¿ã§ããã§ããrootã®URLã«ã€ããŠã¯å¿ èŠãããŸããã)ããªã¯ãšã¹ãã®ã¡ãœãããšãšãã«èª¬æããŸãããã
åãšã³ããã€ã³ãã«ã€ããŠ
-
URLãã©ã¡ãŒã¿ã¯ããååšããå Žåã¯ãURLã»ã¯ã·ã§ã³ã«èšèŒãããŠããååã«åŸã£ãŠæå®ããŸãããã
Required: id=[integer] Optional: photo_id=[alphanumeric]
-
ãªã¯ãšã¹ãã¿ã€ããPOSTãªããã¡ãããšåãäŸãçšæããŸããããURLãã©ã¡ãŒã¿ã®ã«ãŒã«ã¯ããã«ãé©çšããŸããOptionalãšRequiredã«åããŸãããã
-
ã¬ã¹ãã³ã¹ã®æåã®å Žåã¹ããŒã¿ã¹ã³ãŒãã¯äœã§ããããïŒã©ããªããŒã¿ãè¿ãããã§ããããïŒããã¥ã¡ã³ãã¯APIã®è¿çãéçºè ãç¥ããããšãã«åœ¹ç«ã¡ãŸãã
Code: 200 Content: { id : 12 }
-
ã¬ã¹ãã³ã¹ã®å€±æã®æã¯ãã»ãšãã©ã®ãšã³ããã€ã³ãã®å€±æã¯è€æ°éããããŸããèªèšŒãããŠããªãã¢ã¯ã»ã¹ããã®äžæ£ãªå€çããããå šãŠãããã§ã¯åæããŸããããç¹°ãè¿ãã«ãªããŸãããããããããšã§æ¶æž¬ã®ã¿ã§éçºããããåŸãªãç¶æ³ãé²ããŸããäŸ
{ "code": 403, "message" : "Authentication failed", "description" : "Invalid username or password" }
-
APIãã¶ã€ã³ããŒã«ã䜿çšããŸããããAPI BlueprintãSwaggerã®ãããªãªãŒãã³ãœãŒã¹ã®è¯ãããã¥ã¡ã³ããŒã·ã§ã³ããŒã«ããããããããŸãã
䜿çšã§ããæš©å©ã®ãããªãœãŒã¹ã䜿çšããŠããããšã確èªããŠãã ãããã©ã€ãã©ãªã䜿ã£ãŠããã®ã§ããã°ãMITãApacheãBSDã®ã©ã€ã»ã³ã¹ãèŠã€ããããšãå¿ãããŸããããã©ã€ãã©ãªãä¿®æ£ãããã®ã§ããã°ãã©ã€ã»ã³ã¹ã®è©³çŽ°ãå°ãèŠãŠèŠãŸããããèäœæš©ã§ä¿è·ãããŠããç»åãåç»ãæ³çåé¡ãåŒãèµ·ãããããããŸããã
Sources: RisingStack Engineering, Mozilla Developer Network, Heroku Dev Center, Airbnb/javascript, Atlassian Git tutorials, Apigee, Wishtack
Icons by icons8