[{"data":1,"prerenderedAt":1316},["ShallowReactive",2],{"navigation_docs":3,"-rpc-middlewares-sync-routes":399},[4,162,346],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":24},"RPC","icon-park-outline:lightning","\u002Frpc","01.rpc",[10,25,63,77,102,136],{"title":11,"icon":12,"redirect":7,"path":13,"stem":14,"children":15,"page":24},"Introduction","icon-park-outline:home","\u002Frpc\u002Fintroduction","01.rpc\u002F01.introduction",[16,20],{"title":17,"path":18,"stem":19},"Quick Start","\u002Frpc\u002Fintroduction\u002Fquick-start","01.rpc\u002F01.introduction\u002F02.quick-start",{"title":21,"path":22,"stem":23},"Manual Install","\u002Frpc\u002Fintroduction\u002Fmanual-install","01.rpc\u002F01.introduction\u002F03.manual-install",false,{"title":26,"icon":27,"path":28,"stem":29,"children":30,"page":24},"Server","icon-park-outline:server","\u002Frpc\u002Fserver","01.rpc\u002F02.server",[31,35,39,43,47,51,55,59],{"title":32,"path":33,"stem":34},"Routes","\u002Frpc\u002Fserver\u002Froutes","01.rpc\u002F02.server\u002F01.routes",{"title":36,"path":37,"stem":38},"Middleware","\u002Frpc\u002Fserver\u002Fmiddleware","01.rpc\u002F02.server\u002F02.middleware",{"title":40,"path":41,"stem":42},"Call Context","\u002Frpc\u002Fserver\u002Fcall-context","01.rpc\u002F02.server\u002F03.call-context",{"title":44,"path":45,"stem":46},"Headers","\u002Frpc\u002Fserver\u002Fheaders","01.rpc\u002F02.server\u002F04.headers",{"title":48,"path":49,"stem":50},"Error Handling","\u002Frpc\u002Fserver\u002Ferror-handling","01.rpc\u002F02.server\u002F05.error-handling",{"title":52,"path":53,"stem":54},"Validation","\u002Frpc\u002Fserver\u002Fvalidation","01.rpc\u002F02.server\u002F06.validation",{"title":56,"path":57,"stem":58},"JSON Round Trip","\u002Frpc\u002Fserver\u002Fjson-round-trip","01.rpc\u002F02.server\u002F07.json-round-trip",{"title":60,"path":61,"stem":62},"Drizzle Tables","\u002Frpc\u002Fserver\u002Fdrizzle-tables","01.rpc\u002F02.server\u002F08.drizzle-tables",{"title":64,"icon":65,"path":66,"stem":67,"children":68,"page":24},"Middlewares","icon-park-outline:link-one","\u002Frpc\u002Fmiddlewares","01.rpc\u002F03.middlewares",[69,73],{"title":70,"path":71,"stem":72},"fetchMetadata","\u002Frpc\u002Fmiddlewares\u002Ffetch-metadata","01.rpc\u002F03.middlewares\u002F01.fetch-metadata",{"title":74,"path":75,"stem":76},"syncRoutes","\u002Frpc\u002Fmiddlewares\u002Fsync-routes","01.rpc\u002F03.middlewares\u002F02.sync-routes",{"title":78,"icon":79,"path":80,"stem":81,"children":82,"page":24},"Client","icon-park-outline:computer","\u002Frpc\u002Fclient","01.rpc\u002F04.client",[83,87,91,94,98],{"title":84,"path":85,"stem":86},"Client Overview","\u002Frpc\u002Fclient\u002Fclient-overview","01.rpc\u002F04.client\u002F00.client-overview",{"title":88,"path":89,"stem":90},"Client Middleware","\u002Frpc\u002Fclient\u002Fclient-middleware","01.rpc\u002F04.client\u002F01.client-middleware",{"title":48,"path":92,"stem":93},"\u002Frpc\u002Fclient\u002Ferror-handling","01.rpc\u002F04.client\u002F02.error-handling",{"title":95,"path":96,"stem":97},"Batch Requests","\u002Frpc\u002Fclient\u002Fbatch","01.rpc\u002F04.client\u002F03.batch",{"title":99,"path":100,"stem":101},"Cancellation & Timeouts","\u002Frpc\u002Fclient\u002Fcancellation-timeouts","01.rpc\u002F04.client\u002F04.cancellation-timeouts",{"title":103,"redirect":104,"icon":105,"path":106,"stem":107,"children":108,"page":24},"Platforms","\u002Frpc\u002Fplatforms\u002Fnode-js","icon-park-outline:play","\u002Frpc\u002Fplatforms","01.rpc\u002F06.platforms",[109,112,116,120,124,128,132],{"title":110,"path":104,"stem":111},"Node.js","01.rpc\u002F06.platforms\u002F01.node-js",{"title":113,"path":114,"stem":115},"Bun","\u002Frpc\u002Fplatforms\u002Fbun","01.rpc\u002F06.platforms\u002F02.bun",{"title":117,"path":118,"stem":119},"AWS Lambda","\u002Frpc\u002Fplatforms\u002Faws-lambda","01.rpc\u002F06.platforms\u002F03.aws-lambda",{"title":121,"path":122,"stem":123},"Google Cloud Functions","\u002Frpc\u002Fplatforms\u002Fgoogle-cloud-functions","01.rpc\u002F06.platforms\u002F04.google-cloud-functions",{"title":125,"path":126,"stem":127},"Cloudflare Workers","\u002Frpc\u002Fplatforms\u002Fcloudflare","01.rpc\u002F06.platforms\u002F05.cloudflare",{"title":129,"path":130,"stem":131},"Vercel","\u002Frpc\u002Fplatforms\u002Fvercel","01.rpc\u002F06.platforms\u002F06.vercel",{"title":133,"path":134,"stem":135},"uWebSockets.js","\u002Frpc\u002Fplatforms\u002Fuwebsockets","01.rpc\u002F06.platforms\u002F07.uwebsockets",{"title":137,"icon":138,"path":139,"stem":140,"children":141,"page":24},"Devtools","icon-park-outline:tool","\u002Frpc\u002Fdevtools","01.rpc\u002F07.devtools",[142,146,150,154,158],{"title":143,"path":144,"stem":145},"Linter","\u002Frpc\u002Fdevtools\u002Flinter","01.rpc\u002F07.devtools\u002F01.linter",{"title":147,"path":148,"stem":149},"Vite","\u002Frpc\u002Fdevtools\u002Fvite","01.rpc\u002F07.devtools\u002F02.vite",{"title":151,"path":152,"stem":153},"Next.js","\u002Frpc\u002Fdevtools\u002Fnextjs","01.rpc\u002F07.devtools\u002F03.nextjs",{"title":155,"path":156,"stem":157},"CLI","\u002Frpc\u002Fdevtools\u002Fcli","01.rpc\u002F07.devtools\u002F04.cli",{"title":159,"path":160,"stem":161},"API Types","\u002Frpc\u002Fdevtools\u002Fapi-types","01.rpc\u002F07.devtools\u002F05.api-types",{"title":163,"icon":164,"path":165,"stem":166,"children":167,"page":24},"RunTypes","i-lucide-braces","\u002Fruntypes","02.runtypes",[168,184,224,254,268,290,332],{"title":11,"icon":169,"redirect":165,"path":170,"stem":171,"children":172,"page":24},"i-lucide-rocket","\u002Fruntypes\u002Fintroduction","02.runtypes\u002F01.introduction",[173,177,180],{"title":174,"path":175,"stem":176},"Built on typescript-go","\u002Fruntypes\u002Fintroduction\u002Fbuilt-on-typescript-go","02.runtypes\u002F01.introduction\u002F02.built-on-typescript-go",{"title":17,"path":178,"stem":179},"\u002Fruntypes\u002Fintroduction\u002Fquick-start","02.runtypes\u002F01.introduction\u002F03.quick-start",{"title":181,"path":182,"stem":183},"Configuration","\u002Fruntypes\u002Fintroduction\u002Fconfiguration","02.runtypes\u002F01.introduction\u002F04.configuration",{"title":185,"icon":186,"redirect":187,"path":188,"stem":189,"children":190,"page":24},"Guide","i-lucide-book-open","\u002Fruntypes\u002Fguide\u002Ftype-builders","\u002Fruntypes\u002Fguide","02.runtypes\u002F02.guide",[191,194,198,201,204,208,212,216,220],{"title":192,"path":187,"stem":193},"Types vs Type Builders","02.runtypes\u002F02.guide\u002F01.type-builders",{"title":195,"path":196,"stem":197},"Reflection","\u002Fruntypes\u002Fguide\u002Freflection","02.runtypes\u002F02.guide\u002F02.reflection",{"title":52,"path":199,"stem":200},"\u002Fruntypes\u002Fguide\u002Fvalidation","02.runtypes\u002F02.guide\u002F03.validation",{"title":56,"path":202,"stem":203},"\u002Fruntypes\u002Fguide\u002Fjson-round-trip","02.runtypes\u002F02.guide\u002F04.json-round-trip",{"title":205,"path":206,"stem":207},"Data Mocking","\u002Fruntypes\u002Fguide\u002Fmocking","02.runtypes\u002F02.guide\u002F07.mocking",{"title":209,"path":210,"stem":211},"JSON Schemas","\u002Fruntypes\u002Fguide\u002Fjson-schemas","02.runtypes\u002F02.guide\u002F08.json-schemas",{"title":213,"path":214,"stem":215},"Pure Functions","\u002Fruntypes\u002Fguide\u002Fpure-functions","02.runtypes\u002F02.guide\u002F09.pure-functions",{"title":217,"path":218,"stem":219},"Compiler Markers","\u002Fruntypes\u002Fguide\u002Fcompiler-markers","02.runtypes\u002F02.guide\u002F10.compiler-markers",{"title":221,"path":222,"stem":223},"All Compiled Functions","\u002Fruntypes\u002Fguide\u002Fall-compiled-functions","02.runtypes\u002F02.guide\u002F11.all-compiled-functions",{"title":225,"icon":226,"redirect":227,"path":228,"stem":229,"children":230,"page":24},"Type Formats","i-lucide-shapes","\u002Fruntypes\u002Ftype-formats\u002Foverview","\u002Fruntypes\u002Ftype-formats","02.runtypes\u002F03.type-formats",[231,234,238,242,246,250],{"title":232,"path":227,"stem":233},"Overview","02.runtypes\u002F03.type-formats\u002F01.overview",{"title":235,"path":236,"stem":237},"String Formats","\u002Fruntypes\u002Ftype-formats\u002Fstring","02.runtypes\u002F03.type-formats\u002F02.string",{"title":239,"path":240,"stem":241},"Number Formats","\u002Fruntypes\u002Ftype-formats\u002Fnumber","02.runtypes\u002F03.type-formats\u002F03.number",{"title":243,"path":244,"stem":245},"BigInt Formats","\u002Fruntypes\u002Ftype-formats\u002Fbigint","02.runtypes\u002F03.type-formats\u002F04.bigint",{"title":247,"path":248,"stem":249},"Date and Time Formats","\u002Fruntypes\u002Ftype-formats\u002Fdate-time","02.runtypes\u002F03.type-formats\u002F05.date-time",{"title":251,"path":252,"stem":253},"Collection Formats","\u002Fruntypes\u002Ftype-formats\u002Fcollections","02.runtypes\u002F03.type-formats\u002F06.collections",{"title":255,"icon":256,"redirect":257,"path":258,"stem":259,"children":260,"page":24},"Tooling","i-lucide-wrench","\u002Fruntypes\u002Ftooling\u002Flinting","\u002Fruntypes\u002Ftooling","02.runtypes\u002F04.tooling",[261,264],{"title":262,"path":257,"stem":263},"Linting","02.runtypes\u002F04.tooling\u002F01.linting",{"title":265,"path":266,"stem":267},"Source Conversion","\u002Fruntypes\u002Ftooling\u002Fsource-conversion","02.runtypes\u002F04.tooling\u002F02.source-conversion",{"title":269,"icon":270,"redirect":271,"path":272,"stem":273,"children":274,"page":24},"AI Integration","i-lucide-sparkles","\u002Fruntypes\u002Fai-integration\u002Fworkflow-and-commands","\u002Fruntypes\u002Fai-integration","02.runtypes\u002F05.ai-integration",[275,278,282,286],{"title":276,"path":271,"stem":277},"AI Workflow","02.runtypes\u002F05.ai-integration\u002F01.workflow-and-commands",{"title":279,"path":280,"stem":281},"FriendlyText","\u002Fruntypes\u002Fai-integration\u002Ffriendly-text","02.runtypes\u002F05.ai-integration\u002F02.friendly-text",{"title":283,"path":284,"stem":285},"MockData","\u002Fruntypes\u002Fai-integration\u002Fmock-data","02.runtypes\u002F05.ai-integration\u002F03.mock-data",{"title":287,"path":288,"stem":289},"Translations (i18n)","\u002Fruntypes\u002Fai-integration\u002Fi18n","02.runtypes\u002F05.ai-integration\u002F04.i18n",{"title":291,"icon":292,"redirect":293,"path":294,"stem":295,"children":296,"page":24},"Drizzle ORM","i-lineicons-drizzle","\u002Fruntypes\u002Fdrizzle-orm\u002Fdrizzle-overview","\u002Fruntypes\u002Fdrizzle-orm","02.runtypes\u002F06.drizzle-orm",[297,300,304,308,312,316,320,324,328],{"title":298,"path":293,"stem":299},"Drizzle Overview","02.runtypes\u002F06.drizzle-orm\u002F00.drizzle-overview",{"title":301,"path":302,"stem":303},"Column Formats","\u002Fruntypes\u002Fdrizzle-orm\u002Fcolumn-formats","02.runtypes\u002F06.drizzle-orm\u002F01.column-formats",{"title":305,"path":306,"stem":307},"Views","\u002Fruntypes\u002Fdrizzle-orm\u002Fviews","02.runtypes\u002F06.drizzle-orm\u002F02.views",{"title":309,"path":310,"stem":311},"Indexes and Constraints","\u002Fruntypes\u002Fdrizzle-orm\u002Fconstraints","02.runtypes\u002F06.drizzle-orm\u002F03.constraints",{"title":313,"path":314,"stem":315},"Row Level Security","\u002Fruntypes\u002Fdrizzle-orm\u002Frow-level-security","02.runtypes\u002F06.drizzle-orm\u002F04.row-level-security",{"title":317,"path":318,"stem":319},"Relations","\u002Fruntypes\u002Fdrizzle-orm\u002Frelations","02.runtypes\u002F06.drizzle-orm\u002F05.relations",{"title":321,"path":322,"stem":323},"The Schema File","\u002Fruntypes\u002Fdrizzle-orm\u002Fschema-file","02.runtypes\u002F06.drizzle-orm\u002F06.schema-file",{"title":325,"path":326,"stem":327},"Migrate an Existing Schema","\u002Fruntypes\u002Fdrizzle-orm\u002Fmigrate-an-existing-schema","02.runtypes\u002F06.drizzle-orm\u002F07.migrate-an-existing-schema",{"title":329,"path":330,"stem":331},"Cloudflare D1 and Durable Objects","\u002Fruntypes\u002Fdrizzle-orm\u002Fcloudflare-storage","02.runtypes\u002F06.drizzle-orm\u002F08.cloudflare-storage",{"title":333,"icon":334,"redirect":335,"path":336,"stem":337,"children":338,"page":24},"Diagnostics","i-lucide-triangle-alert","\u002Fruntypes\u002Fdiagnostics\u002Ferror-levels","\u002Fruntypes\u002Fdiagnostics","02.runtypes\u002F08.diagnostics",[339,342],{"title":340,"path":335,"stem":341},"Error Levels","02.runtypes\u002F08.diagnostics\u002F01.error-levels",{"title":343,"path":344,"stem":345},"All Diagnostics","\u002Fruntypes\u002Fdiagnostics\u002Fall-diagnostics","02.runtypes\u002F08.diagnostics\u002F02.all-diagnostics",{"title":347,"icon":348,"path":349,"stem":350,"children":351,"page":24},"Benchmarks","i-lucide-gauge","\u002Fbenchmarks","03.benchmarks",[352,372],{"title":5,"icon":6,"redirect":353,"path":354,"stem":355,"children":356,"page":24},"\u002Fbenchmarks\u002Frpc\u002Fhello-world","\u002Fbenchmarks\u002Frpc","03.benchmarks\u002F02.rpc",[357,360,364,368],{"title":358,"path":353,"stem":359},"Hello World","03.benchmarks\u002F02.rpc\u002F01.hello-world",{"title":361,"path":362,"stem":363},"Light Validation","\u002Fbenchmarks\u002Frpc\u002Flight-validation","03.benchmarks\u002F02.rpc\u002F02.light-validation",{"title":365,"path":366,"stem":367},"Heavy Validation","\u002Fbenchmarks\u002Frpc\u002Fheavy-validation","03.benchmarks\u002F02.rpc\u002F03.heavy-validation",{"title":369,"path":370,"stem":371},"Payload Sizes","\u002Fbenchmarks\u002Frpc\u002Fpayload-sizes","03.benchmarks\u002F02.rpc\u002F04.payload-sizes",{"title":163,"icon":164,"redirect":373,"path":374,"stem":375,"children":376,"page":24},"\u002Fbenchmarks\u002Fruntypes\u002Fis-valid","\u002Fbenchmarks\u002Fruntypes","03.benchmarks\u002F03.runtypes",[377,380,384,388,392,395],{"title":378,"path":373,"stem":379},"Is Valid","03.benchmarks\u002F03.runtypes\u002F01.is-valid",{"title":381,"path":382,"stem":383},"Is Valid Formats","\u002Fbenchmarks\u002Fruntypes\u002Fis-valid-formats","03.benchmarks\u002F03.runtypes\u002F02.is-valid-formats",{"title":385,"path":386,"stem":387},"Get Errors","\u002Fbenchmarks\u002Fruntypes\u002Fget-errors","03.benchmarks\u002F03.runtypes\u002F03.get-errors",{"title":389,"path":390,"stem":391},"Get Errors Formats","\u002Fbenchmarks\u002Fruntypes\u002Fget-errors-formats","03.benchmarks\u002F03.runtypes\u002F04.get-errors-formats",{"title":56,"path":393,"stem":394},"\u002Fbenchmarks\u002Fruntypes\u002Fjson-round-trip","03.benchmarks\u002F03.runtypes\u002F05.json-round-trip",{"title":396,"path":397,"stem":398},"Type Checking","\u002Fbenchmarks\u002Fruntypes\u002Ftype-checking","03.benchmarks\u002F03.runtypes\u002F07.type-checking",{"id":400,"title":74,"body":401,"description":407,"extension":1311,"links":1312,"meta":1313,"navigation":637,"path":75,"seo":1314,"stem":76,"__hash__":1315},"docs\u002F01.rpc\u002F03.middlewares\u002F02.sync-routes.md",{"type":402,"value":403,"toc":1309},"minimark",[404,408,411,414,1305],[405,406,407],"p",{},"Check whether the client and server routes are in sync.",[405,409,410],{},"When you deploy a server where a route's types changed, an app that is already open still sends data in the old shape, and the server may reject or misread it. Use this middleware to stop such a call, so your app can ask the user to reload.",[405,412,413],{},"With each call, the client sends a route sync id: an id for the types of every route it calls. When the server's id differs, the call stops before the route runs and your code gets an error.",[415,416,417,852],"tabs",{},[418,419,420],"tabs-item",{"label":26},[421,422,425,430,444,535,539,554,837],"div",{"className":423},[424],"tab-body",[426,427,429],"h2",{"id":428},"changes-that-stop-a-call","Changes That Stop a Call",[405,431,432,433,437,438,443],{},"The id changes when the route's params type or return type changes, or the way they are encoded. Only the ",[434,435,436],"code",{},"compact"," ",[439,440,442],"a",{"href":441},"\u002Frpc\u002Fserver\u002Fjson-round-trip#parser-strategies","parser"," encodes them differently. In a batch, every route is checked, and one changed route stops the whole batch.",[445,446,447,460],"table",{},[448,449,450],"thead",{},[451,452,453,457],"tr",{},[454,455,456],"th",{},"Change on the server",[454,458,459],{},"The call",[461,462,463,472,479,488,496,511,519,527],"tbody",{},[451,464,465,469],{},[466,467,468],"td",{},"The route's params type",[466,470,471],{},"Stopped",[451,473,474,477],{},[466,475,476],{},"The route's return type",[466,478,471],{},[451,480,481,486],{},[466,482,483,484],{},"The parser of the route or router switches to or from ",[434,485,436],{},[466,487,471],{},[451,489,490,493],{},[466,491,492],{},"mion upgraded, and the client was built with the old version",[466,494,495],{},"Stopped, for every route",[451,497,498,508],{},[466,499,500,501,504,505],{},"The route's options, like a ",[434,502,503],{},"query"," turned into a ",[434,506,507],{},"mutation",[466,509,510],{},"Runs",[451,512,513,516],{},[466,514,515],{},"A middleware's params type",[466,517,518],{},"Runs. The middleware's own validation rejects data that no longer fits.",[451,520,521,524],{},[466,522,523],{},"A route added",[466,525,526],{},"Other routes keep running",[451,528,529,532],{},[466,530,531],{},"The route removed",[466,533,534],{},"Not checked. The call fails because the route is not found.",[426,536,538],{"id":537},"adding-the-middleware","Adding the Middleware",[405,540,541,542,545,546,549,550,553],{},"Add ",[434,543,544],{},"mionSyncRoutes"," from ",[434,547,548],{},"@mionjs\u002Frouter\u002Fmiddlewares"," at the root of your routes. If you also use ",[439,551,552],{"href":71},"mionFetchMetadata",", put that one first.",[555,556,562],"pre",{"className":557,"code":558,"filename":559,"language":560,"meta":561,"style":561},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import {createMionRouter, Routes} from '@mionjs\u002Frouter';\nimport {mionFetchMetadata, mionSyncRoutes} from '@mionjs\u002Frouter\u002Fmiddlewares';\n\nconst mion = createMionRouter();\n\nconst routes = {\n  mionFetchMetadata,\n  \u002F\u002F before your own middleware and routes, so a stopped call runs nothing else\n  mionSyncRoutes,\n  sayHello: mion.route((ctx, name: string): string => `Hello ${name}`),\n} satisfies Routes;\n\nconst myApi = mion.initRoutes(routes);\n\nexport type MyApi = typeof myApi;\n","server.routes.ts","ts","",[434,563,564,606,632,639,661,666,679,688,695,703,770,782,787,809,814],{"__ignoreMap":561},[565,566,569,573,577,581,584,587,590,593,596,600,603],"span",{"class":567,"line":568},"line",1,[565,570,572],{"class":571},"s7zQu","import",[565,574,576],{"class":575},"sMK4o"," {",[565,578,580],{"class":579},"sTEyZ","createMionRouter",[565,582,583],{"class":575},",",[565,585,586],{"class":579}," Routes",[565,588,589],{"class":575},"}",[565,591,592],{"class":571}," from",[565,594,595],{"class":575}," '",[565,597,599],{"class":598},"sfazB","@mionjs\u002Frouter",[565,601,602],{"class":575},"'",[565,604,605],{"class":575},";\n",[565,607,609,611,613,615,617,620,622,624,626,628,630],{"class":567,"line":608},2,[565,610,572],{"class":571},[565,612,576],{"class":575},[565,614,552],{"class":579},[565,616,583],{"class":575},[565,618,619],{"class":579}," mionSyncRoutes",[565,621,589],{"class":575},[565,623,592],{"class":571},[565,625,595],{"class":575},[565,627,548],{"class":598},[565,629,602],{"class":575},[565,631,605],{"class":575},[565,633,635],{"class":567,"line":634},3,[565,636,638],{"emptyLinePlaceholder":637},true,"\n",[565,640,642,646,649,652,656,659],{"class":567,"line":641},4,[565,643,645],{"class":644},"spNyl","const",[565,647,648],{"class":579}," mion ",[565,650,651],{"class":575},"=",[565,653,655],{"class":654},"s2Zo4"," createMionRouter",[565,657,658],{"class":579},"()",[565,660,605],{"class":575},[565,662,664],{"class":567,"line":663},5,[565,665,638],{"emptyLinePlaceholder":637},[565,667,669,671,674,676],{"class":567,"line":668},6,[565,670,645],{"class":644},[565,672,673],{"class":579}," routes ",[565,675,651],{"class":575},[565,677,678],{"class":575}," {\n",[565,680,682,685],{"class":567,"line":681},7,[565,683,684],{"class":579},"  mionFetchMetadata",[565,686,687],{"class":575},",\n",[565,689,691],{"class":567,"line":690},8,[565,692,694],{"class":693},"sHwdD","  \u002F\u002F before your own middleware and routes, so a stopped call runs nothing else\n",[565,696,698,701],{"class":567,"line":697},9,[565,699,700],{"class":579},"  mionSyncRoutes",[565,702,687],{"class":575},[565,704,706,710,713,716,719,722,725,727,731,733,736,738,742,745,747,750,753,756,759,762,765,768],{"class":567,"line":705},10,[565,707,709],{"class":708},"swJcz","  sayHello",[565,711,712],{"class":575},":",[565,714,715],{"class":579}," mion",[565,717,718],{"class":575},".",[565,720,721],{"class":654},"route",[565,723,724],{"class":579},"(",[565,726,724],{"class":575},[565,728,730],{"class":729},"sHdIc","ctx",[565,732,583],{"class":575},[565,734,735],{"class":729}," name",[565,737,712],{"class":575},[565,739,741],{"class":740},"sBMFI"," string",[565,743,744],{"class":575},"):",[565,746,741],{"class":740},[565,748,749],{"class":644}," =>",[565,751,752],{"class":575}," `",[565,754,755],{"class":598},"Hello ",[565,757,758],{"class":575},"${",[565,760,761],{"class":579},"name",[565,763,764],{"class":575},"}`",[565,766,767],{"class":579},")",[565,769,687],{"class":575},[565,771,773,775,778,780],{"class":567,"line":772},11,[565,774,589],{"class":575},[565,776,777],{"class":571}," satisfies",[565,779,586],{"class":740},[565,781,605],{"class":575},[565,783,785],{"class":567,"line":784},12,[565,786,638],{"emptyLinePlaceholder":637},[565,788,790,792,795,797,799,801,804,807],{"class":567,"line":789},13,[565,791,645],{"class":644},[565,793,794],{"class":579}," myApi ",[565,796,651],{"class":575},[565,798,715],{"class":579},[565,800,718],{"class":575},[565,802,803],{"class":654},"initRoutes",[565,805,806],{"class":579},"(routes)",[565,808,605],{"class":575},[565,810,812],{"class":567,"line":811},14,[565,813,638],{"emptyLinePlaceholder":637},[565,815,817,820,823,826,829,832,835],{"class":567,"line":816},15,[565,818,819],{"class":571},"export",[565,821,822],{"class":644}," type",[565,824,825],{"class":740}," MyApi",[565,827,828],{"class":575}," =",[565,830,831],{"class":575}," typeof",[565,833,834],{"class":579}," myApi",[565,836,605],{"class":575},[838,839,840,841,843,844,847,848,718],"tip",{},"Middleware placed before ",[434,842,544],{}," still runs on a stopped call, and so does any middleware with ",[434,845,846],{},"alwaysRun",". See ",[439,849,851],{"href":850},"\u002Frpc\u002Fserver\u002Ferror-handling#stopping-the-request","Stopping the Request",[418,853,854],{"label":78},[421,855,857,861,875,1050,1054,1068,1221,1262,1266,1276,1290,1294],{"className":856},[424],[426,858,860],{"id":859},"setting-up-the-client","Setting Up the Client",[405,862,863,864,545,867,870,871,874],{},"Call ",[434,865,866],{},"useSyncRoutes",[434,868,869],{},"@mionjs\u002Fclient\u002Fmiddlewares"," with the client's ",[434,872,873],{},"middlewares.mionSyncRoutes",". It sends the route sync ids and handles the errors the server answers with.",[555,876,879],{"className":557,"code":877,"filename":878,"language":560,"meta":561,"style":561},"import {isRpcError} from '@mionjs\u002Fcore';\nimport {initClient} from '@mionjs\u002Fclient';\nimport {useSyncRoutes} from '@mionjs\u002Fclient\u002Fmiddlewares';\nimport type {MyApi} from '.\u002Fsync-routes.routes.ts';\n\nconst {routes, middlewares} = initClient\u003CMyApi>({\n  baseURL: 'http:\u002F\u002Flocalhost:3000',\n});\n\u002F\u002F once, next to initClient\nuseSyncRoutes(middlewares.mionSyncRoutes);\n","client.ts",[434,880,881,903,925,945,969,973,1007,1023,1031,1036],{"__ignoreMap":561},[565,882,883,885,887,890,892,894,896,899,901],{"class":567,"line":568},[565,884,572],{"class":571},[565,886,576],{"class":575},[565,888,889],{"class":579},"isRpcError",[565,891,589],{"class":575},[565,893,592],{"class":571},[565,895,595],{"class":575},[565,897,898],{"class":598},"@mionjs\u002Fcore",[565,900,602],{"class":575},[565,902,605],{"class":575},[565,904,905,907,909,912,914,916,918,921,923],{"class":567,"line":608},[565,906,572],{"class":571},[565,908,576],{"class":575},[565,910,911],{"class":579},"initClient",[565,913,589],{"class":575},[565,915,592],{"class":571},[565,917,595],{"class":575},[565,919,920],{"class":598},"@mionjs\u002Fclient",[565,922,602],{"class":575},[565,924,605],{"class":575},[565,926,927,929,931,933,935,937,939,941,943],{"class":567,"line":634},[565,928,572],{"class":571},[565,930,576],{"class":575},[565,932,866],{"class":579},[565,934,589],{"class":575},[565,936,592],{"class":571},[565,938,595],{"class":575},[565,940,869],{"class":598},[565,942,602],{"class":575},[565,944,605],{"class":575},[565,946,947,949,951,953,956,958,960,962,965,967],{"class":567,"line":641},[565,948,572],{"class":571},[565,950,822],{"class":571},[565,952,576],{"class":575},[565,954,955],{"class":579},"MyApi",[565,957,589],{"class":575},[565,959,592],{"class":571},[565,961,595],{"class":575},[565,963,964],{"class":598},".\u002Fsync-routes.routes.ts",[565,966,602],{"class":575},[565,968,605],{"class":575},[565,970,971],{"class":567,"line":663},[565,972,638],{"emptyLinePlaceholder":637},[565,974,975,977,979,982,984,987,989,991,994,997,999,1002,1004],{"class":567,"line":668},[565,976,645],{"class":644},[565,978,576],{"class":575},[565,980,981],{"class":579},"routes",[565,983,583],{"class":575},[565,985,986],{"class":579}," middlewares",[565,988,589],{"class":575},[565,990,828],{"class":575},[565,992,993],{"class":654}," initClient",[565,995,996],{"class":575},"\u003C",[565,998,955],{"class":740},[565,1000,1001],{"class":575},">",[565,1003,724],{"class":579},[565,1005,1006],{"class":575},"{\n",[565,1008,1009,1012,1014,1016,1019,1021],{"class":567,"line":681},[565,1010,1011],{"class":708},"  baseURL",[565,1013,712],{"class":575},[565,1015,595],{"class":575},[565,1017,1018],{"class":598},"http:\u002F\u002Flocalhost:3000",[565,1020,602],{"class":575},[565,1022,687],{"class":575},[565,1024,1025,1027,1029],{"class":567,"line":690},[565,1026,589],{"class":575},[565,1028,767],{"class":579},[565,1030,605],{"class":575},[565,1032,1033],{"class":567,"line":697},[565,1034,1035],{"class":693},"\u002F\u002F once, next to initClient\n",[565,1037,1038,1040,1043,1045,1048],{"class":567,"line":705},[565,1039,866],{"class":654},[565,1041,1042],{"class":579},"(middlewares",[565,1044,718],{"class":575},[565,1046,1047],{"class":579},"mionSyncRoutes)",[565,1049,605],{"class":575},[426,1051,1053],{"id":1052},"handling-a-stopped-call","Handling a Stopped Call",[405,1055,1056,1057,1060,1061,1064,1065,718],{},"A stopped call returns no value. The error is in ",[434,1058,1059],{},"response.mionSyncRoutes",", with the type ",[434,1062,1063],{},"route-types-mismatch"," and the changed route ids in ",[434,1066,1067],{},"errorData.routeIds",[555,1069,1071],{"className":557,"code":1070,"filename":878,"language":560,"meta":561,"style":561},"const [greeting, , response] = await routes.sayHello('Ana').call();\nconst syncError = response.mionSyncRoutes;\n\n\u002F\u002F the route's types changed on the server since this app was built\nif (isRpcError(syncError) && syncError.type === 'route-types-mismatch')\n  location.reload();\nelse console.log(greeting);\n",[434,1072,1073,1127,1144,1148,1153,1189,1203],{"__ignoreMap":561},[565,1074,1075,1077,1080,1083,1085,1088,1091,1094,1096,1099,1102,1104,1107,1109,1111,1114,1116,1118,1120,1123,1125],{"class":567,"line":568},[565,1076,645],{"class":644},[565,1078,1079],{"class":575}," [",[565,1081,1082],{"class":579},"greeting",[565,1084,583],{"class":575},[565,1086,1087],{"class":575}," ,",[565,1089,1090],{"class":579}," response",[565,1092,1093],{"class":575},"]",[565,1095,828],{"class":575},[565,1097,1098],{"class":571}," await",[565,1100,1101],{"class":579}," routes",[565,1103,718],{"class":575},[565,1105,1106],{"class":654},"sayHello",[565,1108,724],{"class":579},[565,1110,602],{"class":575},[565,1112,1113],{"class":598},"Ana",[565,1115,602],{"class":575},[565,1117,767],{"class":579},[565,1119,718],{"class":575},[565,1121,1122],{"class":654},"call",[565,1124,658],{"class":579},[565,1126,605],{"class":575},[565,1128,1129,1131,1134,1136,1138,1140,1142],{"class":567,"line":608},[565,1130,645],{"class":644},[565,1132,1133],{"class":579}," syncError ",[565,1135,651],{"class":575},[565,1137,1090],{"class":579},[565,1139,718],{"class":575},[565,1141,544],{"class":579},[565,1143,605],{"class":575},[565,1145,1146],{"class":567,"line":634},[565,1147,638],{"emptyLinePlaceholder":637},[565,1149,1150],{"class":567,"line":641},[565,1151,1152],{"class":693},"\u002F\u002F the route's types changed on the server since this app was built\n",[565,1154,1155,1158,1161,1163,1166,1169,1172,1174,1177,1180,1182,1184,1186],{"class":567,"line":663},[565,1156,1157],{"class":571},"if",[565,1159,1160],{"class":579}," (",[565,1162,889],{"class":654},[565,1164,1165],{"class":579},"(syncError) ",[565,1167,1168],{"class":575},"&&",[565,1170,1171],{"class":579}," syncError",[565,1173,718],{"class":575},[565,1175,1176],{"class":579},"type ",[565,1178,1179],{"class":575},"===",[565,1181,595],{"class":575},[565,1183,1063],{"class":598},[565,1185,602],{"class":575},[565,1187,1188],{"class":579},")\n",[565,1190,1191,1194,1196,1199,1201],{"class":567,"line":668},[565,1192,1193],{"class":579},"  location",[565,1195,718],{"class":575},[565,1197,1198],{"class":654},"reload",[565,1200,658],{"class":579},[565,1202,605],{"class":575},[565,1204,1205,1208,1211,1213,1216,1219],{"class":567,"line":681},[565,1206,1207],{"class":571},"else",[565,1209,1210],{"class":579}," console",[565,1212,718],{"class":575},[565,1214,1215],{"class":654},"log",[565,1217,1218],{"class":579},"(greeting)",[565,1220,605],{"class":575},[445,1222,1223,1236],{},[448,1224,1225],{},[451,1226,1227,1230,1233],{},[454,1228,1229],{},"Route metadata",[454,1231,1232],{},"What the client does",[454,1234,1235],{},"What you do",[461,1237,1238,1249],{},[451,1239,1240,1243,1246],{},[466,1241,1242],{},"Bundled at build time (the default)",[466,1244,1245],{},"Returns the error.",[466,1247,1248],{},"Reload the app to pick up a newer client build, or ship one.",[451,1250,1251,1256,1259],{},[466,1252,1253,1254],{},"Fetched from the server with ",[439,1255,552],{"href":71},[466,1257,1258],{},"Drops its saved copy, fetches the new metadata and sends the call again, once.",[466,1260,1261],{},"Nothing. You see the error only if the second try fails too.",[426,1263,1265],{"id":1264},"calls-without-ids","Calls Without Ids",[405,1267,1268,1269,1272,1273,1275],{},"A call that sends no id is stopped with ",[434,1270,1271],{},"route-sync-required",". This happens on the first call of a route whose metadata the client has not fetched yet. The error includes the route's metadata, so ",[434,1274,866],{}," saves that metadata and sends the call again.",[1277,1278,1279,1280,1282,1283,1285,1286,1289],"note",{},"Without ",[434,1281,866],{}," the client sends no ids, so every call ends with ",[434,1284,1271],{},". The same goes for any other caller, like ",[434,1287,1288],{},"curl"," or a client in another language.",[426,1291,1293],{"id":1292},"build-check","Build Check",[405,1295,1296,1297,1299,1300,1302,1303,718],{},"When the client bundles route metadata, the build fails with rpc-client-optional-middleware-not-set-up if a route runs ",[434,1298,544],{}," and nothing in the client uses ",[434,1301,873],{},". Look up the name in ",[439,1304,343],{"href":344},[1306,1307,1308],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":561,"searchDepth":608,"depth":608,"links":1310},[],"md",null,{},{"title":74,"description":407},"BYHt6m9Hi4MLjyYwdeyO8koBRSTNKabwkRapUMr7RpA",1793324370026]