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
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
79
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
480
iOSDC Japan 2022 スポンサーセッション
kaitokudou
0
2k
iOS勉強会資料
kaitokudou
0
120
App Storeにアプリをリリースした話
kaitokudou
0
48
Other Decks in Programming
See All in Programming
ReactとSvelteのその先、Ripple-TS / Beyond React and Svelte: Ripple-TS
ssssota
2
560
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
630
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
2
420
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
290
関係性から理解する"同一性"の型用語たち
pvcresin
2
400
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
160
新規プロダクトを高速で生み出すハーネスエンジニアリング
seanchas116
3
240
Skillは並べた。動かなかった。契約で繋いだ。— 65個のSkillから、自走する開発サイクルへ
junholee
0
690
Transactional Change Stream Processing With Debezium and Apache Flink
gunnarmorling
1
120
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
130
1人1案件のプロダクトエンジニア時代に、"プロセス監督"としてチャレンジしたこと
non0113
0
170
継続的な負荷検証を目指して
pyama86
3
1.4k
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
170
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Claude Code のすすめ
schroneko
67
220k
Technical Leadership for Architectural Decision Making
baasie
3
370
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
140
Side Projects
sachag
455
43k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.6k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
340
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
750
Facilitating Awesome Meetings
lara
57
6.9k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
350
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͕Մೳ