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
5分でわかる! VaporでAPI+DB構築
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Kaito Kudo
October 10, 2025
Programming
110
0
Share
5分でわかる! VaporでAPI+DB構築
Kaito Kudo
October 10, 2025
More Decks by Kaito Kudo
See All by Kaito Kudo
未来大LT_2025.pdf
kaitokudou
0
73
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
470
iOSDC Japan 2022 スポンサーセッション
kaitokudou
0
2k
iOS勉強会資料
kaitokudou
0
120
App Storeにアプリをリリースした話
kaitokudou
0
48
Other Decks in Programming
See All in Programming
感情を設計する
ichimichi
5
1.6k
TiDBのアーキテクチャから学ぶ分散システム入門 〜MySQL互換のNewSQLは何を解決するのか〜 / tidb-architecture-study
dznbk
1
190
AWSコミュニティ活動は顧客のクラウド推進に効くのか / Do AWS community activities help customers adopt the cloud?
seike460
PRO
0
150
Claude Codeをカスタムして自分だけのClaude Codeを作ろう
terisuke
0
150
Liberating Ruby's Parser from Lexer Hacks
ydah
2
2.2k
Back to the roots of date
jinroq
0
490
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
1.3k
의존성 주입과 모듈화
fornewid
0
150
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
730
Making the RBS Parser Faster
soutaro
0
540
t *testing.T は どこからやってくるの?
otakakot
1
760
Kingdom of the Machine
yui_knk
2
960
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
900
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
220
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
A better future with KSS
kneath
240
18k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
680
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Are puppies a ranking factor?
jonoalderson
1
3.3k
The Language of Interfaces
destraynor
162
26k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
How GitHub (no longer) Works
holman
316
150k
Transcript
5ͰΘ͔Δʂ VaporͰAPI+DBߏங 2025/10/10 DroidKaigi & iOSDC After Talks Night ͘Ͳ͔͍
ࣗݾհ גࣜձࣾΏΊΈ/͘Ͳ͔͍ 2022/04ʹiOSΤϯδχΞͱͯ͠৽ଔೖࣾɻ ෭ۀͰFlutterΛͪΐͬͱͬͨΓɻ ݸਓ։ൃ ݮञࢧԉΞϓϦʮAlconʯ https://apps.apple.com/jp/app/alcon/id1571071417 ࡔಓάϧʔϓͷ८ྱΞϓϦʮͷ͗ϥϦʔʯ https://apps.apple.com/jp/app/ͷ͗ϥϦʔ/id6501994754 @kudokai00
@KaitoKudou 2
DroidKaigi & iOSDC ͓ർΕ༷Ͱͨ͠ʂʂʂ
SwiftͰόοΫΤϯυͷ࣮͕Մೳʂ
Server Side Kotlin͋Δͬͯʁ
SwiftͰॻ͖͍ͨΜͩΑʂʂʂ
7
Vaporͱ • Server Side SwiftͷදతͳϑϨʔϜϫʔΫ • Swift Ͱ Web ΞϓϦͷ
API ɺ HTTP αʔόʔͷߏங͕Մೳ • पลϥΠϒϥϦ͕͔ͳΓॆ࣮ - ORMʢFluentʣɺೝূʢJWTɾOAuthʣɺWebSocketͳͲ 8
VaporͷΠϯετʔϧํ๏ • HomebrewͰΠϯετʔϧ • versionͷ֬ೝ 9
ϓϩδΣΫτͷ࡞ • ࠷খߏͰϓϩδΣΫτΛ࡞ • APIαʔόʔΛىಈ 10
GET APIΛ࡞
GET APIΛ࡞
Ϩεϙϯε curl http://localhost:8080/todos Λୟ͍ͨ݁Ռ
DB࿈ܞ 1. serverͷ४උ 2. con fi gure.swift ʹserverͷใΛ͢ 3. MigrationϑΝΠϧΛ࡞
4. ModelΛఆٛ 5. ControllerʹϨεϙϯεΛฦ͢ϝιουΛఆٛ
serverͷ४උ • pgAdminΛ༻ - SQLॻ͔ͣʹࡁΉʂ
con fi gure.swift ʹserverͷใΛ͢
con fi gure.swift ʹserverͷใΛ͢
MigrationϑΝΠϧΛ࡞ • DBͷมߋͱͦͷऔΓফ͠ํ๏Λఆٛ • ఆٛޙɺcon fi gure.swiftʹMigrationΛՃ - `app.migrations.add(CreateTodo())` •
`swift run {ϓϩδΣΫτ໊} migrate` ͰMigrationΛ࣮ߦ • MigrationޙదʹtableʹrecordΛՃ
MigrationϑΝΠϧΛ࡞
MigrationϑΝΠϧΛ࡞ ↓↓↓͜Μͳײ͡Ͱtableʹcolumn͕Ճ͞ΕΔ
ModelΛఆٛ
ControllerʹϨεϙϯεΛฦ͢ϝιουΛఆٛ • ϨεϙϯεΛฦ͢ϝιουControllerʹఆ͍ٛͯ͘͠
·ͱΊ • VaporΛ͏ͱSwiftΛͬͨAPI։ൃ͕Մೳ • PostgreSQL + Fluent ORMͰDB࿈ܞ؆୯ • جຊతʹDelegateϝιουΛ࣮͍ͯ͘͜͠ͱͰɺɹɹɹɹɹ
MigrationRouting͕Մೳ