NestJSを活用したREST APIサーバ/REST_API_SERVER_BY_NESTJS

7ce46cdba50db99f3403024fe2519c91?s=47 Masahiko Sakakibara
November 29, 2019
620

NestJSを活用したREST APIサーバ/REST_API_SERVER_BY_NESTJS

7ce46cdba50db99f3403024fe2519c91?s=128

Masahiko Sakakibara

November 29, 2019
Tweet

Transcript

  1. /FTU+4Λ׆༻ͨ͠ 3&45"1*αʔό

  2. ࣗݾ঺հ !SEMBCP Ұൠࣾஂ๏ਓ ϦϨʔγϣϯσβΠϯݚڀॴ୅දཧࣄ Ұൠࣾஂ๏ਓ "SFB*OOPWBUJPO"MJBODF$50 *POJD+BQBO 6TFS(SPVQ୅ද

  3. ίϯτϦϏϡʔλʔ ionic-team/ionic ionic-team/starters ionic-team/ionic-cli ionic-team/ionic-docs ionic-team/ionic-react -conference-app GoogleChrome/lighthouse

  4. όοΫΤϯυͱϑϩϯτΤϯυͷͭͳ͗ํ

  5. ϨϯμϦϯάίετ͕ॏ͍ಈతαΠτ  .PEFMͰσʔλΛ੔ܗͯ͠  ৔߹ʹΑͬͯ͸$PUSPMMFSͰ ͦΕΛల։ɾ࠶੔ܗͯ͠  7JFXͰల։͢Δ

  6. ΤϥʔϋϯυϦϯά͕೉͍͠ಈతαΠτ

  7. ΑΓΑ͍69Λ໨ࢦͯ͠ ੩తαΠτ 4JOHMF1BHF"QQMJDBUJPO 41"   3&45"1*(SBQI2-ʹΑΔόοΫΤ ϯυͱϑϩϯτΤϯυͷϒϦοδ  +BWB4DSJQUʹΑΔϦονͳ6*

    1SPHSFTTJWF8FC"QQT 18"  41" 8FC"1* ಈతαΠτ ΑΓΑ͍69Λ໨ࢦ͢
  8. +40/Ͱͷ΍ΓͱΓ͕Ұൠతͳख๏ʹɻ όοΫΤϯυ \n^ ϑϩϯτΤϯυ \n^

  9. +40/Ͱൃ࿩͢Δͱ͍͏Ҏ্ͷ৘ใ͸ڞ༗Ͱ͖͍ͯ·͔͢ʁ όοΫΤϯυ \n^ ϑϩϯτΤϯυ \n^ ѫࡰͯ͠΄͍͠ (&5IFMMP ʁʁ 3&45Ͱ͸ɺॲཧํ๏ͱ෼ྨ͔͠ఆٛͯ͘͠Εͳ͍໰୊ɻ

  10. ཧ૝ͷੈք όοΫΤϯυ \n^ \ OBNFTUSJOH EFTDTUSJOH JNBHFTUSJOH VSMTUSJOH ^<> ͰσʔλΛૹΔˠ

    ϑϩϯτΤϯυ \n^ \ OBNFTUSJOH EFTDTUSJOH JNBHFTUSJOH VSMTUSJOH ^<> Ͱσʔλ͕ཉ͍͠ ˡ
  11. ͦ͏ͩ5ZQF4DSJQUͩʂ w"1*ͷܕΛڞ༗Ͱ͖Δͷ͸5ZQF4DSJQU͚ͩʢ  wFYQSFTT͸ϑϨʔϜϫʔΫͱͯ͠͸ͪΐͬͱബ͍ w/FTU+4͸ϑϨʔϜϫʔΫͱͯ͠ͷػೳ͕े෼ ɾ3&45"1*Λ࠾༻ͯ͠Δ ɾৄࡉυΩϡϝϯτͱͷೋॏ؅ཧΛͨ͘͠ͳ͍ ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹʜϓϩδΣΫτͰΦεεϝ 8FC"TTFNCMZͳͲͷಈ࡞؀ڥΛআ͖·͢

  12. ܕͷڞ༗ʹ͍ͭͯ

  13. ͡Ό͋Ͳ͏΍ͬͯܕΛڞ༗͢Δʁʁ όοΫΤϯυ \n^ ϑϩϯτΤϯυ \n^ Ͳ͏΍ͬͯܕΛڞ༗ʁ OQNύοέʔδʹ͢Δ ˕ ཧ૝తɻͨͩ͠อक͕खؒɻ /FTU+4ͷϓϩδΣΫτʹ

    ஔ͘ ̋ ݱ࣮తɻϑϩϯτΤϯυ͔Β͸
 webpackͰόϯυϧ ϓϩδΣΫτ֎ʹ͓͘ ˚ tscίϚϯυͷઃఆΛཁมߋʢະௐࠪʣ
  14. σϞ ʢձ৔ͰͷܕΤϥʔͷ࣮ԋʹͳΓ·͢ʣ

  15. XFCQBDLͱUTDίϚϯυ͸ҧ͏ XFCQBDL όϯυϥʔɻUZQFTDSJQUύοέʔδΛར༻͢Δ͜ͱͰɺSFRVJSFؔ਺΍ JNQPSUؔ਺Λఏڙͯ͠ґଘؔ܎ղܾࡁΈͷγϯϓϧͳϑΝΠϧΛग़ྗ͢Δ ͜ͱ͕Ͱ͖Δɻ UTDίϚϯυ 5ZQF4DSJQU͔Β+BWB4DSJQU΁ͷίϯύΠϧΛߦ͏ɻґଘؔ܎ग़ྗͷղܾͳ ʹͦΕɻίϯύΠϥͰ͢ɻ

  16. CBEQSBDUJDFUPJOTUBMMEFQFOEFODJFTPOBQSPEVDUJPOTFSWFS IUUQTHJUIVCDPNHPMECFSHZPOJOPEFCFTUQSBDUJDFTJTTVFT

  17. *EPOPUSFDPNNFOEVTJOHBOZCVOEMFSGPS/PEF IUUQTHJUIVCDPNOFTUKTOFTUJTTVFTJTTVFDPNNFOU

  18. "1*ͳΒ࣌ؒಈ͔͞ͳͯ͘΋͍͍ͷͰ͸ ʢ4FSWFSͷอकͨ͘͠ͳ͍ʂʣ

  19. ৗʹΞΫηε͕͋Δͱ͸ݶΒͳ͍ load() { if (this.data) { return of(this.data); } else

    { return this.http.get<IDataJson>(‘https://example.com‘)
 .pipe(map(this.processData, this)); } } ϝϞϦ΍ετϨʔδΛ ׆༻ͨ͠Γ FϥʔχϯάΈ͍ͨʹ සൟͳ"1*ߋ৽͕ͳ͍
  20. ͦ͏ͩʂ-BNCEBͩʂʂ ʮίʔυͷอकͰखҰഋ͔ͩΒαʔόͷอकͨ͘͠ͳ͍ʯ

  21. /PEPDTGSPN ʜͭ͘Εͦ͏͡Όͳ͍ʁ

  22. ͭ͘Εͨɻ ࠓ೔.FFUVQ͋Δ͔Β൒೥ͿΓʹόʔδϣϯ௥ਵͨ͠

  23. ࢖͍ํ $ npm install serverless -g $ git clone git@github.com:rdlabo/serverless-nestjs.git

    ʲprojectNameʳ Πϯετʔϧ ։ൃ $ npm start -BNCEB)PUTUBSUαϙʔτ 4XBHHFSαϙʔτ $ npx ts-node src/swagger.ts
  24. ϑϩϯτΤϯυͱόοΫΤϯυͰڞ௨ݴޠΛ खʹೖΕΑ͏ɻ ϩδΧϧʹָͰ͖Δ/FTU+4͍͍Ͱ͢Α

  25. *POJDΛ࢖͏ͱ8FCͰϞόΠϧΞϓϦͭ͘Ε·͢ ϒϥ΢β 18" J04ΞϓϦ

  26. ͜͏͍͏ΞϓϦ͕೔ʹͭ͘ΕΔΑ͏ʹʂ

  27. *POJDͰ࡞ΔϞόΠϧΞϓϦ੍࡞ೖ໳ ୯ߦຊr ϖʔδɹ ԁ IUUQTBN[OUP1"S&M