An use case and development tips of cloud functions at Ginco inc

386f5d10f65260aeaa51e64afa749b10?s=47 Soichi Sumi
January 17, 2019

An use case and development tips of cloud functions at Ginco inc

GincoにおけるCloud Functionsの
利用事例と開発tipsの紹介

Firebase Meetup #9 Cloud Functions Day
presentation slide
https://firebase-community.connpass.com/event/110958/

386f5d10f65260aeaa51e64afa749b10?s=128

Soichi Sumi

January 17, 2019
Tweet

Transcript

  1. (JODPʹ͓͚Δ$MPVE'VODUJPOTͷ ར༻ࣄྫͱ։ൃUJQTͷ঺հ Soichi Sumi / @soichisumi 2019 / 01 /

    17 / THU Firebase Meetup #9
  2. A B O U T M Y S E L

    F ࣗݾ঺հ Soichi Sumi @soichisumi ɾ#BDLFOE&OHJOFFS!(JODP ɾ࢓ࣄ಺༰ ɹɾόοΫΤϯυͷ։ൃ 'JSFCBTF(P (,&  ɹɾϒϩοΫνΣʔϯΠϯϑϥͷӡ༻ ɹɾࣾ಺'JSFCBTF͓͡͞Μ
  3. (JODPͱ͸

  4. ©2019 Ginco, Inc. Wallet ΢ΥϨοτΛओ࣠ͱ͢Δଟ֯తͳࣄۀల։ Solutions Mining ҆৺ɾ҆શͷ Ծ૝௨՟΢ΥϨοτ ϒϩοΫνΣʔϯͷ

    αʔϏε։ൃˍ࣮ূ࣮ݧ αϙʔτ ϞϯΰϧͰͷ Ծ૝௨՟ϚΠχϯά
  5. ©2019 Ginco, Inc. Crypto Wallet

  6. ©2018 Ginco, Inc. ·ͱΊͯͻͱͭʹ Bitcoin Bitcoin Cash Litecoin XRP Ethereum

    Classic Ethereum
  7. ©2018 Ginco, Inc. ϢʔβʔϑϨϯυϦʔͳσβΠϯ

  8. ©2019 Ginco, Inc. ΫϥΠΞϯτܕ΢ΥϨοτͷجຊΛ஧࣮ʹ ߴਫ४ͷηΩϡϦςΟͱ҆શੑ ֤σόΠεͷ தʹͷΈอ؅ ̍ͭͷόοΫΞοϓΩʔͰ
 ෳ਺ͷ௨՟Λ؅ཧ ௨৴ͷ҉߸Խͱ

    ಠࣗͷೝূํࣜ ൿີ伴ͷ؅ཧํࣜ ΢ΥϨοτͷߏ଄ ௨৴ํࣜ
  9. ©2019 Ginco, Inc. ಠࣗͷݎ࿚ͳΠϯϑϥ Node શͯͷϒϩοΫνΣʔϯ ϊʔυΛࣗΒཱͯΔ Block Explorer ϒϩοΫΤΫεϓϩʔϥΛ

    ࣗ෼ୡͰ࡞Δ Scalability ߴ͍εέʔϥϏϦςΟΛ ֬อ
  10. (JODPͷઆ໌͸Ҏ্

  11. ࠓ೔࿩͢͜ͱ  (JODPʹ͓͚Δ$MPVE'VODUJPOTͷར༻ࣄྫ • ։ൃνʔϜ • $MPVE'VODUJPOTͷ༻్ • ύϑΥʔϚϯεͱίετ 

    ։ൃUJQT
  12. (JODPʹ͓͚Δ $MPVE'VODUJPOTͷར༻ࣄྫ P A R T 1

  13. ঺հ͢Δ಺༰ • ։ൃνʔϜ • $MPVE'VODUJPOTͷ༻్ • ύϑΥʔϚϯεͱίετ

  14. ։ൃνʔϜ

  15. ։ൃνʔϜ • ΫϥΠΞϯτ • ୲౰ΞϓϦɺ$MPVE'VODUJPOT • J04ਓ ۀ຿ҕୗਓ • "OESPJEਓ

    ۀ຿ҕୗਓ • 8FCਓ • όοΫΤϯυ • ୲౰औҾཤྺγεςϜɺ΢ΥϨοτϥΠϒϥϦɺ ϒϩοΫνΣʔϯϊʔυӡ༻ɺ$MPVE'VODUJPOT • $50 ਓ
  16. $MPVE'VODUJPOTͷ༻్

  17. $MPVE'VODUJPOTͱ͸ • ϑϧϚωʔδυͳؔ਺ͷ࣮ߦ؀ڥ • ؔ਺ͱɺτϦΨʔͱͳΔΠϕϯτΛࢦఆͯ͠"1*Λ࣮૷ ར఺ • τϦΨʔʹର͢ΔॲཧΛॻ͚ͩ͘ɻ؆୯ • ݸʑͷؔ਺͸׬શʹҟͳΔ؀ڥͰ࣮ߦ͞ΕΔ

    • ͋Δؔ਺΁ͷมߋ͕ଞͷؔ਺΁ӨڹΛ༩͑ͳ͍ • ؔ਺ͷ਺͕૿͑ͯ΋ػೳ௥Ճɾमਖ਼͕༰қ • ϦΫΤετʹԠͯ͡Φʔτεέʔϧ • τϦΨʔͷछྨ͕๛෋
  18. ࣮૷ྫ0O3FRVFTUτϦΨʔ JOEFYKT const functions = require(‘firebase-functions'); exports.httpFunc = functions.https.onRequest((req, res)

    => { return res.status(200).json({ result: “result” }); });
  19. (JODPͷػೳ • ૹडۚ • ྆ସ ւ֎ͷΈ  • औҾཤྺ •

    ϙʔτϑΥϦΦ • ௨஌
  20. Functions Cloud ΞʔΩςΫνϟ Messaging Cloud Firestore Cloud Storage Cloud BigQuery

    Engine Kubernetes ֎෦ API Node Blockchain Node Blockchain Blockchain Nodes …
  21. $MPVE'VODUJPOTͷ τϦΨʔͷछྨ

  22. τϦΨʔͷछྨ • )551ؔ਺ • 0O3FRVFTU • 0O$BMM • όοΫάϥ΢ϯυؔ਺ •

    'JSFTUPSF • "OBMZUJDT • 1VC4VC • 4UPSBHF • $SBTIMZUJDT • 3FNPUF$POpH • "VUIFOUJDBUJPO
  23. )551ؔ਺

  24. 0O$BMMτϦΨʔ • ΫϥΠΞϯτ͔Βؔ਺Λ௚઀ݺͼग़ͤΔ • ݺͼग़࣌͠ʹϢʔβͷೝূ৘ใΛ4%,͕ݕূͯ͘͠ΕΔ • Լه༻్Ͱར༻ • ૹۚ YϒϩοΫνΣʔϯ

     • ྆ସ • औҾཤྺͷμ΢ϯϩʔυ • ΄ͱΜͲͷ)551ؔ਺Λ0O$BMMτϦΨʔͰ࣮૷
  25. ࣮૷ྫ0O$BMMτϦΨʔ JOEFYKT ؔ਺Λݺͼग़͢ TXJGU τϦΨʔΛPO$BMMʹࢦఆ let functions = Functions.functions() functions.httpsCallable(“Func1”).call([“data":

    “hoge”]) {(result, error) in } ؔ਺໊ͱύϥϝʔλΛࢦఆ const functions = require('firebase-functions') exports.Func1 = functions.https.onCall((data, ctx) => { // ...... })
  26. Ծ૝௨՟ͷૹۚ • ࢿ࢈͸ΞυϨεʹඥͮ͘ • ྫY'%&G###%D"BG"B⒎'" • ΞυϨεʹ͸ରԠ͢Δൿີ伴͕ଘࡏ͢Δ • ൿີ伴ʹΑΔॺ໊͕͋Ε͹ૹۚͰ͖Δ •

    ԼهखॱͰૹۚ • Ͳ͜΁͍͘ΒૹΔ͔Λࣔ͢τϥϯβΫγϣϯΛ࡞੒ • ൿີ伴Ͱॺ໊ • ॺ໊ࡁΈτϥϯβΫγϣϯΛωοτϫʔΫ΁ૹΔ
  27. ૹۚͷྲྀΕ 59ͷ࡞੒ɾॺ໊ TFOE5SBOTBDUJPO #SPBEDBTU Functions Cloud Node Blockchain

  28. Ծ૝௨՟ͷ྆ସ • Ծ૝௨՟ಉ࢜ͷ྆ସΛߦ͏αʔϏεΛར༻ • ྫDIBOHFMMZ LZCFSOFUXPSL • ࢦఆͷૹۚઌ΁௨՟ΛૹΔͱॴ๬ͷ௨՟ʹฦͬͯ͘Δ࢓૊Έ • ԼهखॱͰ྆ସ

    • ௨՟ϖΞͷϨʔτΛऔಘ ྫ#5$ˠ&5) &5)#5$  • ௨՟ϖΞͱฦۚઌΞυϨεΛૹΓɺૹۚઌΞυϨεΛൃߦ • ૹۚઌΞυϨε΁ૹۚ͢Δ • ฦۚઌΞυϨε΁ॴ๬ͷ௨՟͕ૹΒΕͯ͘Δ
  29. ྆ସͷྲྀΕ QSFQBSF&YDIBOHF #SPBEDBTU TFOE5SBOTBDUJPO $BMM"1* Functions Cloud Exchange API Node

    Blockchain
  30. औҾཤྺͷΤΫεϙʔτ • ֬ఆਃࠂ༻ʹऔҾཤྺΛΤΫεϙʔτͰ͖Δ • ԼهखॱͰΤΫεϙʔτ • औҾཤྺΛऔಘ • ֬ఆਃࠂ༻ϑΥʔϚοτͷ$47ϑΝΠϧʹ੔ܗ •

    ($4΁อଘ • μ΢ϯϩʔυ63-Λฦ͢
  31. ཤྺΤΫεϙʔτͷྲྀΕ औҾཤྺͷऔಘ TBWF$47'JMF EPXOMPBE5Y)JTU Functions Cloud Firestore Cloud Storage Cloud

  32. 0O3FRVFTUτϦΨʔ • )551ϦΫΤετͰؔ਺Λݺͼग़͢ • ϦΫΤετͷݕূΛࣗલͰ࣮૷͢Δඞཁ͕͋Δ • ະೝূϢʔβ΋࢖͏ؔ਺ͷ৔߹ʹར༻ • FYϢʔβ࡞੒ɺ*1νΣοΫ

  33. όοΫάϥ΢ϯυؔ਺

  34. όοΫάϥ΢ϯυؔ਺ͷτϦΨʔ • 'JSFTUPSF • 1VC4VC • 4UPSBHF • "OBMZUJDT •

    $SBTIMZUJDT • 3FNPUF$POpH • "VUIFOUJDBUJPO
  35. $MPVE'JSFTUPSFͱ͸ • εέʔϥϒϧͳ/P42-ܕσʔλϕʔε • εέʔϥϏϦςΟΛ֬อ͠ͳ͕Β΋ڧ੔߹ੑΛ࣋ͭ ར఺ • ΫϥΠΞϯτ͕4%,Λհͯ͠௚઀σʔλΛऔಘͰ͖Δ • σʔλͷΞΫηεݖ͸ηΩϡϦςΟϧʔϧͰίϯτϩʔϧ

    • ϦΞϧλΠϜʹσʔλϕʔεͷมߋΛऔಘͰ͖Δ • 38ͷΦϖϨʔγϣϯ՝ۚ  ͍҆
  36. 'JSFTUPSFτϦΨʔ • υΩϡϝϯτʹมߋ͕͋ͬͨࡍʹؔ਺͕ىಈ • σʔλΛมߋͨ͠ࡍͷॲཧͷڞ௨Խ΍ɺϢʔβݻ༗ͷ σʔλΛͭͷίϨΫγϣϯʹ·ͱΊΔॲཧͷڞ௨Խʹ ༗༻ • ϓογϡ௨஌ʹར༻͍ͯ͠Δ

  37. ϓογϡ௨஌ • ৽͍͠औҾ΍͓஌Β͕ͤ͋ͬͨࡍʹϓογϡ௨஌Λૹ ͍ͬͯΔ • ௨஌ͷ഑৴ʹ͸$MPVE.FTTBHJOHΛར༻

  38. ϓογϡ௨஌ͷ഑৴ • ௨஌Λ༗ޮԽͨ͠Ϣʔβͷ.FTTBHF5PLFOΛ'JSFTUPSF΁อଘ • ৽͍͠औҾ΍͓஌Β͕ͤ͋ͬͨࡍɺϢʔβ͕5PLFOΛอଘ͍ͯ͠Ε ͹௨஌ΛૹΔ ͓ ஌Βͤ  औ

    Ҿ ཤ ྺ ௨஌σʔλ  .TH5PLFO ௨஌ Firestore Cloud Functions Cloud Messaging Cloud
  39. 1VC4VCτϦΨʔ • ࢦఆͨ͠τϐοΫͰϝοηʔδΛड͚औΔͱؔ਺͕ىಈ • Լه༻్ʹར༻͍ͯ͠Δ • ૹۚख਺ྉͷߋ৽ YϒϩοΫνΣʔϯ  •

    'JSFTUPSFͷఆظόοΫΞοϓ • શͯͷؔ਺ͷఆظ࣮ߦ
  40. ૹۚख਺ྉͷߋ৽ • ૹۚʹ͸ख਺ྉ͕ඞཁ • ૹۚ࣌ؒ͸ଞͷૹۚʹൺ΂ͯࣗ෼ͷૹۚख਺ྉ͕Կ൪໨ʹ ߴ͍͔Ͱܾ·Δ • ҆͘ɺૣ͘ૹۚ͢ΔͨΊʹඞཁͳख਺ྉΛఆظతʹ 'JSFTUPSFʹه࿥͍ͯ͠Δ "1*ྫIUUQTCJUDPJOGFFTDPBQJ

  41. ૹۚख਺ྉͷߋ৽ • $MPVE4DIFEVMFSͰఆظతʹϝοηʔδΛૹΔ • "1*ͳͲ͔Β࠷దͳૹۚख਺ྉΛऔಘ • 'JSFTUPSF΁ॻ͖ࠐΉ Firestore Cloud Functions

    Cloud Pub/Sub Cloud Scheduler Cloud ֎෦ API
  42. 'JSFTUPSFͷఆظόοΫΞοϓ • ఆظతʹ'JSFTUPSFͷόοΫΞοϓΛऔ͍ͬͯΔ • όοΫΞοϓʹ͸$MPVE"1*Λ࢖༻ • ($4ͷࢦఆͨ͠όέοτʹόοΫΞοϓϑΝΠϧ͕࡞੒͞ ΕΔ ࢀߟIUUQCJUMZ3UIWS Scheduler

    Cloud Functions Cloud Firestore Cloud Storage Cloud Pub/Sub Cloud Cloud API
  43. 4UPSBHFτϦΨʔ • ࢦఆ͞ΕͨόέοτʹΦϒδΣΫτ͕࡞੒͞ΕΔͱؔ਺ ͕ىಈ • 'JSFTUPSFͷ#JH2VFSZ΁ͷΤΫεϙʔτʹ࢖༻ • ػೳվળͷͨΊͷ෼ੳ΍σόοάʹར༻

  44. 'JSFTUPSFΛ#JH2VFSZ΁ΤΫεϙʔτ • ($4ʹ࡞੒͞ΕͨόοΫΞοϓϑΝΠϧͷ͏ͪɺඞཁͳ΋ ͷΛ#JU2VFSZ΁ΤΫεϙʔτ͢Δ • $MPVE"1*Λར༻ ࢀߟIUUQCJUMZ.HQE6V Storage Cloud Functions

    Cloud Storage Cloud BigQuery Cloud API
  45. "OBMZUJDTτϦΨʔ • ࢦఆ͞ΕͨΠϕϯτ͕"OBMZUJDTʹૹΒΕΔͱؔ਺͕ىಈ • ྫBQQ@PQFO JO@BQQ@QVSDIBTFΠϕϯτͳͲ • ΫϥΠΞϯτ͕Πϕϯτʹ௥Ճͨ͠ύϥϝʔλ΍Ϣʔβ৘ ใΛ࢖ͬͨॲཧΛߦ͑Δ •

    ྫΞϓϦ಺ΞΠςϜΛߪೖͨ͠ϢʔβʹΫʔϙϯΛ෇༩ • ίϯόʔδϣϯΠϕϯτͷ"QQT'MZFS΁ͷૹ৴Λαʔό αΠυͰ·ͱΊͯߦ͏ͨΊʹར༻
  46. "QQT'MZFS΁ͷΠϕϯτͷૹ৴ • ର৅ͷΠϕϯτ͕ૹΒΕΔࣄʹΑΓؔ਺͕ىಈ • 'JSFTUPSFʹ֤Πϕϯτ͕ى͖ͨճ਺Λه࿥ • ࢝ΊͯͷΠϕϯτͳΒ"QQT'MZFS΁ૹ৴ Analytics Firestore Cloud

    Functions Cloud AppsFlyer
  47. $SBTIMZUJDTτϦΨʔ • $SBTIMZUJDTͰJTTVF͕ى͖ͨࡍʹؔ਺͕ىಈ • ৽͘͠JTTVF͕ى͖ͨ৔߹ʹ4MBDL௨஌͢ΔΑ͏ʹ͍ͯ͠Δ

  48. $SBTIMZUJDTͷ௨஌ • $SBTIMZUJDTͷJTTVFʹมԽ͕͋Δͱؔ਺͕ىಈ͢Δ • ؔ਺ʹJTTVFͷ৘ใ͕౉͞ΕΔͷͰɺ੔ܗͯ͠TMBDL΁௨஌ Functions Cloud Crashlytics Slack

  49. ύϑΥʔϚϯεͱίετ

  50. ύϑΥʔϚϯεͷܭଌ • ௚ۙ̍िؒͷؔ਺ͷϨΠςϯγΛ֬ೝ͢Δ • ର৅͸ɺݺͼग़͠ճ਺͕ଟΊͷؔ਺ͭ • ৚݅ • ϦʔδϣϯVTDFOUSBM •

    ޙड़͢Δ$PME4UBSUରࡦΛ࣮ࢪࡁΈ
  51. ύϑΥʔϚϯε • QFSDFOUJMFͰNTdNTఔ౓ • ࠷େTFD͔͔Δ࣌΋

  52. ύϑΥʔϚϯε • QFSDFOUJMFͰNTdNTఔ౓ • ࠷େTFD͔͔Δ࣌΋

  53. ίετ ࢖༻ྔ ྉۚ 'VODUJPOT ສDBMM = 'JSFTUPSF ԯ3FBE ສ8SJUF =ສ

    4UPSBHF  -PHHJOH FUD  =ສ 5PUBM  =ສ ˞݄ؒίετ'JSFCBTFͷΈ • ͔ͳΓ͍҆ɻಛʹ'VODUJPOTͱ'JSFTUPSF • ΋͠7.ͱ%#Λ਺୆ཱͯͯϚϧνϦʔδϣϯʹల։͍ͯͨ͠ Β਺ഒ͔͔Δ
  54. ։ൃtips P A R T 2

  55. $PME4UBSUରࡦΛ͠Α͏ • ؔ਺͸͠͹Β͘࢖ΘΕ͍ͯͳ͍ͱεϦʔϓ͢Δ • εϦʔϓޙɺ࠷ॳͷϦΫΤετͷॲཧʹ͸͕͔͔࣌ؒΔ • ͜ΕΛ$PME4UBSUͱݺͿ • ԼهͭͷରࡦΛߦ͏ͱྑ͍ •

    άϩʔόϧείʔϓͰϞδϡʔϧΛϩʔυ͠ͳ͍ • )551ؔ਺Ͱ'JSFTUPSFΛͳΔ΂͘࢖Θͳ͍ • શͯͷؔ਺Λఆظతʹ࣮ߦ͢Δ ৄ͘͠͸IUUQTCJUMZ.VN9
  56. άϩʔόϧείʔϓͰϞδϡʔϧΛϩʔυ͠ͳ͍ • $MPVE'VODUJPOT͸$PME4UBSU࣌ʹJOEFYKTΛϩʔυ͢Δ • ͭͷؔ਺Λ࣮ߦ͢Δ৔߹ʹ΋શͯͷؔ਺͕ಡΈࠐ·ΕΔ • ࣮ߦ͢Δؔ਺Ҏ֎Λϩʔυ͠ͳ͍Α͏࣮૷͢Δͱྑ͍

  57. JOEFYKT const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase);

    const db = admin.firestore(); module.exports = functions.https .onRequest((req, res)=>{ // ...... }); GVODTGVODKT const functions = require('firebase-functions') const google = require('googleapis'); const rp = require('request-promise'); const projectId = process.env.GCLOUD_PROJECT; module.exports = functions.storage
 .bucket(`${projectId}-bucket`) .object() .onFinalize((obj)=>{ // ...... }); Ͳͷؔ਺Λ࣮ߦ͢Δ৔߹Ͱ΋ ͢΂ͯͷؔ਺͕ϩʔυ͞ΕΔ ࣮૷ྫमਖ਼લ exports.Func1 = require('./funcs/func1'); exports.Func2 = require('./funcs/func2'); exports.Func3 = require(‘./funcs/func3'); ... GVODTGVODKT
  58. JOEFYKT ؔ਺࣮ߦ࣌ʹ͸'6/$5*0/@/".&ʹؔ਺໊͕ೖΔ ͦΕҎ֎ͷ৔߹͸ۭ σϓϩΠ࣌ʹ͸͢΂ͯͷؔ਺͕ϩʔυ͞Εɺ ࣮ߦ࣌ʹ͸࣮ߦର৅ͷؔ਺ͷΈ͕ϩʔυ͞ΕΔʂ const funcName = process.env.FUNCTION_NAME; if

    (!funcName || funcName === 'Func1') { exports.Func1 = require('./funcs/func1'); } if (!funcName || funcName === 'Func2') { exports.Func2 = require('./funcs/func2'); } ... ࣮૷ྫमਖ਼ޙ
  59. )551ؔ਺Ͱ'JSFTUPSFΛͳΔ΂͘࢖Θͳ͍ • 'JSFTUPSF΁ͷॳճͷ઀ଓʹ$PME4UBSU͕͋Δ • HFUʹdඵ͔͔Δ • $MJFOU͔Β௚઀ܨ͛͹جຊతʹෆཁͷ͸ͣͳͷͰͳΔ ΂͘࢖Θͳ͍ํ͕͍͍ • ࢖͏৔߹ɺؔ਺ͷ3VOUJNF͸/PEFʹ

    • $PME4UBSU͕एׯܰݮ͞ΕΔ ࢀߟJTTVFIUUQCJUMZ%CQ"HI
  60. શͯͷؔ਺Λఆظతʹ࣮ߦ͢Δ • ఆظతʹؔ਺Λୟ͘͜ͱͰεϦʔϓΛආ͚ΒΕΔ • -BNCEBͰ͸༗໊ͳख๏ • υΩϡϝϯτʹॻ͔Εͯͳ͍ͷͰਪ঑͞Εͯ͸ͳ͍͔΋ ͠Εͳ͍͕ɺޮՌ͸͋Δ

  61. શͯͷؔ਺Λఆظతʹ࣮ߦ͢Δ • $MPVE"1*ͰσϓϩΠ͞Ε͍ͯΔؔ਺ͷϦετ͕औಘ Ͱ͖ΔͷͰɺશͯͷ)551ؔ਺Λୟ͘ • ִؒ͸෼ఔ౓ ৄࡉIUUQCJUMZTXO[O Scheduler Cloud Pub/Sub

    Cloud Functions Cloud Cloud API
  62. ςετʹpSFCBTFGVODUJPOTUFTUΛ࢖͓͏ • ςετʹ͸pSFCBTFGVODUJPOTUFTU͕ศར • ԼهͷNPDLΛߦͬͯ͘ΕΔ • "ENJO4%,ͷ઀ଓϓϩδΣΫτ • ίϯςΩετΦϒδΣΫτ •

    GVODUJPOTDPOpH
  63. UFTUJOEFYUFTUKT Ͳ ͷ ؔ ਺ Λ ࣮ ߦ ͢ Δ

    ৔ ߹ Ͱ ΋ ͢ ΂ ͯ ͷ ؔ ਺ ͕ ϩ ʔ υ ͞ Ε Δ ࣮૷ྫpSFCBTFGVODUJPOTUFTUͷॳظԽ const test = require('firebase-functions-test')({ databaseURL: 'https://my-project.firebaseio.com', storageBucket: 'my-project.appspot.com', projectId: 'my-project', }, ‘path/to/serviceAccountKey.json’); const mockData = { key: "mocked string" }; // function.config().key -> "mocked string" test.mockConfig(mockData);
  64. JOEFYKT UFTUJOEFYUFTUKT Ͳ ͷ ؔ ਺ Λ ࣮ ߦ ͢

    Δ ৔ ߹ Ͱ ΋ ͢ ΂ ͯ ͷ ؔ ਺ ͕ ϩ ʔ υ ͞ Ε Δ ࣮૷ྫ0O$BMMؔ਺ͷςετ describe("Callable function test sample", () => { const wrapped = test.wrap(myFuncs.CallableFunc); it("Success", () => { const data = { data: "testdata" }; const ctx = { auth: { uid: 'user1' } } const res = wrapped(data, ctx); assert.deepEqual(res, {data: JSON.stringify(data)}); }); }); exports.CallableFunc = functions.https.onCall((data, ctx) => { console.log(`req: ${JSON.stringify(data)}`) return {data: JSON.stringify(data)} });
  65. SFUSZ͸σϑΥϧτͰߦΘΕͳ͍ͷͰ஫ҙ SFUSZϙϦγʔͷJTTVFIUUQTCJUMZ"';ZE • σϑΥϧτͰ͸ؔ਺͕ࣦഊͯ͠΋SFUSZ͞Εͳ͍ • ҰԠɺ($1ͷίϯιʔϧ͔ΒSFUSZ͢ΔΑ͏ઃఆͰ͖Δ • ؔ਺ʹόά͕͋Δͱେྔʹ࣮ߦ͞Εͯ͠·͏ͨΊɺΤϥʔ ϩάΛ࢒ͯ͠ӡ༻ͰΧόʔΛਪ঑ •

    ඵ͝ͱʹSFUSZ ೔੒ޭ͠ͳ͔ͬͨΒऴྃ • SFUSZϙϦγʔΛΧελϚΠζͰ͖ΔΑ͏ରԠதͱͷ͜ͱ
  66. ಉҰ໊ͷؔ਺Λෳ਺ϦʔδϣϯʹσϓϩΠͰ͖ͳ͍ • ݱঢ়Ͱ͸ɺಉҰ໊ͷؔ਺Λෳ਺ϦʔδϣϯʹσϓϩΠͰ͖ͳ͍ • ؔ਺໊ʹQPTUpYΛ͚͖ͭͯͨͨ෼͚ΔରԠ΋Ͱ͖Δ • ྫ(FU%BUB+1 (FU%BUB64 • ࠷ۙɺෳ਺Ϧʔδϣϯ΁ͷσϓϩΠΛαϙʔτ͢Δ13͕Ϛʔδ

    ͞Εͨ JTTVFIUUQCJUMZ'YM82N
  67. ·ͱΊ • Ծ૝௨՟΢ΥϨοτͰͲͷΑ͏ʹ$MPVE'VODUJPOT Λ׆༻͍ͯ͠Δ͔঺հͨ͠ • ΄΅͢΂ͯͷτϦΨʔΛ׆༻ͯ͠։ൃ͍ͯ͠Δ • ։ൃɺӡ༻͢ΔதͰಘΒΕͨUJQTΛ঺հͨ͠  $PME4UBSUରࡦ͠Α͏

     ςετʹ͸pSFCBTFGVODUJPOTUFTUΛ࢖͓͏  SFUSZ͸σϑΥϧτͰߦΘΕͳ͍  ಉҰ໊ͷؔ਺Λෳ਺ϦʔδϣϯʹσϓϩΠͰ͖ͳ͍ ࠓͷॴ