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
ニュースレターつき会員制メディア作成サービス Medy における TypeScript 活用
Search
Satoru Takanami
December 17, 2021
Programming
0
360
ニュースレターつき会員制メディア作成サービス Medy における TypeScript 活用
2021/12/17 Harajuku.ts Meetup #1
Satoru Takanami
December 17, 2021
Tweet
Share
Other Decks in Programming
See All in Programming
AI Coding Meetup #3 - 導入セッション / ai-coding-meetup-3
izumin5210
0
2.4k
NixOS + Kubernetesで構築する自宅サーバーのすべて
ichi_h3
0
530
XP, Testing and ninja testing ZOZ5
m_seki
3
600
CSC509 Lecture 05
javiergs
PRO
0
300
Devvox Belgium - Agentic AI Patterns
kdubois
1
110
いま中途半端なSwift 6対応をするより、Default ActorやApproachable Concurrencyを有効にしてからでいいんじゃない?
yimajo
2
400
チームの境界をブチ抜いていけ
tokai235
0
160
止められない医療アプリ、そっと Swift 6 へ
medley
1
150
育てるアーキテクチャ:戦い抜くPythonマイクロサービスの設計と進化戦略
fujidomoe
1
170
Pull-Requestの内容を1クリックで動作確認可能にするワークフロー
natmark
2
490
Web Components で実現する Hotwire とフロントエンドフレームワークの橋渡し / Bridging with Web Components
da1chi
3
2k
GraphQL×Railsアプリのデータベース負荷分散 - 月間3,000万人利用サービスを無停止で
koxya
1
1.2k
Featured
See All Featured
KATA
mclloyd
32
15k
RailsConf 2023
tenderlove
30
1.2k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
53k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.5k
Visualization
eitanlees
148
16k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
How to Think Like a Performance Engineer
csswizardry
27
2k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.7k
Transcript
Title yyyy/mm/dd ニュースレターつき会員制メディア作成サービス Medy における TypeScript 活用 2021/12/17 Harajuku.ts Meetup
#1
Spectra, Inc. Spectra, Inc. 自己紹介 2 storz / Satoru Takanami
• スキル: Go, TypeScript, GCP • 経歴 ◦ 2017-2019: メルカリグループ ▪ ソウゾウ • 本に特化した売買アプリ ▪ メルペイ • QR コード決済 ◦ 2020-: Spectra ▪ 自社サービス「Medy」 ▪ DX 支援
Spectra, Inc. Agenda • Medy の話 ◦ サービスの紹介 ◦ アプリケーションアーキテクチャ説明
◦ インフラ構成図解 • Apache Thrift x TypeScript • Next.js x TypeScript • React x TypeScirpt 3
Spectra, Inc. Medy のサービス紹介 4 01
Spectra, Inc. Medy について(宣伝) 5 自分専用のメディアを持ちニュースレター形式で運営できるメディアサービスです。
Spectra, Inc. Medy について(宣伝) 6 ブログ × メルマガのような形態。 ブログ :オープンさ,
ソーシャルとの連携 メルマガ:クローズさ, 直接手元に届ける のメリットを組み合わせ読者と関係性を作る、セミクローズドな発信スタイル・メディアの種類です。 WEB上の記事公開 × メールで記事を直接届け、コミュニティ形成・収益化へ。
Spectra, Inc. アプリケーションアーキテクチャ説明 #1 • モノレポです • 以下のようなモジュールがあります ◦ web
▪ FE アプリケーションサーバ • UA 上で動作するアプリケーションを配布 ◦ backend ▪ Web アプリケーションサーバ • GraphQL I/F • BE アプリケーション ◦ その他 ▪ Apache Thrift 定義 / Cloud Functions コード / MkDocs (ドキュメン ト) 7
Spectra, Inc. アプリケーションアーキテクチャ説明 #2 • 技術スタック ◦ web ▪ TypeScript,
React, Next.js, Apollo Client, Tailwind CSS ◦ backend ▪ Go, gqlgen ◦ その他 ▪ Apache Thrift (TypeScript, Go コード生成) 8
Spectra, Inc. インフラ構成(簡略版) 9 • 主に Google Cloud で構成しています •
Web では Next.js (Server) が 動作しています ◦ SSG / 静的ファイルの配信 ◦ SSR
Spectra, Inc. Medy での TypeScript 活用例 10 02
Spectra, Inc. Apache Thrift x TypeScript • Apache Thrift ◦
Meta (旧 Facebook) で開発されたクロスランゲージな RPC フレームワー ク ▪ https://thrift.apache.org/ • Medy での用途 ◦ モジュールを跨いで共有したい値があるときなどに利用 ◦ 他にもシリアライゼーションの機能など 11
Spectra, Inc. Apache Thrift x TypeScript • モジュールを跨いで共有したい値があるとき ◦ 認証トークンを載せる
HTTP header name ▪ e.g. “X-HOGE-TOKEN” といった文字列 ◦ GraphQL query/mutation が返すエラーコード ▪ 特定のエラーを Web 側でハンドルしたい場合がある 12
Spectra, Inc. Apache Thrift x TypeScript 13 enum の生成例 errors.thrift
errors.js errors.d.ts
Spectra, Inc. Apache Thrift x TypeScript • シリアライゼーション機能の利用 ◦ Identity
Platform で発生したイベントを Cloud Function (TypeScript) で 受けて Backend に伝えたかった • Identity Platform? ◦ ≒ Firebase Authentication ▪ SDK も共通 ◦ SLA が設定されているなどよりエンタープライズ向け 14
Spectra, Inc. Apache Thrift x TypeScript • Identity Platform のイベントを
シリアライズする様子 15 他の言語(e.g Go)で デシリアライズできる
Spectra, Inc. Spectra, Inc. 16 Next.js x TypeScript • プロジェクトルートに
tsconfig.json を設置してビルドするだけで 動作するので導入は楽 • .js を徐々に .tsx に置き換えていけばいい(たぶん) • ビルトインでいくつか type のサポートがある ◦ GetStaticProps, GetStaticPaths, and GetServerSideProps • next.config.js の型チェックができる ◦ ただし IDE 上での動作 https://nextjs.org/docs/basic-features/typescript
Spectra, Inc. Spectra, Inc. 17 React x TypeScirpt • React.ComponentProps
◦ コンポーネントのプロパティを type 定義に再利用できる ◦ Index signatures `T[K]` を 利用してフィールドごとの type を取り出すのも便利
None