Stubcellを使ってフロントやアプリの開発効率をあげよう

Fe9ce1fc26c929ec0e98d1485894761a?s=47 sussan0416
January 19, 2018

 Stubcellを使ってフロントやアプリの開発効率をあげよう

Fe9ce1fc26c929ec0e98d1485894761a?s=128

sussan0416

January 19, 2018
Tweet

Transcript

  1. StubcellΛ࢖ͬͯ ϑϩϯτ΍ΞϓϦͷ ։ൃޮ཰Λ͋͛Α͏ @sussan_0416 2017/01/19ɹएखΤϯδχΞLT #3

  2. ླ໦޹޺ʢ@sussan_0416ʣ • 2015೥৽ଔೖࣾʢ3೥໨ ·ͩएखʣ • Android/iOSΞϓϦΤϯδχΞ
 ʢJava, Kotlin, Swiftʣ •

    ݱࡏ͸ɺ޿ࠂ഑৴Λ࠷దԽ͢Δػց ֶशΛ୲౰
 ʢpython, Dataflow, PHP etc..ʣ 
  3. ֓ཁ 1. ϑϩϯτଆ։ൃ͋Δ͋Δͷ࿩ 2. Stubcellͷಋೖํ๏ͱ࢖͍ํ 3. StubcellΛࣾ಺Ͱ࢖ͬͨࣄྫ 

  4. ϑϩϯτ΍ΞϓϦͷ։ൃͰ 

  5. Α͋͘Δʮ΋΍΋΍ʯ 

  6. 1. APIΑΓϑϩϯτͷ։ൃ͕ ઌߦͪ͠Όͬͨ 

  7. 2. σόοά͍͚ͨ͠Ͳ API͔Βҙਤͨ͠Ϩεϙϯε͕ ฦͬͯ͜ͳ͍ 

  8. 3. ֎෦ͷAPIΛ࢖͍ͬͯͯɺ SandboxϞʔυ͕ແ͍ 

  9. ։ൃͰΑ͋͘ΔϞϠϞϠ • APIΑΓϑϩϯτ͕։ൃઌߦͨ͠
 ˠ ͤΊͯURI͚ͩͰ΋༻ҙ͠ͱ͍ͯ΄͍͠ʂ • API͔Βҙਤͨ͠Ϩεϙϯε͕ฦͬͯ͜ͳ͍
 ˠ ϥϯμϜੑͷ͋Δ΋ͷͳͲ͸ݕূ͕ࠔ೉ʂ •

    SandboxϞʔυ͕ແ͍
 ˠ ֎෦ͩͬͨΒͳ͓͞Β೉͍͠ 
  10. APIΛϞοΫͨ͠Βղܾʂ 

  11. Stubcell ͬͯͷ͕͋ΔΒ͍͠  Stubcell https://github.com/yosuke-furukawa/stubcell

  12. Stubcell • JSONΛฦ͢͜ͱʹಛԽͨ͠stubαʔόʔ • Ϩεϙϯε಺༰Λఆٛ͢ΔϑΝΠϧʹɺίϝ ϯτΛॻ͖ࠐΊΔʢJSON5ରԠʣ Stubcell ϞοΫ͍ͯ͠ͳ͍URI͸ɺຊདྷͷAPIʹϦΫΤετ͢Δ ϞοΫͨ͠URI͸ɺStubcell͔ΒϨεϙϯε 

  13. ಋೖํ๏ 

  14. npmͰΠϯετʔϧ $ npm -g install stubcell npm WARN deprecated node-uuid@1.4.8:

    Use uuid module instead /usr/local/bin/stubcell -> /usr/local/lib/node_modules/stubcell/bin/ stubcell.js + stubcell@0.8.3 added 110 packages in 14.713s 
  15. ࢖͍ํ͸3εςοϓ! • entry.yamlΛॻ͘ʢStubαʔόͷઃఆʣ • ֤URIͷϨεϙϯεΛςΩετϑΝΠϧʹॻ͘ • ίϚϯυϥΠϯ͔Βىಈ͢Δ 

  16. ͔ΜͨΜ! 

  17. entry.yamlʢجຊྫʣ # جຊ - request: url: /hoge method: get response:

    status: 200 file: hoge.json # ௚઀ϨεϙϯεΛॻ͍ͨྫ - request: url: /fuga method: get response: status: 200 body: '{"text": ";͕ͩͶ"}' ←/hogeͷϦΫΤετʹ͸ ɹhoge.jsonͷ಺༰Λฦ͢ ʢී௨ͷςΩετͰ΋OKʣ ←bodyύϥϝʔλʹ ɹ௚઀ॻ͍ͨྫ 
  18. ͋ͱ͸ىಈ͢Δ͚ͩ $ stubcell Listening on 8090 entry yaml is /Users/ta_suzuki/Documents/stubcell/entry.yaml

    silent is false record proxy is undefined loose compare undefined $ stubcell --port 3000ɹɹˡ ϙʔτͷࢦఆ $ stubcell --entry ./entry.yamlɹɹˡ entryϑΝΠϧͷࢦఆ $ stubcell --record_target http://echo.jsontest.comɹɹˡ αʔόͷࢦఆ 
  19. ͔ΜͨΜ!! γϯϓϧ!! 

  20. ࣾ಺Ͱ࢖ͬͨࣄྫ 

  21. εϚϗΞϓϦ։ൃ Stubcell PC γϛϡϨʔλ ։ൃAPI ։ൃதͷURIΛϞοΫ ։ൃࡁΈͷURI͸௨ա ։ൃதͷURIΛϞοΫͯ͠ɺ։ൃޮ཰Λ্͛Δྫ APIଆͷ։ൃͷਐḿʹӨڹ͞Εͣɺϑϩϯτଆͷ։ൃΛਐΊΒΕΔΑ͏ʹͳͬͨ!! 

  22. ֎෦API΋ར༻ͷϑϩϯτ։ൃ ։ൃAPI ֎෦API Stubcell PC ֎෦ͷAPIΛ࢖༻͍ͯ͠ΔՕॴΛϞοΫͯ͠ɺ։ൃޮ཰Λ্͛Δྫ ِ૷ͨ͠JSONΛฦ͢ ΋͸΍઀ଓ͠ͳ͍ ֎෦APIͷϨεϙϯεΛِ૷Ͱ͖Δ͔Βɺσόοά͠΍͘͢ͳͬͨ!! 

  23. ಋೖͯ͠Α͔ͬͨ͜ͱ • APIଆͷ։ൃͷਐḿʹ͔͔ΘΒͣҰ௨Γͷಈ࡞ ֬ೝ͕Ͱ͖Δ • ҙਤͨ͠ϨεϙϯεΛฦͤΔ͔Βσόοά͠΍ ͍͢ • entry.yaml΍Ϩεϙϯεͷ಺༰͸࢓༷ॻʹͳΔ ͠ɺςΩετఆ͔ٛͩΒgit؅ཧ͠΍͍͢

    
  24. ·ͱΊ • ։ൃதʹΑ͋͘Δʮ΋΍΋΍ʯ
 APIͷ։ൃঢ়گ΍ɺ֎෦ͷAPIͷڍಈʹӨڹ͞Εͣʹ։ൃ͍ͨ͠ͱ͖ͬͯ͋ΔΑͶ • StubcellΛ࢖͏ͱɺAPIΛϞοΫͰ͖ͯศར
 npm -g install stubcell


    entry.yamlΛॻ͘ɺϨεϙϯεΛϑΝΠϧʹॻ͘ɺstubcellͰىಈ͢Δ • StubcellΛࣾ಺Ͱ࢖ͬͨࣄྫ
 εϚϗΞϓϦ։ൃͱ֎෦APIΛ࢖ͬͨϑϩϯτΞϓϦͷࣄྫΛ঺հ