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
Kaito Kudo
October 10, 2025
Programming
0
46
5分でわかる! VaporでAPI+DB構築
Kaito Kudo
October 10, 2025
Tweet
Share
More Decks by Kaito Kudo
See All by Kaito Kudo
未来大LT_2025.pdf
kaitokudou
0
53
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
410
iOSDC Japan 2022 スポンサーセッション
kaitokudou
0
1.8k
iOS勉強会資料
kaitokudou
0
100
App Storeにアプリをリリースした話
kaitokudou
0
42
Other Decks in Programming
See All in Programming
そのpreloadは必要?見過ごされたpreloadが技術的負債として爆発した日
mugitti9
2
3.4k
Things You Thought You Didn’t Need To Care About That Have a Big Impact On Your Job
hollycummins
0
230
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
310
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
190
階層構造を表現するデータ構造とリファクタリング 〜1年で10倍成長したプロダクトの変化と課題〜
yuhisatoxxx
3
1k
理論と実務のギャップを超える
eycjur
0
130
スマホから Youtube Shortsを見られないようにする
lemolatoon
27
32k
CSC509 Lecture 04
javiergs
PRO
0
300
uniqueパッケージの内部実装を支えるweak pointerの話
magavel
0
1k
Introducing ReActionView: A new ActionView-Compatible ERB Engine @ Kaigi on Rails 2025, Tokyo, Japan
marcoroth
3
1k
CSC305 Lecture 04
javiergs
PRO
0
270
非同期jobをtransaction内で 呼ぶなよ!絶対に呼ぶなよ!
alstrocrack
0
900
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
21k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
32
2.3k
Unsuck your backbone
ammeep
671
58k
How to Think Like a Performance Engineer
csswizardry
27
2k
Being A Developer After 40
akosma
91
590k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
The Pragmatic Product Professional
lauravandoore
36
6.9k
Making Projects Easy
brettharned
119
6.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
369
20k
Navigating Team Friction
lara
190
15k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
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͕Մೳ