Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
FARM スタックに触れてみる
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
takf
February 09, 2022
Technology
1.7k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
FARM スタックに触れてみる
2022.02.08 Saitama.js #2 LT
takf
February 09, 2022
More Decks by takf
See All by takf
Go未経験・MVC脳のエンジニアが オニオンアーキテクチャを学ぶまで
takfjp
0
49
見やすい PRを作るために取り組んでいること
takfjp
0
71
Denoに入門していきなりAleph.jsを触ってみた
takfjp
0
550
Atomic Design とテストの○○な話
takfjp
2
2k
Node.jsのアップグレードで気をつけたこと
takfjp
1
3k
React Testing Library の Query について整理してみた
takfjp
0
570
React.js 消えるライフサイクルメソッドについて
takfjp
0
170
Laravel 初めての業務で遭遇したハマりポイント×2
takfjp
2
3.2k
React で Stateless Functional Component の書き方を盛大に間違えていた話
takfjp
0
470
Other Decks in Technology
See All in Technology
Futexes the good, the bad, the ugly
ennael
PRO
0
120
カンファレンスに参加した後の浮遊感とセルフケア
pauli
0
310
大阪オフィスに Unitree Go2 がやってきたので Physical AI やってみた
dafujii
0
300
Execution in the Kingdom of Agents: Reflections on Abstraction and Complexity
bcantrill
0
840
オブザーバビリティを高める AI エージェント体験を考える / Designing AI Agent Experiences That Enhance Observability
aoto
PRO
2
300
Kernel testing frameworks
ennael
PRO
0
110
生成AIで高い生産性を求められて、 悩み、乗り越えた話
mot_techtalk
2
130
Snowflake Horizon Catalog と Apache Iceberg で作る オープンなデータ基盤
kitagawaz
0
440
全社共通データ基盤をつくる。ソニーのDatabricks活用とデータガバナンス設計の裏側
sony
0
410
ログラスのマルチプロダクトを 支える認証基盤 〜テナントごとに異なる統制とどう向き合うか〜
dada4386
3
390
FactoryBotアンチパターン / factory_bot anti-patterns
toshimaru
0
130
ai_cording_with_k8s_knowledge.pdf
mochizuki875
1
280
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
210
How GitHub (no longer) Works
holman
316
150k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Fireside Chat
paigeccino
43
4k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
610
Practical Orchestrator
shlominoach
192
12k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
HDC tutorial
michielstock
2
940
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
920
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Transcript
FARM スタックに触れてみる 2022.02.08 Saitama.js vol.2 @takfjp
自己紹介 Takeru Furuichi (@takfjp) 川越市出身です ( オススメのお店:寿製麺よしかわ) https://www.kotobukiseimen.com/ コネヒト株式会社 所属
「ママリ」という出産・育児領域のサービスを開発・運営してい ます フロント: React バックエンド: CakePHP
None
FARM スタックとは? 以下の技術スタックを使ったSPA の開発手法 FastAPI React Mongo DB
MERN スタック Mongo DB Express React Node.js サーバサイドもJS で完結しているのが特徴
今回話さないこと FastAPI の詳細な仕様 Python の文法, 各種ライブラリの説明 デプロイ手順 実戦への導入( 触れてみた、という軽い紹介) React
アプリの実装( 時間の都合上)
FastAPI とは Python 製のAPI フレームワーク (v3.6 以上) https://fastapi.tiangolo.com/ja/ 名前の通り高速 Request,
Response 共に型定義が可能 SwaggerUI でAPI のドキュメントを自動生成できる <- !!
Swagger UI locahost:port/docs で表示できる リクエストを作成して投げるのを試せる
Mongo DB のセットアップ Mongo DB Cloud を利用 無料プラン(shared) を使用可能
GCP / AWS / Azure からクラウドプロバイダを選択可能 Tokyo リージョンを選択できる (!!)
FastAPI 側で用意するもの router REST API のエンドポイントを記載 schema エンドポイント向けに Request, Response
の型定義 DB に格納するModel の型定義 controller アクセス時の DB への操作 router に読み込ませる
schema from pydantic import BaseModel from typing import Optional from
decouple import config # BaseModel = FastAPI のスキーマモデル class Todo(BaseModel): id: str title: str description: str class TodoBody(BaseModel): title: str description: str
controller (database) from decouple import config ~~~ 中略 ~~~ #
async / await で手軽に非同期通信処理を記述できる async def db_create_todo(data: dict) -> Union[dict, bool]: todo = await collection_todo.insert_one(data) new_todo = await collection_todo.find_one({"_id": todo.inserted_id}) if new_todo: return todo_serializer(new_todo) return False
router from fastapi import APIRouter, Response, Request, HTTPException from schemas
import Todo, TodoBody from database import db_create_todo from starlette.status import HTTP_201_CREATED router = APIRouter() @router.post("/api/todo", response_model=Todo) async def create_todo(request: Request, response: Response, data: TodoBody): todo = jsonable_encoder(data) res = await db_create_todo(todo) response.status_code = HTTP_201_CREATED if res: return res raise HTTPException( status_code=404, detail="Create task failed")
deploy できたバックエンドAPI は Vercel Heroku などにデプロイして使用 Docker にpython のコンテナを作ってローカルで開発しても良さそ う
フロントエンドアプリ React, React-Query, Axios( 非同期通信用) などを使用して実装 単純なTodo アプリで動かしてみました React-Query はキャッシュが使えたりデータの取得状態を返し
てくれて便利ですね
Todo List
Todo List 2 Todo 作成成功と同時にDB に格納された Todo を fetch
雑感 API も独力で実装したい時にとても協力 フロントエンドエンジニアだって API を作りたい Mongo DB + FastAPI
は GraphQL とも親和性が高そう SwaggerUI を自動生成してくれるのはとても嬉しい API 側で型定義できるので TypeScript との親和性も高い Todo List 以外でも活用したくなる
We're Hiring! カジュアル面談やってます! https://connehito.com/recruit/
Thank you!
None