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
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
78
Denoに入門していきなりAleph.jsを触ってみた
takfjp
0
550
Atomic Design とテストの○○な話
takfjp
2
2k
Node.jsのアップグレードで気をつけたこと
takfjp
1
3k
React Testing Library の Query について整理してみた
takfjp
0
580
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
AIがGISを代替する日:〜すべてをAIが創る時代に、私たちがFOSS4Gに関わる意味〜
lehupa
0
130
ポケモン対戦を自動で記録して振り返ろう
fufufukakaka
0
420
Oracle Database Security 詳細解説
oracle4engineer
PRO
1
170
Vibe-to-Spec開発_実践ガイド
happysamurai294
0
130
渡米前の準備を制す!re:Invent 2026徹底準備術 / The Ultimate Preparation Guide for re:Invent 2026
yuj1osm
1
440
AX時代の自治体支援リソース再配分と役割分担の再構成:戦略とロードマップ(概要)
sishi2026
0
130
Agent 活用環境の構築・運用のための AWS サービスのご紹介/agentcore-for-building-and-operating-agents
ren8k
1
280
Patterns in AI Driven Software Development
akosma
PRO
0
380
キヨさん67歳 AIコーディングエージェント物語
happysamurai294
0
140
AIで選択肢が広がった組織設計の理想と現実
konifar
16
7.2k
Snowflake でできることが増えたら、 ABAC が必要になった
kaeton
0
120
自律的なチームを作るためにTechPMがやらないこと
ny7760
0
270
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
234
19k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.4k
Documentation Writing (for coders)
carmenintech
77
5.6k
Done Done
chrislema
187
17k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Leo the Paperboy
mayatellez
10
2.4k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.3k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
290
エンジニアに許された特別な時間の終わり
watany
109
250k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.7k
Become a Pro
speakerdeck
PRO
31
6.3k
Test your architecture with Archunit
thirion
2
2.5k
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