Upgrade to Pro — share decks privately, control downloads, hide ads and more …

API になろう / Let's become an API

60775fff9467dfa6fa158228010a26df?s=47 Pちゃん
December 18, 2019

API になろう / Let's become an API

60775fff9467dfa6fa158228010a26df?s=128

Pちゃん

December 18, 2019
Tweet

Transcript

  1. өͬͨΒ࿩͢

  2. ͜Μ͹Μ͸

  3. PͪΌΜ @p1ch_jp

  4. ͓·͑ͩΕ w ॴଐ w גࣜձࣾσΟʔɾΤψɾΤʔ w Կͯ͠Δ w ϑϩϯτΤϯυΤϯδχΞ

  5. ͸͍

  6. ࠓ೔ͳΜͰ͕͢

  7. -5ότϧͱ͍͏͜ͱͰ Ժ΍͔͡Όͳ͍Ͱ͢Ͷ

  8. ͸͍

  9. ΅͕͘͜͜ʹ͍Δ ܦҢͳΜͰ͕͢

  10. None
  11. None
  12. ͳΜ΍͔Μ΍Ͱ

  13. ͏͔ͬΓϦϯάʹ ্͕Δ͜ͱʹͳͬͯ͠·ͬͨ

  14. ͔͠΋ͳ͔ͥ όοΫΤϯυͰ

  15. ϏϏͬͯ·͢

  16. ԿΛ࿩͢ͷ͔

  17. ຊ೔ͷ΅͘ͷςʔϚ

  18. όοΫΤϯυͱ ͍͏͜ͱͳΜͰ͕͢

  19. ͨͿΜདྷͯΔਓͷ ΄ͱΜͲͷਓ͕

  20. σβΠφʔ ϑϩϯτΤϯυΤϯδχΞ 03

  21. ΑͶʁ

  22. ͳʹΑΓ ΅ࣗ͘਎͕ৄ͘͠ͳ͍

  23. ͱ͍͏Θ͚Ͱ

  24. ࠓ೔͸Ͱ͢Ͷ

  25. ࣮຿ͰΞϨίϨͯ͠ಘͨ ҝʹͳΔ஌ݟͷڞ༗ͱ͔

  26. ͦ͏͍͏ͷ Ͱ͖ͯ·ͤΜ

  27. ԿΛ࿩͔͢ͱݴ͏ͱʜ

  28. ࠷ۙझຯͰ࡞ͬͨAPI ͷ࿩Ͱ΋ ͠Α͏ͱࢥ͍·͢

  29. גࣜձࣾσΟʔɾΤψɾΤʔσβΠϯຊ෦αʔϏεσβΠϯ෦%&(( ౻ݪ৻ଠ࿠BLB1$IBO APIʹͳΖ͏ FROKAN x UIT #2 - ೥๨ΕLT ότϧ

  30. ૝ఆௌߨऀ

  31. ૝ఆௌߨऀ w ීஈɺ࢓ࣄͰ͸ϑϩϯτΤϯυΛॻ͍͍ͯΔ͕ɺझຯ΍ ݸਓ։ൃͰόοΫΤϯυ΋ॻ͍͍͖͍ͯͨਓ w มͳAPI͕ੜ͑ͯΔͷΛݟ͚ͭΔͱָ͘͠ͳͬͪΌ͏ਓ

  32. ͜͏ͳΔͱΑͦ͞͏ w ॳֶऀʹ΋ෛ୲ͷগͳ͍ٕज़ελοΫΛ஌ͬͯɺ࣮ࡍʹ (FUUJOH4UBSU͢Δػӡ͕ߴ·Δ w ͱ͸ݴ͑Կͭ͘Ε͹͑͑ͶΜ໰୊Λղফͯ͠ɺ࣮ࡍʹ (FUUJOH4UBSU͢Δػӡ͕ߴ·Δ

  33. Ͱ

  34. ࠓ೔ɺग़ͯ͘Δ੒Ռ෺ શ෦JSONͳΜͰ

  35. Έͳ͞Μ΋͓खݩʹ

  36. 1PTUNBO

  37. ͱ͔

  38. 1PTUXPNBO

  39. ͱ͔

  40. *OTPNOJB

  41. ͱ͔ى্ͪ͛ͳ͕Β ฉ͍͍͚ͯͨͩΔͱ

  42. ָ͍͔͠΋͠Ε·ͤΜ

  43. ΈΜͳ͕ى্ͪ͛ͯΔؒʹ ΅͕͘ञΛҿΉ࣌ؒ

  44. ͸͍

  45. ࠓճ࡞ͬͨ΋ͷ 0

  46. P-Chan API

  47. IUUQTBQJQDIBOJN

  48.  ಡΜͰυϝΠϯͷ೗͘

  49.  ΅͘ʹؔ͢Δ৘ใ͕ฦΓ·͢

  50. GET /identification GET /accounts GET /assets PATCH /assets

  51.  ࢖༻ٕज़

  52.  ͜Μͳײ͡Ͱ͢

  53.  ࠓ೔͸

  54.  ୈҰষɺίίΒ΁Μ

  55.  ୈೋষɺίίΒ΁Μ

  56.  ʹผ͚ͯ঺հ͍͖ͯ͠·͢

  57. ͱΓ·αʔόʔΛى্ͪ͛ͯ ੩తͳ৘ใΛฦͯ͠ΈΔ 1

  58.  ίίΒ΁Μͷ࿩

  59.  ͜ͷষ͸ݴ͍͍ͨ͜ͱ ͻͱ͔ͭ͠ͳ͍

  60.  झຯor ݸਓ։ൃ && ॳΊͯͷαʔόʔαΠυNode.js

  61. TypeScript + Express Ͱ૊΋͏

  62. 5ZQF4DSJQU &YQSFTT w &YQSFTTӫރ੝ਰͷܹ͍͠ք۾ʹ͓͍ͯ͸௝͘͠ɺރΕ ͭͭ΋ݱ໾Ͱ࢖͑ΔͷͰʢރΕͯΔ΋ͷ͸৘ใྔ͕๛෋ w 5ZQF4DSJQUϑϩϯτ͸·ͩ54ͱ૬ੑͷྑ͍ϑϨʔϜϫʔ Ϋͦ͏͡Όͳ͍ϑϨʔϜϫʔΫ͋Δ͕ɺόοΫΤϯυ͸ ͍͍ͩͨ૬ੑ͍͍ɻϑϩϯτͱҧͬͯXFCQBDLͷઃఆ Ͱ͠ΜͲ͍ͱ͔ͳͯ͘ɺجຊUTDίϚϯυͰઓ͑ΔͷͰ

    ྑ͞Έ͕͋Δɻ
  63.  ࠷ۙ͸Nest.jsͱ͔͕ ྲྀߦͬͯ·͕͢

  64.  Ұ൪ॳΊ͸ΦʔιυοΫεʹ ExpressͰ૊Ή͜ͱΛΦεεϝ σΟεͬͯ͸ͳ͍Αɺ510ͶʢҰԠ

  65.  P-Chan APIͷ৔߹͸ ͜ΕͰ

  66. GET /identification

  67. GET /accounts

  68.  ͋ͨΓΛฦͯ͠·͢

  69.  ͸͍

  70.  ͱΓ·͜ΕͰAPI૊Ί·ͨ͠

  71.  ͱ͸ݴ͑͜Ε͚ͩ͡Ό Կ΋໘ന͘Ͷ͑

  72.  όοΫΤϯυͳΒͰ͸ͷ

  73.  औ͖ͬͯͨσʔλΛ อଘͨ͠Γɺు͖ग़ͨ͠Γ

  74.  ͦ͏͍͏ͷ͍ͨ͠

  75. σʔλΛऔ͖ͬͯͯอଘͯ͠ ు͖ग़͢·ͰͷΞϨίϨ 2

  76. ͲΜͳΤϯυϙΠϯτ ੜ΍͔͢ͳʔͱࢥ͍ͬͯͨΒ

  77. ͜ΜͳIssue͕ͨͬͯͨͷͰ

  78. ݮΔ΋Μ͡Όͳ͍͍͍͔͠

  79. ͜ΜͳΤϯυϙΠϯτΛ ༻ҙ͠·ͨ͠

  80. PATCH /assets GET /assets ࢿ࢈৘ใͷฦ٫ͱߋ৽

  81. αϯϓϧσʔλͰ΋ ͍͍͔ͱࢥͬͨΜͰ͕͢

  82. ໘നΈʹ͚ܽΔͷͰ

  83. ʢϦΞϧΨνσʔλฦ͠·͢ʣ

  84. ͜ΕΒͷΤϯυϙΠϯτ͸ ओʹ2ͭͷ޻ఔͰ੒ΓཱͬͯΔ

  85. PuppeteerͰ σʔλΛऔͬͯ͘Δ޻ఔ Prisma FrameworkͰ σʔλΛग़͠ೖΕ͢Δ޻ఔ Prisma Framework

  86. PuppeteerͰ σʔλΛऔͬͯ͘Δ޻ఔ Prisma FrameworkͰ σʔλΛग़͠ೖΕ͢Δ޻ఔ Prisma Framework

  87. Puppeteer ࢖͏ͳΒσϓϩΠઌ͸Α͘ߟ͑Α͏ w ZEIT Nowɺv2͔Β͸FaaSతͳײ͡ʹͳͬͨͷͰɺ͋Μ ·ΓϔουϨεϒϥ΢βΛͿΜճ͢Έ͍ͨͳέʔεΛ૝ఆ ͞Ε͍ͯͳ͍ɻλΠϜΞ΢τ͕10 ඵɻ ՝ۚͰ5 ෼ʹ

     w ͓ͱͳ͘͠GAE/SE λΠϜΞ΢τ60ඵ ͱ͔ɺGoogle Cloud Functions λΠϜΞ΢τ540ඵ ͱ͔࢖ͬͨ΄͏͕ ྑ͍ w ͨͿΜP-Chan API͸ɺ͖͡ʹ৐Γ׵͑Δ
  88. PuppeteerͰ σʔλΛऔͬͯ͘Δ޻ఔ Prisma FrameworkͰ σʔλΛग़͠ೖΕ͢Δ޻ఔ Prisma Framework

  89. ࠓ೔Ұ൪஌ͬͯ΄͍͠΍ͭ

  90. ͋ͨΓ·͑ͳΜͰ͕͢

  91. ϑϩϯτΤϯυͰ͸Ͱ͖ͳ͍ όοΫΤϯυͷ໘ന͞ͱͯ͠

  92. σʔλͷӬଓԽ͕͋Δ

  93. 2019೥ͷ ΞϓϦέʔγϣϯ։ൃʹ͓͍ͯ

  94. େମͷ৔߹ɺORMͱ͍͏ྨͷ ϥΠϒϥϦΛ࢖͏͜ͱʹΑͬͯ

  95. SQLΛ௚ॻ͖͢Δ͜ͱͳ͘ ؆୯ʹDB΁ͷCRUD͕Ͱ͖ΔΑ͏ʹ

  96. ͱ͸ݴ͑

  97. ॳֶऀʹͱͬͯ

  98. ίʔυ͕ Ұ൪ΰνϟΓΨνͳ෦෼Ͱ͋Γ

  99. ORMಠࣗͷϚΠάϨʔγϣϯϧʔ ϧ΍ه๏Ͱ୤མ͕ͪ͠

  100. ͦ͜Ͱࠓճ࢖ͬͨͷ͕

  101. Prisma Framework

  102. ORM Migration Sequel Pro ͬΆ͍΍ͭ

  103. ࢖͍ํ͸؆୯

  104. εΩʔϚΛఆٛ͢Δ Prettier΋αϙʔτ͞ΕͯΔΑ TDIFNBQSJTNB

  105. ϚΠάϨʔγϣϯͷੜ੒ͱ࣮ߦ prisma2 lift save && prisma2 lift up 5FSNJOBM

  106. ͜Μͳײ͡Ͱ௥Ճͨ͠Γ DPOUSPMMFSTBTTFUTUT

  107. ͜Μͳײ͡Ͱfindͨ͠Γ DPOUSPMMFSTBTTFUTUT

  108. ΊͪΌͪ͘Ό௚ײతͳ ΦϒδΣΫτͷૢ࡞Ͱ׬݁

  109. ·ͩ·ͩ͜Ε͔ΒͳORM͚ͩͲɺ ৮ͬͨײ͡ɺखʹೃછΉؾ͕͢Δ

  110. ҰԠTypeScript ORMքͷԦऀ TypeORMͱͷൺֱ

  111. vs TypeORM (1/2) w ޙൃͷͨΊɺશମతʹ·ͩ·ͩউͯͳ͍ʢػೳͷଟ͞ɺ ରԠ͢Δσʔλϕʔεͷଟ͞ɺ࣮ࡍͷར༻ྫͳͲͳͲʣ w ͱ͸ݴ͑ɺ๏ਓ͕։ൃ฼ମͳͷͰɺ։ൃεϐʔυ͕҆ఆ ͍ͯ͠Δʢ࠷௿Ͱ΋ִिͰΞϓσ͢Δͱݴͬͯͨʣ w

    TypeORM ʹൺ΂ͯରԠ͢Δσʔλϕʔε͕ߜΒΕͯΔ ͷ͸ɺܽ఺Ͱ΋͋Δ͕ར఺Ͱ΋͋Γͦ͏
  112. vs TypeORM (2/2) w Photon JS ORM૚ Lift JS Migration૚

    ͕ಠཱͯ͠ ಈ͘ͱ͍͏ͷ͸NodeͬΆͯ͘޷͖ʢ޷Έͷ໰୊ w ԿΑΓɺ·ͩv0.xͰ͋ΓProductionͰͷ࢖༻͸ਪ঑͞ Ε͍ͯͳ͍ͷͰɺશମతʹࠓޙʹظ଴ͱ͍͏ײ͡ w ʢTypeScript Ͱॻ͚ΔORM͕ͦΜͳʹଟ͘ͳ͍தͰɺ બ୒ࢶ͕૿͑Δ͜ͱࣗମɺ݁ߏՁ஋͕͋Γͦ͏ʣ
  113. ·ͱΊ 3

  114. ·ͱΊ w όοΫΤϯυ͜ͱ͸͡Ί͸ʮTypeScript + Express + Prisma Frameworkʯ͕͍͍͔΋͠Εͳ͍Α w ࣗ෼ͷ৘ใΛίϯςϯπʹͨ͠ΒɺແݶʹΤϯυϙΠϯ

    τΛ࡞ΕΔͷͰɺʮͱ͸ݴ͑Կ࡞Ε͹͑͑ͶΜ໰୊ʯͰ ΤλΔͱ͔ͳͦ͞͏ɺΦεεϝ
  115.  ࠓ೔঺հͨ͠APIͳΜͰ͕͢

  116.  ୭ಘ͔͸෼͔Βͳ͍͚Ͳ

  117.  ಛʹೝՄػߏͱ͔ ੵΜͰͳ͍ΜͰ

  118.  ୭Ͱ΋ୟ͚·͢

  119. ͱ͍͏Θ͚Ͱ

  120. Ҏ্

  121. גࣜձࣾσΟʔɾΤψɾΤʔσβΠϯຊ෦αʔϏεσβΠϯ෦%&(( ౻ݪ৻ଠ࿠BLB1$IBO APIʹͳΖ͏ FROKAN x UIT #2 - ೥๨ΕLT ότϧ

  122. Ͱͨ͠

  123. ͝੩ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠