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
Remix で middleware
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ONDA, Takashi
November 20, 2024
Programming
1.1k
0
Share
Remix で middleware
Remix で middleware を作る方法とハマリどころ
ONDA, Takashi
November 20, 2024
More Decks by ONDA, Takashi
See All by ONDA, Takashi
Make Illegal States Unrepresentable
takonda
1
130
細粒度リアクティブステートのスコープとライフサイクル
takonda
2
4k
React への依存を最小にするフロントエンド設計
takonda
27
28k
TSKaigi Kansai 2024 - 構造的部分型と serialize 境界
takonda
3
1.6k
Remix Way を外れる自由
takonda
2
610
一休レストランで Next.js App Router から Remix に乗り換えた話 / Migration from Next.js App Router to Remix
takonda
14
8.7k
Other Decks in Programming
See All in Programming
レガシーPHP転生 〜父がドメインエキスパートだったのでDDD+Claude Codeでチート開発します〜
panda_program
0
930
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
140
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
430
Making the RBS Parser Faster
soutaro
0
290
Running Swift without an OS
kishikawakatsumi
0
840
実践CRDT
tamadeveloper
0
560
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
280
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
130
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
780
GitHubCopilotCLIをはじめよう.pdf
htkym
0
140
의존성 주입과 모듈화
fornewid
0
140
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
2
360
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.4k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
98
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
450
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Leo the Paperboy
mayatellez
7
1.7k
Design in an AI World
tapps
0
190
A Tale of Four Properties
chriscoyier
163
24k
SEO for Brand Visibility & Recognition
aleyda
0
4.5k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
310
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
100
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Transcript
Remix で middleware 株式会社一休 CTO 室 恩田 崇
2 自己紹介 株式会社一休 CTO 室 恩田 崇 1978 年生まれ、京都在住 フルスタック、なんでも屋
一休レストランのフロントエンドアーキテクト Next.js App Router を Remix に書き換えた フロントエンドは IE4/DHTML あたりから
3 TSKaigi Kansai にて TypeScript っぽい話をしたのに…
4 TSKaigi Kansai にて Remix 移行の話ばかりでした 🤣 懇親会その他で訊かれるのは…
5 本編 とある開発中の案件で認証関連の機能が必要に
6 本編 express だし middleware 使えばすぐ? 🤔 とある開発中の案件で認証関連の機能が必要に
7 middleware Remix は express アプリ const port = Number(process.env.PORT)
const buildPathArg = process.argv[2] const buildPath = path.resolve(buildPathArg) const build: ServerBuild = await import(url.pathToFileURL(buildPath).href) const app = express() app.disable('x-powered-by') app.use(compression()) // ここで middleware app.use(authMiddleware) app.use( build.publicPath, express.static(build.assetsBuildDirectory, { immutable: true, maxAge: '1y' }) ) app.all('*', remixHandler(build)) app.listen(port, onListen)
8 middleware Remix context に引き継げる function remixHandler(build: ServerBuild) { return
(req: Request, res: Response, next: NextFunction) => { const handler = createRequestHandler({ build, mode: process.env.NODE_ENV, getLoadContext() { return { authResult: (req as ReqWithAuth).authResult } }, }) handler(req, res, next) } }
9 ハマりどころ
10 ハマりどころ Node の native fetch でリクエストが詰まる問題に遭遇しました installGlobals を忘れずに `
` import { installGlobals } from '@remix-run/node' installGlobals() let { File: RemixFile, fetch: RemixFetch, FormData: RemixFormData, Headers: RemixHeaders, Request: RemixRequest, Response: RemixResponse, } = require("@remix-run/web-fetch"); global.File = RemixFile; global.Headers = RemixHeaders; global.Request = RemixRequest; global.Response = RemixResponse; global.fetch = RemixFetch; global.FormData = RemixFormData;
11 2024 年に express 書くの? 今日の特別ゲストは…
12 2024 年に express 書くの? 今日の特別ゲストは…
13 2024 年に express 書くの? demo hono-remix-adapter で動かしてみた
14 宣伝 土曜日の JSConf JP で登壇します
15 エンジニア募集中! 一休では、よりよいサービスを届ける仲間を募集しています。