NestJS meetup Tokyo Opening Talk / What is NestJS? #nestjs_meetup

NestJS meetup Tokyo Opening Talk / What is NestJS? #nestjs_meetup

2019/11/29 に株式会社エウレカで開催された #nestjs_meetup のスライドです。

A54b31d4ebbce222dff88a5c42bac033?s=128

Potato4d(Hanatani Takuma)

November 29, 2019
Tweet

Transcript

  1. What is NestJS ? 2019.11.28 #nestjs_meetup Takuma HANATANI (@potato4d)

  2. Takuma HANATANI (@potato4d) • Working at • Senior Front-End Engineer

    at LINE Corp. • CEO at ElevenBack LLC. • Contributions • Vue.js and React.js Japanese document maintainer • Contributed to NestJS for the first time this month • I — • User Interface, Serverless, Cloud Native
  3. ΧϨϯμʔ΍ࣗಈԽʹΑͬͯձܭ؅ཧ͔Βղ์͞ΕΔΫϥ΢υʮ$BOEZʯϕʔλఏڙத IUUQTDBOEZBDDBNQBJHOCFUB

  4. Topics 1. ͸͡Ίʹ 2. αʔόʔαΠυ Node.js ͷ՝୊ 3. ͳͥ NestJS

    ͳͷ͔ɻಛ௃ͱັྗ 4. αʔόʔαΠυ Node.js ͷੈքͰ NestJS ʹظ଴͞ΕΔ΋ͷ
  5. Topics 1. ͸͡Ίʹ 2. αʔόʔαΠυ Node.js ͷ՝୊ 3. ͳͥ NestJS

    ͳͷ͔ɻಛ௃ͱັྗ 4. αʔόʔαΠυ Node.js ͷੈքͰ NestJS ʹظ଴͞ΕΔ΋ͷ
  6. Q. NestJS ࢖ͬͨ͜ͱ͋Δʁ

  7. NestJS Official website (https://nestjs.com/)

  8. ࣄલΞϯέʔτ݁Ռ ࢓ࣄͰ࢖͍ͬͯΔ ਓ ྆ํͰ࢖͍ͬͯΔ ਓ झຯͰ࢖͍ͬͯΔ ਓ ࢖ͬͨ͜ͱ͕ͳ͍ ਓ

  9. 3ߦͰΘ͔Δ NestJS

  10. NestJS ͬͯͲΜͳϑϨʔϜϫʔΫʁ • ७ਮͳΔ TypeScript ʹΑͬͯهड़͞Εͨ • DI ͷจ຺Λڧ͘ड͚ܧ͍ͩ •

    Opinionated Ͱ Progressive ͳϑϨʔϜϫʔΫ
  11. Over 20k stars https://github.com/nestjs/nest

  12. 16.5k weekly downloads https://www.npmtrends.com/@nestjs/common

  13. αʔόʔαΠυ Node.js ͸ Express ͚ͩ͡Ό͋ͳ͍

  14. Topics 1. ͸͡Ίʹ 2. αʔόʔαΠυ Node.js ͷ՝୊ 3. ͳͥ NestJS

    ͳͷ͔ɻಛ௃ͱັྗ 4. αʔόʔαΠυ Node.js ͷੈքͰ NestJS ʹظ଴͞ΕΔ΋ͷ
  15. Express Ұڧ͕ଓ͘৘੎

  16. Express ࢖͏্Ͱͷ೰Έ • ബ͍ API ͷͭ΋ΓͰ࡞ͬͨ Req/Res Object ʹґଘͨ͠ີ݁߹ͳίʔυ •

    ୭΋࢖ͬͯͳ͍ express-generator • Ϧςϥγʔ͕௿͍ͱ console.log ͰϩΪϯάͯͨ͠Γ͢Δ • 100ਓډͨΒ100ਓҧ͏ΞʔΩςΫνϟʹͳΔࣗ༝౓ • ߴ೉қ౓Խ͢Δ։ൃϧʔϧɾΞʔΩςΫνϟͷ౷Ұ ϚΠΫϩϑϨʔϜϫʔΫʹඞਢͳઃܭ੹೚Λ୭΋ͱΕͣഁ୼͢Δ։ൃମ੍ ☠
  17. “ࣗ෼Ҏ֎ͷ Express ͷίʔυ͸ಡΈͨ͘ͳ͍”

  18. “ࣗ෼ͷੲͷ Express ͷίʔυ΋ಡΈͨ͘ͳ͍”

  19. ͦ΋ͦ΋ͷؒҧ͍ • Express ͸ศརͳٕज़͕ͩɺͦΕ͚ͩΛ࢖͍ͬͯΕ͹ྑ͍Θ͚Ͱ͸ͳ͍ • ബ͍ͨΊखܰʹ࢖͑Δ͕ɺബ͍͔Βͱ͍ͬͯࡶͰྑ͍Θ͚Ͱ͸ͳ͍ • ബ͍(Less opinionated)ٕज़ʹ͸ബ͍͚ͩͷ੹೚͕൐͏ •

    ϑϨʔϜϫʔΫͷࢥ૝ʹ৐Βͳ͍ͳΒɺࣗ਎͕ࢥ૝Λ࣋ͭ΂͖Ͱ͋Δ • ߟ͑ͳͯ͘ྑ͍ͷͰ͸ͳ͘ɺ౰ࣄऀͱͯ͠ߟ͑ɺ఻͑Δඞཁ͕͋Δ • ࢥߟͱܒ໤ʹ੹೚Λ޿࣋ͯ͘ͳ͍৔߹ɺڱΊΔ͜ͱ͕ॏཁ • աڈͷϑϧελοΫϑϨʔϜϫʔΫ͸͜ΕʹΑͬͯࢥߟΛ࠷খԽͨ͠ • ܕʹ͸·ͬͨ։ൃͷ՝୊΋͋Γɺബ͍΋ͷ͕ٻΊΒΕΔ͜ͱ΋͋ͬͨ
  20. ॏ͍ʁ

  21. Topics 1. ͸͡Ίʹ 2. αʔόʔαΠυ Node.js ͷ՝୊ 3. ͳͥ NestJS

    ͳͷ͔ɻಛ௃ͱັྗ 4. αʔόʔαΠυ Node.js ͷੈքͰ NestJS ʹظ଴͞ΕΔ΋ͷ
  22. NestJS ͬͯͲΜͳϑϨʔϜϫʔΫʁ • ७ਮͳΔ TypeScript ʹΑͬͯهड़͞Εͨ • DI ͷจ຺Λڧ͘ड͚ܧ͍ͩ •

    Opinionated Ͱ Progressive ͳϑϨʔϜϫʔΫ
  23. NestJS ͸αʔόʔαΠυ Node.js ʹ டং Λ༩͑Δ

  24. TypeScript NestJS Λࢧ͑Δ3ͭͷப %FQFOEFODZ *OKFDUJPO 0QJOJPOBUFE "SDIJUFDUVSF 1SPHSFTTJWF &DPTZTUFN

  25. Dependency Injection • ΦϒδΣΫτಉ࢜(Ϋϥεಉ࢜)ͷґଘΛ֎෦͔Βઃఆ͢Δ͜ͱ • Dependency(ґଘΦϒδΣΫτ)ͷInjection(஫ೖ) • ΦϒδΣΫτಉ࢜ͷґଘΛ಺෦Ͱղܾ͠ͳ͍͜ͱʹΑͬͯɺςελϒϧ͔ͭ ൚༻ੑͷߴ͍ίʔυΛॻͨ͘ΊͷςΫχοΫ •

    DAO ͕ؔΘΔΦϒδΣΫτςετͮ͠Β͍໰୊ • ֎෦ API ͕ؔΘΔΦϒδΣΫτςετͮ͠Β͍໰୊ • ͦͯ͠ DI Λ͏·͘औΓѻ͏࢓૊ΈΛఏڙ͞Ε͍ͯΔ (DIίϯςφ) NestJSΛ࢖͏͜ͱͰʮࣗવͱґଘؔ܎Λҙࣝͨ͠ίʔυ͕࡞ΒΕΔʯΑ͏ʹ
  26. Opinionated Architecture • DI Λલఏͱͨ͠ Service ͱͦΕΛར༻͢Δ Provider / Module

    • ൚༻తͳ Service ͱɺΞϓϦέʔγϣϯ޲͚ͷೖΓޱͷ Module • ࣗવͱϨΠϠͱϢʔεέʔεʹ͍ͭͯߟྀ͞ΕΔΑ͏ʹ • ؔ৺ྖҬʹ͍ͭͯ͸ըҰతͳղܾํ๏Λఏڙ • HTTPϨεϙϯεɾೝূɾόϦσʔλɾྫ֎ϕʔεͷҟৗܥ؅ཧɾϩά • ҰํͰଞͷϑϨʔϜϫʔΫʹ͸͋Δ͕ຊ࣭తͰͳ͍΋ͷ͸ແؔ৺ • ίΞʹ͸ RDB ΍ NoSQL ΁ͷػೳ͸ଘࡏ͠ͳ͍(௥Ճ͸Մೳ) ʮඞཁͳ΋ͷΛબ୒͢Δ͚ͩͰɺࣗવͱNestΒ͘͠ͳΔʯར఺͕͋Δ
  27. Progressive Ecosystem • NestJS ͸ίΞʹ͸ͳ͍͕ΦϑΟγϟϧͷύοέʔδ͕େྔʹ͋Δ • σʔλετΞ: TypeORM / Sequalize

    / Mongoose • IDL / Server: GraphQL / gRPC • For starter: Nest CLI • Utilities: Swagger(Open API) / Compodoc / • ։ൃऀ͕ NestJS ʹίΞҎ֎ΛͲ͜·ͰٻΊΔ͔͸ఆٛͰ͖Δ • ϑϧελοΫͰ͸ͳ͘ɺελʔτ࣌ʹղܾ͞Ε͍ͯΔ՝୊͕ଟ͍͚ͩ جຊతͳΞʔΩςΫνϟ͕९क͞ΕͨதͰɺ࠷దͳπʔϧΛ૊Έସ͑ΒΕΔ
  28. Topics 1. ͸͡Ίʹ 2. αʔόʔαΠυ Node.js ͷ՝୊ 3. ͳͥ NestJS

    ͳͷ͔ɻಛ௃ͱັྗ 4. αʔόʔαΠυ Node.js ͷੈքͰ NestJS ʹظ଴͞ΕΔ΋ͷ
  29. ࢲݟͰ͢

  30. αʔόʔαΠυ Node ͕ඞཁͳঢ়گʹ͍ͭͯ • ϓϥοτϑΥʔϜͷ໰୊ • Cloud Native ready ͳ૊৫Ͱ͸ͳ͘

    FaaS ͕ར༻Ͱ͖ͳ͍ • ্ཱ͕ͪΓ͕ϔϏʔͳ΋ͷͷಈ࡞Λཁٻ͞ΕΔ • ։ൃϝϯόʔͷ՝୊ • JavaScript(TypeScript) ͕ୈҰݴޠͷϝϯόʔ͕த৺ • ͍ΘΏΔόοΫΤϯυͷઃܭʹ׳Ε͍ͯΔਓ͕͍Δ͔΋Θ͔Βͳ͍ • ٕज़ؒͷࠩҟΛٵऩ͍ͨ͠ • BFF ͰϑϩϯτΤϯυͱ͸ JSON ͰɺMicroServices ͱ͸ gRPC Ͱ
  31. NestJS ͕͏·͘ڹ͘ϙΠϯτʹ͍ͭͯ • Opinionated ͳ Architecture ʹΑͬͯΈΜͳͰಉ͡౔୆ʹཱͯΔ • ໪࿦ NestJS

    ʹ͍ͭͯͷ஌͕ࣝ͋Δલఏ • ࠷ߴͷઃܭʹ͸ͳΒͳ͍͔΋͠Εͳ͍͕ɺ੺఺ʹͳΔ͜ͱΛ๷͛Δ • جຊ͸ʮWebʯʹؔ͢ΔྖҬʹͷΈؔ৺Λ࣋ͭ • DAO ΍ ORM ͕ίΞ͔Β֎Ε͍ͯΔͨΊɺݎ࿚ͳ͕Βٕज़Λബ͘ར༻͢ Δ͜ͱ͕Մೳ • ಛʹ BFF ͳͲόϦσʔλʔɾೝূج൫͕͔ͬ͠Γͯ͠ཉ͍͠Έ͍ͨͳ৔ ߹͸͕͜͜ޮ͍ͯ͘Δ
  32. NestJS ΛΦϓγϣϯͷͻͱͭͱͯ͠஌Δ • NestJS ͕͍ͭͰ΋༗ޮͳΘ͚Ͱ͸ͳ͍ • 1ΤϯυϙΠϯτͷ؆୯ͳαϯϓϧʹ NestJS ͸ඞཁͳ͍ •

    ΋ͬͱϢʔεέʔεʹԊͬͨઃܭΛΞʔΩςΫτ͕͢Δ΂͖͔΋͠Εͳ͍ • Ͳ͏࢖͑Δͷ͔ɺ͋Δ͍͸࢖͑ͳ͍ͷ͔Λ஌͓ͬͯ͘͜ͱ͕େ੾ • ͦ΋ͦ΋ NestJS ͕Ͳ͏͍͏ػೳΛ༗͍ͯ͠Δͷ͔ • NestJS ͷΧόʔൣғ͸Ͳ͜·ͰͰɺͲͷΑ͏ʹར༻͞Ε͍ͯΔͷ͔ • Ͳ͏͍ͬͨ࣌ʹ NestJS ͕໾ཱͬͨͷ͔
  33. Continue to main sessions… #nestjs_meetup

  34. Ϣʔβʔάϧʔϓ͔Βͷ͓஌Βͤ

  35. 1. NestJS Λ͸͡ΊΔਓ͕͔᪴ͳ͍͚ͩͷ೔ຊޠࢿྉΛੜΈग़͢ 2. ݱঢ়ଘࡏ͠ͳ͍ࠃ಺Ͱͷʮݱ৔ͷφϚͷ੠ʯ͕ڞ༗Ͱ͖Δ৔Λͭ͘Δ 3. NestJS Λར༻͢΂͖ͱ͖ɾ͢΂͖Ͱͳ͍࣌ͷ൑அج४Λ૿΍͢ NestJS ͕ඞཁͳਓʹे෼ʹಧ͘·ͰΛαϙʔτ͢Δ

  36. https://qiita.com/advent-calendar/2019/nestjs

  37. https://nestjs.com/

  38. https://discord.gg/qUdzdDH

  39. https://nest-jp.connpass.com

  40. NestJS JP Λ͓ئ͍͍ͨ͠·͢