Introduction to Database Connection Management Patterns in TypeScript.pdf
Introduction to Database Connection Management Patterns in TypeScript.pdf
ããã«ã¡ã¯ãsugar-catã§ãã ãã®è¨äºã¯Hono Advent Calendar 2024ã®12æ¥ç®ã®è¨äºã§ãã ã¯ããã« Honoã§ã¯v4.5ç³»ã§Service Workerã®ã¢ããã¿ã¼ã使ç¨ãããã¨ãã§ããããã«ãªãã¾ããã ãã®ã¢ããã¿ã¼ã使ç¨ãããã¨ã§ããªã¯ã¨ã¹ãã®ã¤ã³ã¿ã¼ã»ãããå種å¦çãHonoã®æ¸ãå³ã®ã¾ã¾å®è£ ãããã¨ãå¯è½ã«ãªãã¾ãã Service Workerã«ã¤ã㦠Service Workerã¯ããã©ã¦ã¶ã¨ãããã¯ã¼ã¯ã®éã§ãããã·ã¨ãã¦æ©è½ãã¾ãã ãã©ã¦ã¶ã®ããã¯ã°ã©ã¦ã³ãã§åä½ãããã£ãã·ã¥ãããã·ã¥éç¥ãªã©ã®ã¿ã¹ã¯ãå¦çããã¹ã¯ãªããã¨ãã¦å©ç¨ããã¦ãã¾ãã ã©ã¤ããµã¤ã¯ã«ã«ã¤ãã¦ã¯ã以ä¸ã®åç»ãããããããã§ãã ãã®Service Workerã«ã¯ãfetchã¤ãã³ããããã¾ãã ãã®fetchã¤ãã³ãã¯ã¡ã¤ã³ã¹ã¬ããããããã¯ã¼ã¯ãªã¯ã¨ã¹ããè¡
Honoã¨ããWebãã¬ã¼ã ã¯ã¼ã¯ãããã¾ããExpress.jsã®ãããªæ¸ãæ¹ã§Webã¢ããªã±ã¼ã·ã§ã³ãä½ãããã®ã§ãã import { Hono } from "hono"; const app = new Hono(); app.get("/", (c) => c.json({ message: "Hello, Hono!" })); export default app; Honoã¯Webæ¨æºæºæ ã謳ã£ã¦ãããã¬ã¼ã ã¯ã¼ã¯ã§ãããããèãã¨ãªãã ãå°é£ããæãã¾ãã Webæ¨æºã¨ã¯ Request 㨠Response ã®ã¤ã³ã¹ã¿ã³ã¹ãæ±ãã¨ãããã¨ã§ãããããã¯ä¸»ã«ãã©ã¦ã¶ä¸ã®JavaScriptã®fetché¢æ°ãåãæ±ããªãã¸ã§ã¯ãã§ããã Requestã¯fetchã§HTTPãªã¯ã¨ã¹ããéä¿¡ããã¨ãã«ããã¼ã¿ãã¾ã¨ãã¦ãããªãã¸ã§ã¯ãã§ããä¾ãã°éä¿¡å ã®URLãHTTPã¡ã½
ãã®è¨äºã§ã¯ãHonoã使ã£ã¦Stripeã®SDKãå©ç¨ããAPIéçºãè¡ãéã«ãç¥ã£ã¦ããã¨ä¾¿å©ãªAPIãå®è£ æ¹æ³ãç´¹ä»ãã¾ãã ã¯ããã« Stripeã§Developer Relation ( DevRel )ã¨ãã¦æ´»åãã¦ãã岡æ¬ã¨ç³ãã¾ããQiitaã®è¨äºãä½æããéã®ãµã³ãã«ã³ã¼ãéçºããCloudflare Workerã§ã®ãµã³ãã«ã¢ããªãªã©ã§Honoãå©ç¨ãã¦ãã¾ãã Honoå´ã§Stripeã使ã£ãéçºã«é¢ããç¸è«ã»Issueãç«ã£ãéãä½è ã® @yusukebe ããããã¡ã³ã·ã§ã³ããã ããã¨ããããIssueã¸ã®åçãDocumentè¨äºä½æãªã©ã«ãããããªããåå ãã¦ãã¾ãã ãã®è¨äºã§ã¯ããããã®ããåãããã¢ã¢ããªéçºãªã©ãéããçµé¨ãå ã«ãHonoã®æ´»ç¨Tipsãç´¹ä»ãã¾ãã Stripe SDKã®ã»ããã¢ããã¯ãenvã¨middlewareãæ´»ç¨ããã Hon
ãã®è¨äºã¯Hono Advent Calendar 2024 11æ¥ç®ã®è¨äºã§ãã ãã®ã¢ããã³ãã«ã¬ã³ãã¼ããã£ããã«ãåãã¦Honoã§ã¦ã§ãã¢ããªãä½ã£ã¦ã¿ã¾ãããã»ãã¥ãªãã£ãå¼·åãã¦ããã³ã¼ããã³ã³ãã¯ããªã¾ã¾ãªã®ã§ã¨ã¦ãããæãã§ãã ãã®è¨äºã§ã¯ãã¦ã§ãã¢ããªã®ã»ãã¥ãªãã£ãå¼·åããéç¨ããã³ãºãªã³å½¢å¼ã§ãå±ããã¾ãã ã»ãã¥ãªãã£ãå¼·åãã対象ã®ã¢ã㪠Single Page Applicationï¼SPAï¼ã®ç¿»è¨³ã¢ããªã§ãããµã¼ãã¼ã¬ã¹ã®å®è¡ç°å¢Cloudflare Workersã¨ãCloudflareä¸ã§çæAIãç°¡åã«å©ç¨ã§ããWorkers AIã使ã£ã¦ãã¾ãã Cloudflareã®ã¢ã«ã¦ã³ããããã°ç¡æã§åããã¾ããã¯ã¬ã¸ããã«ã¼ããªãã§ã¢ã«ã¦ã³ããä½ãã¾ãããã»ãã¨å¤ªã£è ¹ã§ããï¼ ã½ã¼ã¹ã³ã¼ãã¯GitHubã§å ¬éãã¦ãã¾ãã ã»ãã¥ãªãã£å¼·åã®æµã ãã®ã¢ããª
ãã®è¨äºã¯2024å¹´10æ22æ¥ã«è¡ããããããããã¾ãã¦ã¹ 2024ãã§çºè¡¨ãããHonoã®æ¥ãéã¨ãããããã®å 容ããå ã»ã©å£é ã§åã£ã¦æåèµ·ããã¦ä¿®æ£ãããã®ã§ãã ã¢ã¸ã§ã³ã ä»æ¥ã¯Honoã®æ¥ãéã¨ããããã¨ããé¡åã§è©±ãã¦ããããã¨æãã¾ããã¼ããã¹ã¼ã¨ç³ãã¾ãããããããé¡ããã¾ããä»æ¥ã®ã¢ã¸ã§ã³ãã§ããã©ããHonoã®ç¾å¨ã®ç¶æ³ã¨ã¡ã¤ã³ã®Honoã®æ¥ãéã¨ããããã¨ãããã¨ãç´¹ä»ãããã¨æãã¾ããããããããã¯å°ãªããæ¥ãéãã¨ããã®ãç¦ç¹ã«ãªã£ã¦ãã¦ããããããããã¯å¥ã§ç´¹ä»ãã¦ããããã¨æãã¾ãã Honoã¨ã¯ï¼ ã¾ãHonoã¨ã¯ã¨ãã話ãããããã§ããä»åã¯ã§ãããæåèµ·ããçã¨ãããã¨ã§çãã¾ãã ç´¹ä»ãããã®ã¯ã¤ãã·ã£ã«ã³ãããã¨ãããã¨ã§æåã®ã³ãããã2021å¹´12æ15æ¥ã«ãªãã¾ãã¦ãããã3å¹´çµã¡ã¾ããããã¡ããã©3å¹´çµã¡ã¾ãããçµæ§é·ãéãã£ã¦ããããã¸
Hono ã¢ããã³ãã«ã¬ã³ãã¼ 2024 åæ¥æ å½ã® ããã°ã¼ ã§ãã æ¬è¨äºã§ã¯ã11 æã«ãªãªã¼ã¹ãã漫ç»ãã©ãããã©ã¼ã ãcomilioãã®éçºäºä¾ããã¨ã«ãã¨ã«ãã Hono ãæå¼·ã ã¨ãããã¨ãã¤ãã¤ãã¨æ¸ãã¦ããè¨äºã¨ãªãã¾ãã å人ç 2024 å¹´ãã¹ããªãåªåãã¬ã¼ã ã¯ã¼ã¯ã¯ Hono ä¸æã§ããHono ãç¡ããã°ããããããããã¯ããä»ããªãªã¼ã¹ã§ãã¦ããªãã£ãã¨è¨ã£ã¦ãéè¨ã§ã¯ããã¾ããã ãã²ãã®è¨äºãåèã«ãã¦ã0 -> 1 ãç«ã¡ä¸ããé㯠Hono ãç©æ¥µçã«æ¡ç¨ãã¦ããããã°ã¨æãã¾ãã ã¾ããHono ã¨ããæé«ã®ãããã¯ããçã¿åºãã¦ããã @yusukebe ããã«ã¯å ¨èº«å ¨éãæã£ã¦æè¬ãã¾ãã ãcomilioãã®ã¤ã³ãã©æ§æ ã¾ããä»åã®å®ä¾ã§ãã漫ç»ãã©ãããã©ã¼ã ãcomilioãã®æ§æãç´¹ä»ãã¾ãã ãcomilioãã§ã¯ TypeScrip
Server-Sent Events (SSE) ç®æ°ããæè¡ã¨ããããã§ã¯ããã¾ããããæè¿ Server-Sent Events (SSE) ã«ã¤ãã¦è¨åããè¨äºãããè¦ããã¾ãã ä½çªç ããã¯ãããã¾ããããå人çã«èå³ããããã¨ã¨ãæ£ç´è§¦ã£ã¦ã¿ããã¨ããªãã£ãã®ã§ãã³ã¼ããæ¸ãã¤ã¤èª¿ã¹ã¦ã¿ã¾ããã â»æ¬è¨äºã§ç»å ´ãããµã³ãã«ã³ã¼ãã¯æ¬¡ã®ãªãã¸ããªã§å ¬éãã¦ãã¾ãã SSE ã¨ã¯ SSE èªä½ã解説ããè¨äºã¯ç¡æ°ã«åå¨ãããã詳細ãªèª¬æã¯å²æãã¾ãããç°¡åã«è¨ãã¨ããµã¼ãã¼ããã¯ã©ã¤ã¢ã³ãã¸ä¸æ¹åã® Push éä¿¡ãè¡ãããã®ä»çµã¿ã§ãã MDN ã«ããã¼ã¸ãåå¨ãããããåèã«ãªãã¾ãã ç¬èªãããã³ã«ãå¿ è¦ã¨ãããHTTP/1.1 ã§ãåä½ããã®ãç¹å¾´ã§ãã SSE ã®æ´å² wikipedia ã« SSE ã«é¢ãããã¼ã¸ãåå¨ãã次ã®ãããªè¨è¿°ãããã¾ãã SSE ã¡ã«ããºã ã¯ã
WEBéçºç°å¢Tier1ãçµãããï¼ å¤§å¦ããã®å人ã«ã俺ã¯èµ·æ¥ããããï¼å¤å°ãªãåºãããWEBãµã¤ãä½ããï¼ãã¨è¨ãããã®ã§ ããããèªç± ãæ¡ä»¶ã«ï¼ã»ã¼ï¼ç¡åã§å¼ãåããæ¡ä»¶ã¨ããåã®è¶£å³å¶ä½ã§ãã¼ãã®ãããããæå¼·ã®WEBãµã¤ãããç®æãã¦ã¿ã¾ãããä¿å®éç¨ã®æ±ç¨æ§ã¯ç ç²ã¨ãªã£ãã®ã ä»å¹´ãã¢ããã³ãã«ã¬ã³ãã¼ã«æ稿ããæ©ä¼ãå¾ãã®ã§ãç°å¢æ§ç¯éç¨ã¨APIæ¥ç¶ãã§ããã¾ã§ããç´¹ä»ãã¾ããï¼ä»ã®æ¹ã ã®è¨äºããã²èªãã§ãã ããï¼ ä½æ¥ã¡ã¢ãå ¼ãã¦ããããä¸ã ãªé·ããã¤èªã¿ã¥ãããã¨æãã¾ãããå¿ è¦ãªé¨åãæ»ãæãã§èªãã§ããã ããã°å¹¸ãã§ãã èªå·±ç´¹ä» '97年製 å®åæ´: Angular 1å¹´ãReact 4å¹´ è¦ã¦ã®éãããã³ãã¨ã³ãåè²æã使ããªã®ã§ä»å人çã§åãã¦SQLã ã®DBã ã®çé¢ç®ã«åå¼·ãã¾ãããORM使ã£ã¦ããã©SQLã©ã¤ã¯ãªè¨æ³ãªã®ã§åå¼·ããã¨è¨ããã¦ãã ãããå ã SE
æ ªå¼ä¼ç¤¾ CoeFont ã§ããã³ãã¨ã³ãã¨ã³ã¸ãã¢ããã¦ãã uzimaru ã§ãã Next.js ã® Middleware 㧠Hono ã使ã£ã¦ã¿ãã®ã§ããã«ã¤ãã¦è¨äºã«ã¾ã¨ãã¾ãã ã¢ããã¼ã·ã§ã³ Next.js ã® Middleware ã¯ã¢ããªã±ã¼ã·ã§ã³ã«1ã¤ã ãããè¨å®åºæ¥ããã©ã® path ã§å®è¡ãããã®è¨å®ã config ã使ã£ã¦æ£è¦è¡¨ç¾ã Header, Cookie ãæå®ãã¦è¨å®ããããªã¯ã¨ã¹ãã® pathname ãè¦ã¦å¦çãåå²ããå¿ è¦ãããã¾ãã ã·ã³ãã«ãªå®è£ ã®ã¿ãªãè¯ãã®ã§ãããpath ã«ãã£ã¦ãã°ã¤ã³ãã¦ããã確èªããããããã¤ãã®å¦çã Middleware ã§é©å¿ããããã¨ããããã«è¦ä»¶ãè¤éã«ãªãã¨ç®¡çã大å¤ã«ãªã£ã¦ããã¨æãã¾ãã ããã§ãHono ã®ãããªã·ã³ãã«ãªãã¬ã¼ã ã¯ã¼ã¯ã Middleware ã§åããã¦å®è£ ãã·ã³ãã«ã«ãããã¨
ç·¨éä¸ ããã«ã³ã¼ããç½®ãã¨æãã¾ãã ãã®ã¤ãã³ããä»é±æ«ã§ããã®ä¸ã§ãHonoãã³ãºãªã³ããããã®ã§è¶ 絶ãã¿ãã¬ã§ãããããã§è©±ãå 容ãæ¸ãã¾ãã æ¹é ãã³ãºãªã³ã¨è¨ãã¤ã¤ãã¿ããªã§ä¸æã«ããã¾ããããã£ã¦ããã¨åãããã®ã«æéããããã®ã§ãåãã©ãã©ãé²ãã¾ãããªã®ã§ãã¤ãã¦ããã人ã ãã¤ãã¦ãã¦ãã ããããããããªã人ã¯åãã³ã¼ãæ¸ãã®ãè¦ã¦ãã ãããããããã®æ¹ãããããã£ã¦ããã¨æãã¾ãã Honoã¨ã¯ï¼ ã¦ã§ããµã¤ããè¦ã¦ãã ããã ãã¨æ£ç´ãåã¯ããã°æ¸ãã®ã¨ã好ããªãã§ãããããããã¡ããã¨ãããããã¥ã¡ã³ãããæ¸ãã®ãæ£ç´è¦æã§ããã¯è±èªã«éãããªãã§ããããªã®ã§ããããã¦ããæ¹ãããè²¢ç®ãã¦ãã ãããã³ã³ããªãã¥ã¼ã·ã§ã³ã¦ã§ã«ã«ã ï¼ create-hono ãã¦ãããããã£ã¦ããããã§ãããHonoã®ããã¸ã§ã¯ããã¤ããã¨ãã«ã¯create-honoã¨ããCLIã使
2æ9æ¥ãäºåãã¦ããéãHono v4ããªãªã¼ã¹ãã¾ããã ãã®Hono v4ã®ãªãªã¼ã¹ã¨åæã«ãHonoã使ã£ãã¡ã¿ãã¬ã¼ã ã¯ã¼ã¯ãHonoXããå ¬éãã¾ããã ä»åã¯HonoXã®ããã¤ãã®ç¹å¾´ã«ã¤ãã¦æ¸ãã¦ã¿ããã¨æãã¾ããããã¯ä½¿ãæ¹ã¨ããããä½è ç®ç·ã®ææ³ã¿ãããªãã®ã§ãã ã¡ã¿ãã¬ã¼ã ã¯ã¼ã¯ HonoXã¨ã¯ä¸è¨ã§è¨ãã¨ãHonoã¨Viteãçµã¿åãããã¡ã¿ãã¬ã¼ã ã¯ã¼ã¯ãã§ããHonoXèªä½ãæ©è½ãæä¾ããªãã®ãèã§ãã ããå°ãã ãå ·ä½çã«è¨ãã¾ããHonoXã§æ±ãã®ã¯ãHonoã®ã¤ã³ã¹ã¿ã³ã¹ããã®ãã®ã§ããã¤ã¾ãããªããHonoXã§ã¢ããªãä½ãã¨ãããã¨ã¯ãHonoã®ã¢ããªãä½ãããã¨ã«ãªãã¾ãããã®è¨¼æ ã«ã¨ã³ããªã¼ãã¤ã³ãã«ãªãapp/server.tså ã§åºã¦ããappã¯Honoã®ã¤ã³ã¹ã¿ã³ã¹ãªã®ã§ãhono/devã«ãããã«ãã¼é¢æ°showRoutes()ããã®ã¾ã¾ä½¿
Warning HonoX 㯠2024 å¹´ 2 æç¾å¨ã¢ã«ãã¡ã¹ãã¼ã¸ã¨ãªã£ã¦ãã¾ããã»ãã³ãã£ãã¯ãã¼ã¸ã§ã³ã«å¾ããã«ç ´å£çãªå¤æ´ãè¡ãããå¯è½æ§ãããã¾ãã HonoX 㯠Hono 㨠Vite ããã¼ã¹ã«ãããã«ã¹ã¿ã㯠Web ãã¬ã¼ã ã¯ã¼ã¯ã§ãã以ä¸ã®ãããªç¹å¾´ãããã¾ãã ãã¡ã¤ã«ãã¼ã¹ã®ã«ã¼ãã£ã³ã° é«é㪠SSR BYORï¼Bring Your Own Rerenderï¼ï¼ã¬ã³ããªã³ã°ã¨ã³ã¸ã³ãèªç±ã«é¸æã§ãã¾ã islands ãã¤ãã¬ã¼ã·ã§ã³ ããã«ã¦ã§ã¢ï¼ããã¯ã¨ã³ã㯠Hono ã¨ãã¦åä½ãããããå¤ãã® Hono ã®ããã«ã¦ã§ã¢ ã使ç¨ã§ãã¾ã HonoX ãå§ãã æ°ãã HonoX ã®ããã¸ã§ã¯ããä½æããããã«ã¯ãhono-create ã³ãã³ãã使ç¨ãã¾ãã
X dayã¯2æ9æ¥ã§ãï¼ ã¨ãããã¨ã§ãHonoã®ç¾å¨ã®ãã¼ã¸ã§ã³ã¯v3ç³»ãªã®ã§ãããv4ã2æ9æ¥ã«ãªãªã¼ã¹ããäºå®ã§ããå¶ç¶ã«ãYAPC::Hiroshima 2024ã®åå¤ç¥ã®æ¥ã§ããã å½åã¯deprecatedãªæ©è½ãå»æ¢ãããã¨ããããã¸ãã£ãã§ã¯ãªããçç±ã§ã¡ã¸ã£ã¼ãã¼ã¸ã§ã³ã¢ããããããã£ãã®ã§ããã大ããªæ©è½ãå ¥ããã¨ã«ãªãã¾ããããã°ããã®3ã¤ã§ãã Static Site Generation Client Components File-based Routing ãåããã®éãããããã«ã¹ã¿ãã¯ãªãã¬ã¼ã ã¯ã¼ã¯ã«é²åãã¾ããä»åã¯2æ9æ¥ã«å é§ãã¦ãã®3ã¤ã®æ©è½ã軽ããªã¼ãã¼ãã¥ã¼ãã¦ã¿ã¾ãããã RCç v4ã®RCçãåºã¦ã¾ããç¾å¨ã¯4.0.0-rc.3ãææ°ãªã®ã§ä»¥ä¸ã®ã³ãã³ãã§ã¤ã³ã¹ãã¼ã«ã§ãã¾ãã npm create honoã§ä½ã£ãããã¸ã§ã¯ãå ã§å®
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}