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
79
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
54
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
420
iOSDC Japan 2022 スポンサーセッション
kaitokudou
0
1.8k
iOS勉強会資料
kaitokudou
0
100
App Storeにアプリをリリースした話
kaitokudou
0
42
Other Decks in Programming
See All in Programming
Go言語はstack overflowの夢を見るか?
logica0419
0
590
CSC305 Lecture 11
javiergs
PRO
0
270
3年ぶりにコードを書いた元CTOが Claude Codeと30分でMVPを作った話
maikokojima
0
640
Reactive Thinking with Signals and the Resource API
manfredsteyer
PRO
0
110
品質ワークショップをやってみた
nealle
0
630
CSC305 Lecture 10
javiergs
PRO
0
250
ソフトウェア設計の実践的な考え方
masuda220
PRO
4
650
pnpm に provenance のダウングレード を検出する PR を出してみた
ryo_manba
1
160
One Enishi After Another
snoozer05
PRO
0
160
Range on Rails ―「多重範囲型」という新たな選択肢が、複雑ロジックを劇的にシンプルにしたワケ
rizap_tech
0
7.7k
エンジニアインターン「Treasure」とHonoの2年、そして未来へ / Our Journey with Hono Two Years at Treasure and Beyond
carta_engineering
0
420
Writing Better Go: Lessons from 10 Code Reviews
konradreiche
3
6.8k
Featured
See All Featured
Thoughts on Productivity
jonyablonski
70
4.9k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.2k
Designing for humans not robots
tammielis
254
26k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
How to train your dragon (web standard)
notwaldorf
97
6.3k
A designer walks into a library…
pauljervisheath
209
24k
For a Future-Friendly Web
brad_frost
180
10k
Faster Mobile Websites
deanohume
310
31k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
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͕Մೳ