Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Firebase Japan User Group - meetup #9
Search
kappa0923
January 17, 2019
Programming
800
1
Share
Firebase Japan User Group - meetup #9
kappa0923
January 17, 2019
Other Decks in Programming
See All in Programming
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
340
CSC307 Lecture 17
javiergs
PRO
0
310
ふつうのFeature Flag実践入門
irof
7
3.5k
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
4
450
AI駆動開発勉強会 広島支部 第一回勉強会 AI駆動開発概要とワークショップ
hayatoshimiu
0
430
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
440
New "Type" system on PicoRuby
pocke
1
430
AIとRubyの静的型付け
ukin0k0
0
510
RTSPクライアントを自作してみた話
simotin13
0
430
Modding RubyKaigi for Myself
yui_knk
0
860
net-httpのHTTP/2対応について
naruse
0
420
プロパティの順序で型推論が壊れる!? TypeScript6.0の修正からContext-Sensitivityの仕組みを追う
bicstone
2
1.3k
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
15k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
270
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Discover your Explorer Soul
emna__ayadi
2
1.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
How to build a perfect <img>
jonoalderson
1
5.6k
30 Presentation Tips
portentint
PRO
1
310
Abbi's Birthday
coloredviolet
2
7.8k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
350
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Transcript
Cloud FunctionsでURL短縮 サービスを作ろう! Firebase Meetup #9 Cloud Functions Day @Google
kappa0923
Agenda ▸ 自己紹介 ▸ Cloud Functionsで何を作るか? ▸ どうやって作るのか ▸ ついでにCIも考える
▸ まとめ 2
Self Introduction ▸ 渡辺 友康 ▹ kappa0923 ▸ 株式会社アイソルート クラウドソリューショングループ所属
▹ クラウド周りのアーキテクトやってます ▸ SNS ▹ GitHub : kappa0923 ▹ Twitter : @tom_kappa0923 ▸ Other ▹ GDG Tokyo オーガナイザー 3
今日のターゲット 4 経験者 初学者 この辺
Cloud Functionsで 何を作るか?
何を作るか? URL短縮サービスを作ります! ↓ https://nabe.ga/ 6
何を作るか? なんで? 7
何を作るか? GitHubにCloudFunctionsを利用した URL短縮のサンプルがあった https://github.com/firebase/functions-samples/t ree/Node-8/url-shortener けどBit.lyのAPIを使ってる。。。 8
何を作るか? これなら自分で作っても良いのでは
どうやって作るか
どうやって作るか 11 ▸ Cloud FunctionsでCloud Firestoreから リダイレクト先のURLを読み込み、 301リダイレクトのレスポンスをすればOK
どうやって作るか 12 ▸ リダイレクトの処理はFunctionsの 関数を呼び出すように、firebase.jsonに rewrite設定をしておく ▸ これで独自ドメインで関数が呼び出せる
どうやって作るか 13 ▸ Firestoreからの読み込みにはFunctionsで Firebase Admin SDKを使うので FirestoreのルールはロックモードでOK!
どうやって作るか 14 ▸ でもFunctionsの実行回数が心配。。。 ▸ なら、キャッシュさせてしまおう! cf. https://firebase.google.com/docs/hosting/functions?hl=ja#manage_cach e_behavior
ついでにCIも考える
ついでにCIも考える 16 ▸ せっかくなのでCIも実現しよう! cf. https://www.isoroot.jp/blog/1349/ ▸ GOOGLE_APPLICATION_CREDENTIALSを 使ってサービスアカウントでデプロイする cf.
https://github.com/firebase/firebase-tools/releases/tag/v6.1.0 ▸ 注意 : Firebase Hosting APIを有効にしておく必要あり
ついでにCIも考える 17 ▸ CircleCIだとこんな感じ
ついでにCIも考える 18 ▸ Hostingのデプロイは成功するのに Functionsのデプロイに失敗する。。。 ▸ どうやらバグらしい https://github.com/firebase/firebase-tools/issues/787 ▸
まとめ
まとめ 20 ▸ Cloud FunctionsとHostingのちょっと 変わった使い方を紹介しました ▸ 節約のためにCacheは上手く使いましょう ▸ Firebaseは小さいプロダクトを素早く試すのに◎
いろいろ作ってみよう!
お疲れ様でした 何か質問があれば