@orpc/node 2.0.0-beta.43 → 2.0.0-beta.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  <img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
18
18
  </a>
19
19
  <a href="https://deepwiki.com/middleapi/orpc">
20
- <img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
20
+ <img alt="Ask DeepWiki" src="https://img.shields.io/badge/Ask-DeepWiki-blue" />
21
21
  </a>
22
22
  </div>
23
23
 
@@ -60,10 +60,11 @@ You can read the documentation [here](https://orpc.dev).
60
60
  | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
61
61
  | [@orpc/next](https://www.npmjs.com/package/@orpc/next) | Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data). | [Next.js](https://orpc.dev/docs/integrations/next) |
62
62
  | [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk) | Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools. | [AI SDK](https://orpc.dev/docs/integrations/ai-sdk) |
63
+ | [@orpc/mcp](https://www.npmjs.com/package/@orpc/mcp) | Expose procedures as [MCP](https://modelcontextprotocol.io/) tools. | [MCP](https://orpc.dev/docs/integrations/mcp) |
63
64
  | [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query) | Integrate with [TanStack Query](https://tanstack.com/query/latest). | [TanStack Query](https://orpc.dev/docs/integrations/tanstack-query) |
64
65
  | [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada) | Integrate with [Pinia Colada](https://pinia-colada.esm.dev/). | [Pinia Colada](https://orpc.dev/docs/integrations/pinia-colada) |
65
66
  | [@orpc/swr](https://www.npmjs.com/package/@orpc/swr) | Integrate with [SWR](https://swr.vercel.app/). | [SWR](https://orpc.dev/docs/integrations/swr) |
66
- | [@orpc/experimental-msw](https://www.npmjs.com/package/@orpc/experimental-msw) | Mock procedures with [Mock Service Worker](https://mswjs.io/). | [MSW](https://orpc.dev/docs/integrations/msw) |
67
+ | [@orpc/msw](https://www.npmjs.com/package/@orpc/msw) | Mock procedures with [Mock Service Worker](https://mswjs.io/). | [MSW](https://orpc.dev/docs/integrations/msw) |
67
68
  | [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect) | Integrate with [Effect](https://effect.website/). | [Effect](https://orpc.dev/docs/integrations/effect) |
68
69
  | [@orpc/nest](https://www.npmjs.com/package/@orpc/nest) | Implement your contract with [NestJS](https://nestjs.com/). | [NestJS](https://orpc.dev/docs/integrations/nest) |
69
70
  | [@orpc/node](https://www.npmjs.com/package/@orpc/node) | [Node.js](https://nodejs.org/) plugins for static file serving and large uploads. | [Static File](https://orpc.dev/docs/plugins/static-file), [Tmp File Upload](https://orpc.dev/docs/plugins/tmp-file-upload), [Batch Response Compression](https://orpc.dev/docs/plugins/batch-response-compression) |
@@ -95,27 +96,11 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
95
96
  </tr>
96
97
  </table>
97
98
 
98
- ### Special Sponsors
99
-
100
- <table>
101
- <tr>
102
- <td align="center"><a href="http://twitter.com/rauchg?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guillermo Rauch"><img src="https://avatars.githubusercontent.com/u/13041?u=1ee8d111657cdd02ff6d253df00978d17ee6d722&amp;v=4" width="279" alt="Guillermo Rauch"/><br />Guillermo Rauch</a></td>
103
- </tr>
104
- </table>
105
-
106
- ### Premium Sponsors
107
-
108
- <table>
109
- <tr>
110
- <td align="center"><a href="https://github.com/nexa-ca?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Nexa"><img src="https://avatars.githubusercontent.com/u/199146462?v=4" width="209" alt="Nexa"/><br />Nexa</a></td>
111
- </tr>
112
- </table>
113
-
114
99
  ### Organization Sponsors
115
100
 
116
101
  <table>
117
102
  <tr>
118
- <td align="center"><a href="https://lnmarkets.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="LN Markets"><img src="https://avatars.githubusercontent.com/u/70597625?v=4" width="167" alt="LN Markets"/><br />LN Markets</a></td>
103
+ <td align="center"><a href="https://lnmarkets.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="LN Markets"><img src="https://avatars.githubusercontent.com/u/70597625?v=4" width="209" alt="LN Markets"/><br />LN Markets</a></td>
119
104
  </tr>
120
105
  </table>
121
106
 
@@ -123,27 +108,29 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
123
108
 
124
109
  <table>
125
110
  <tr>
126
- <td align="center"><a href="https://github.com/hrmcdonald?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Reece McDonald"><img src="https://avatars.githubusercontent.com/u/39349270?v=4" width="139" alt="Reece McDonald"/><br />Reece McDonald</a></td>
127
- <td align="center"><a href="https://soymilk.party/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="あわわわとーにゅ"><img src="https://avatars.githubusercontent.com/u/17376330?u=de3353804be889f009f7e0a1582daf04d0ab292d&amp;v=4" width="139" alt="あわわわとーにゅ"/><br />あわわわとーにゅ</a></td>
128
- <td align="center"><a href="https://github.com/nicognaW?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="nk"><img src="https://avatars.githubusercontent.com/u/66731869?u=4699bda3a9092d3ec34fbd959450767bcc8b8b6d&amp;v=4" width="139" alt="nk"/><br />nk</a></td>
129
- <td align="center"><a href="https://supastarter.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="supastarter"><img src="https://avatars.githubusercontent.com/u/110960143?v=4" width="139" alt="supastarter"/><br />supastarter</a></td>
130
- <td align="center"><a href="https://github.com/herrfugbaum?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="herrfugbaum"><img src="https://avatars.githubusercontent.com/u/12859776?u=644dc1666d0220bc0468eb0de3c56b919f635b16&amp;v=4" width="139" alt="herrfugbaum"/><br />herrfugbaum</a></td>
131
- <td align="center"><a href="https://laststance.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryota Murakami"><img src="https://avatars.githubusercontent.com/u/5501268?u=599389e03340734325726ca3f8f423c021d47d7f&amp;v=4" width="139" alt="Ryota Murakami"/><br />Ryota Murakami</a></td>
111
+ <td align="center"><a href="https://github.com/hrmcdonald?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Reece McDonald"><img src="https://avatars.githubusercontent.com/u/39349270?v=4" width="167" alt="Reece McDonald"/><br />Reece McDonald</a></td>
112
+ <td align="center"><a href="https://soymilk.party/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="あわわわとーにゅ"><img src="https://avatars.githubusercontent.com/u/17376330?u=de3353804be889f009f7e0a1582daf04d0ab292d&amp;v=4" width="167" alt="あわわわとーにゅ"/><br />あわわわとーにゅ</a></td>
113
+ <td align="center"><a href="https://github.com/nicognaW?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="nk"><img src="https://avatars.githubusercontent.com/u/66731869?u=4699bda3a9092d3ec34fbd959450767bcc8b8b6d&amp;v=4" width="167" alt="nk"/><br />nk</a></td>
114
+ <td align="center"><a href="https://supastarter.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="supastarter"><img src="https://avatars.githubusercontent.com/u/110960143?v=4" width="167" alt="supastarter"/><br />supastarter</a></td>
115
+ <td align="center"><a href="https://github.com/herrfugbaum?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="herrfugbaum"><img src="https://avatars.githubusercontent.com/u/12859776?u=644dc1666d0220bc0468eb0de3c56b919f635b16&amp;v=4" width="167" alt="herrfugbaum"/><br />herrfugbaum</a></td>
132
116
  </tr>
133
117
  <tr>
134
- <td align="center"><a href="https://cra.mr/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="David Cramer"><img src="https://avatars.githubusercontent.com/u/23610?v=4" width="139" alt="David Cramer"/><br />David Cramer</a></td>
135
- <td align="center"><a href="https://valerii15298.github.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Valerii Petryniak"><img src="https://avatars.githubusercontent.com/u/44531564?u=88ac74d9bacd20401518441907acad21063cd397&amp;v=4" width="139" alt="Valerii Petryniak"/><br />Valerii Petryniak</a></td>
136
- <td align="center"><a href="https://letstri.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Valerii Strilets"><img src="https://avatars.githubusercontent.com/u/13253748?u=c7b10399ccc8f8081e24db94ec32cd9858e86ac3&amp;v=4" width="139" alt="Valerii Strilets"/><br />Valerii Strilets</a></td>
137
- <td align="center"><a href="https://blacklight.sh/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kyle Mistele"><img src="https://avatars.githubusercontent.com/u/18430555?u=3afebeb81de666e35aaac3ed46f14159d7603ffb&amp;v=4" width="139" alt="Kyle Mistele"/><br />Kyle Mistele</a></td>
138
- <td align="center"><a href="https://github.com/christ12938?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="139" alt="christ12938"/><br />christ12938</a></td>
139
- <td align="center"><a href="https://github.com/Ryanjso?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&amp;v=4" width="139" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
118
+ <td align="center"><a href="https://laststance.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryota Murakami"><img src="https://avatars.githubusercontent.com/u/5501268?u=599389e03340734325726ca3f8f423c021d47d7f&amp;v=4" width="167" alt="Ryota Murakami"/><br />Ryota Murakami</a></td>
119
+ <td align="center"><a href="https://cra.mr/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="David Cramer"><img src="https://avatars.githubusercontent.com/u/23610?v=4" width="167" alt="David Cramer"/><br />David Cramer</a></td>
120
+ <td align="center"><a href="https://valerii15298.github.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Valerii Petryniak"><img src="https://avatars.githubusercontent.com/u/44531564?u=88ac74d9bacd20401518441907acad21063cd397&amp;v=4" width="167" alt="Valerii Petryniak"/><br />Valerii Petryniak</a></td>
121
+ <td align="center"><a href="https://letstri.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Valerii Strilets"><img src="https://avatars.githubusercontent.com/u/13253748?u=c7b10399ccc8f8081e24db94ec32cd9858e86ac3&amp;v=4" width="167" alt="Valerii Strilets"/><br />Valerii Strilets</a></td>
122
+ <td align="center"><a href="https://blacklight.sh/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kyle Mistele"><img src="https://avatars.githubusercontent.com/u/18430555?u=3afebeb81de666e35aaac3ed46f14159d7603ffb&amp;v=4" width="167" alt="Kyle Mistele"/><br />Kyle Mistele</a></td>
140
123
  </tr>
141
124
  <tr>
142
- <td align="center"><a href="https://github.com/itigoore01?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&amp;v=4" width="139" alt="shota"/><br />shota</a></td>
143
- <td align="center"><a href="https://github.com/ellis-driscoll?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&amp;v=4" width="139" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
144
- <td align="center"><a href="https://github.com/hoangbn?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&amp;v=4" width="139" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
145
- <td align="center"><a href="https://opencollective.com/guest-ac41de3b?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Orestis Ioannou"><img src="https://images.opencollective.com/guest-ac41de3b/avatar/460.png" width="139" alt="Orestis Ioannou"/><br />Orestis Ioannou</a></td>
146
- <td align="center"><a href="https://automatio.ai/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Stefan Smiljkovic"><img src="https://avatars.githubusercontent.com/u/1984909?u=b7bf5bc40ed49df3c22f69d2da7b8d78709c49ed&amp;v=4" width="139" alt="Stefan Smiljkovic"/><br />Stefan Smiljkovic</a></td>
125
+ <td align="center"><a href="https://github.com/christ12938?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="167" alt="christ12938"/><br />christ12938</a></td>
126
+ <td align="center"><a href="https://github.com/Ryanjso?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&amp;v=4" width="167" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
127
+ <td align="center"><a href="https://github.com/itigoore01?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&amp;v=4" width="167" alt="shota"/><br />shota</a></td>
128
+ <td align="center"><a href="https://github.com/ellis-driscoll?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&amp;v=4" width="167" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
129
+ <td align="center"><a href="https://github.com/hoangbn?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&amp;v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
130
+ </tr>
131
+ <tr>
132
+ <td align="center"><a href="https://opencollective.com/guest-ac41de3b?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Orestis Ioannou"><img src="https://images.opencollective.com/guest-ac41de3b/avatar/460.png" width="167" alt="Orestis Ioannou"/><br />Orestis Ioannou</a></td>
133
+ <td align="center"><a href="https://automatio.ai/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Stefan Smiljkovic"><img src="https://avatars.githubusercontent.com/u/1984909?u=b7bf5bc40ed49df3c22f69d2da7b8d78709c49ed&amp;v=4" width="167" alt="Stefan Smiljkovic"/><br />Stefan Smiljkovic</a></td>
147
134
  </tr>
148
135
  </table>
149
136
 
@@ -151,34 +138,46 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
151
138
 
152
139
  <table>
153
140
  <tr>
154
- <td align="center"><a href="https://github.com/rhinodavid?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="David Walsh"><img src="https://avatars.githubusercontent.com/u/5778036?u=b5521f07d2f88c3db2a0dae62b5f2f8357214af0&amp;v=4" width="119" alt="David Walsh"/><br />David Walsh</a></td>
155
- <td align="center"><a href="https://github.com/IPv4Addr?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="IPv4Addr"><img src="https://avatars.githubusercontent.com/u/100147665?u=59996b72f69bb53063cb7e9ff8b8f898616cd94d&amp;v=4" width="119" alt="IPv4Addr"/><br />IPv4Addr</a></td>
156
- <td align="center"><a href="https://robbevaes.be/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Robbe Vaes"><img src="https://avatars.githubusercontent.com/u/44748019?u=e0232402c045ad4eac7cbd217f1f47e083103b89&amp;v=4" width="119" alt="Robbe Vaes"/><br />Robbe Vaes</a></td>
157
- <td align="center"><a href="https://github.com/aidansunbury?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Aidan Sunbury"><img src="https://avatars.githubusercontent.com/u/64103161?v=4" width="119" alt="Aidan Sunbury"/><br />Aidan Sunbury</a></td>
158
- <td align="center"><a href="https://github.com/soonoo?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="soonoo"><img src="https://avatars.githubusercontent.com/u/5436405?u=5d0b4aa955c87e30e6bda7f0cccae5402da99528&amp;v=4" width="119" alt="soonoo"/><br />soonoo</a></td>
159
- <td align="center"><a href="https://kevinporten.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kevin Porten"><img src="https://avatars.githubusercontent.com/u/1839345?u=dc2263d5cfe0d927ce1a0be04a1d55dd6b55405c&amp;v=4" width="119" alt="Kevin Porten"/><br />Kevin Porten</a></td>
160
- <td align="center"><a href="https://github.com/pumpkinlink?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Denis"><img src="https://avatars.githubusercontent.com/u/11864620?u=5f47bbe6c65d0f6f5cf011021490238e4b0593d0&amp;v=4" width="119" alt="Denis"/><br />Denis</a></td>
141
+ <td align="center"><a href="https://github.com/rhinodavid?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="David Walsh"><img src="https://avatars.githubusercontent.com/u/5778036?u=b5521f07d2f88c3db2a0dae62b5f2f8357214af0&amp;v=4" width="139" alt="David Walsh"/><br />David Walsh</a></td>
142
+ <td align="center"><a href="https://github.com/IPv4Addr?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="IPv4Addr"><img src="https://avatars.githubusercontent.com/u/100147665?u=59996b72f69bb53063cb7e9ff8b8f898616cd94d&amp;v=4" width="139" alt="IPv4Addr"/><br />IPv4Addr</a></td>
143
+ <td align="center"><a href="https://robbevaes.be/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Robbe Vaes"><img src="https://avatars.githubusercontent.com/u/44748019?u=e0232402c045ad4eac7cbd217f1f47e083103b89&amp;v=4" width="139" alt="Robbe Vaes"/><br />Robbe Vaes</a></td>
144
+ <td align="center"><a href="https://github.com/aidansunbury?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Aidan Sunbury"><img src="https://avatars.githubusercontent.com/u/64103161?v=4" width="139" alt="Aidan Sunbury"/><br />Aidan Sunbury</a></td>
145
+ <td align="center"><a href="https://github.com/soonoo?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="soonoo"><img src="https://avatars.githubusercontent.com/u/5436405?u=5d0b4aa955c87e30e6bda7f0cccae5402da99528&amp;v=4" width="139" alt="soonoo"/><br />soonoo</a></td>
146
+ <td align="center"><a href="https://kevinporten.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kevin Porten"><img src="https://avatars.githubusercontent.com/u/1839345?u=dc2263d5cfe0d927ce1a0be04a1d55dd6b55405c&amp;v=4" width="139" alt="Kevin Porten"/><br />Kevin Porten</a></td>
147
+ </tr>
148
+ <tr>
149
+ <td align="center"><a href="https://github.com/pumpkinlink?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Denis"><img src="https://avatars.githubusercontent.com/u/11864620?u=5f47bbe6c65d0f6f5cf011021490238e4b0593d0&amp;v=4" width="139" alt="Denis"/><br />Denis</a></td>
150
+ <td align="center"><a href="https://github.com/christopher-kapic?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Christopher Kapic"><img src="https://avatars.githubusercontent.com/u/59740769?u=e7ad4b72b5bf6c9eb1644c26dbf3332a8f987377&amp;v=4" width="139" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
151
+ <td align="center"><a href="http://ballingt.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Tom Ballinger"><img src="https://avatars.githubusercontent.com/u/458879?u=4b045ac75d721b6ac2b42a74d7d37f61f0414031&amp;v=4" width="139" alt="Tom Ballinger"/><br />Tom Ballinger</a></td>
152
+ <td align="center"><a href="https://lee-sam.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Sam"><img src="https://avatars.githubusercontent.com/u/102863520?u=3c89611f549d5070be232eb4532f690c8f2e7a65&amp;v=4" width="139" alt="Sam"/><br />Sam</a></td>
153
+ <td align="center"><a href="https://github.com/Titoine?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Titoine"><img src="https://avatars.githubusercontent.com/u/3514286?u=1bb1e86b0c99c8a1121372e56d51a177eea12191&amp;v=4" width="139" alt="Titoine"/><br />Titoine</a></td>
154
+ <td align="center"><a href="https://rigtch.fm/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Igor Makowski"><img src="https://avatars.githubusercontent.com/u/56691628?u=ee8c879478f7c151b9156aef6c74243fa3e247a8&amp;v=4" width="139" alt="Igor Makowski"/><br />Igor Makowski</a></td>
161
155
  </tr>
162
156
  <tr>
163
- <td align="center"><a href="https://github.com/christopher-kapic?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Christopher Kapic"><img src="https://avatars.githubusercontent.com/u/59740769?u=e7ad4b72b5bf6c9eb1644c26dbf3332a8f987377&amp;v=4" width="119" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
164
- <td align="center"><a href="http://ballingt.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Tom Ballinger"><img src="https://avatars.githubusercontent.com/u/458879?u=4b045ac75d721b6ac2b42a74d7d37f61f0414031&amp;v=4" width="119" alt="Tom Ballinger"/><br />Tom Ballinger</a></td>
165
- <td align="center"><a href="https://lee-sam.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Sam"><img src="https://avatars.githubusercontent.com/u/102863520?u=3c89611f549d5070be232eb4532f690c8f2e7a65&amp;v=4" width="119" alt="Sam"/><br />Sam</a></td>
166
- <td align="center"><a href="https://github.com/Titoine?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Titoine"><img src="https://avatars.githubusercontent.com/u/3514286?u=1bb1e86b0c99c8a1121372e56d51a177eea12191&amp;v=4" width="119" alt="Titoine"/><br />Titoine</a></td>
167
- <td align="center"><a href="https://rigtch.fm/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Igor Makowski"><img src="https://avatars.githubusercontent.com/u/56691628?u=ee8c879478f7c151b9156aef6c74243fa3e247a8&amp;v=4" width="119" alt="Igor Makowski"/><br />Igor Makowski</a></td>
168
- <td align="center"><a href="https://blog.cwang.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="hanayashiki"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&amp;v=4" width="119" alt="hanayashiki"/><br />hanayashiki</a></td>
169
- <td align="center"><a href="https://dubinets.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Lev Dubinets"><img src="https://avatars.githubusercontent.com/u/3114081?u=f547f5d5012cab54851f1b1ad72d10e537f78fc2&amp;v=4" width="119" alt="Lev Dubinets"/><br />Lev Dubinets</a></td>
157
+ <td align="center"><a href="https://blog.cwang.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="hanayashiki"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&amp;v=4" width="139" alt="hanayashiki"/><br />hanayashiki</a></td>
158
+ <td align="center"><a href="https://dubinets.io/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Lev Dubinets"><img src="https://avatars.githubusercontent.com/u/3114081?u=f547f5d5012cab54851f1b1ad72d10e537f78fc2&amp;v=4" width="139" alt="Lev Dubinets"/><br />Lev Dubinets</a></td>
159
+ <td align="center"><a href="https://kellychan.im/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&amp;v=4" width="139" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
160
+ <td align="center"><a href="https://guyariely.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&amp;v=4" width="139" alt="Guy Ariely"/><br />Guy Ariely</a></td>
161
+ <td align="center"><a href="https://paulsenon.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="PaulSenon"><img src="https://avatars.githubusercontent.com/u/19531087?u=6385741eb91d200b8c513ec6045482e301767ca6&amp;v=4" width="139" alt="PaulSenon"/><br />PaulSenon</a></td>
162
+ <td align="center"><a href="https://nakasyou.how/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Shotaro Nakamura"><img src="https://avatars.githubusercontent.com/u/79000684?u=f644df3f29f0e8677a90967115774564f1d9d6ab&amp;v=4" width="139" alt="Shotaro Nakamura"/><br />Shotaro Nakamura</a></td>
170
163
  </tr>
171
164
  <tr>
172
- <td align="center"><a href="https://kellychan.im/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&amp;v=4" width="119" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
173
- <td align="center"><a href="https://guyariely.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&amp;v=4" width="119" alt="Guy Ariely"/><br />Guy Ariely</a></td>
174
- <td align="center"><a href="https://paulsenon.com/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="PaulSenon"><img src="https://avatars.githubusercontent.com/u/19531087?u=6385741eb91d200b8c513ec6045482e301767ca6&amp;v=4" width="119" alt="PaulSenon"/><br />PaulSenon</a></td>
175
- <td align="center"><a href="https://nakasyou.how/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Shotaro Nakamura"><img src="https://avatars.githubusercontent.com/u/79000684?u=f644df3f29f0e8677a90967115774564f1d9d6ab&amp;v=4" width="119" alt="Shotaro Nakamura"/><br />Shotaro Nakamura</a></td>
176
- <td align="center"><a href="https://piscis.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="119" alt="Alex"/><br />Alex</a></td>
177
- <td align="center"><a href="https://opensource.gubanov.eu/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&amp;v=4" width="119" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
165
+ <td align="center"><a href="https://piscis.dev/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="139" alt="Alex"/><br />Alex</a></td>
166
+ <td align="center"><a href="https://opensource.gubanov.eu/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&amp;v=4" width="139" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
178
167
  </tr>
179
168
  </table>
180
169
 
181
- With thanks to [38 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
170
+ With thanks to [40 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
171
+
172
+ ## Open Source Programs
173
+
174
+ [middleapi](https://github.com/middleapi) is supported by these open source programs:
175
+
176
+ <table>
177
+ <tr>
178
+ <td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude for Open Source</a></td>
179
+ </tr>
180
+ </table>
182
181
 
183
182
  ## References
184
183
 
package/dist/index.d.mts CHANGED
@@ -11,7 +11,7 @@ interface BatchResponseCompressionHandlerPluginOptions {
11
11
  *
12
12
  * @default ['gzip', 'deflate']
13
13
  */
14
- encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
14
+ encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[] | undefined;
15
15
  /**
16
16
  * The minimum response size in bytes required to trigger compression.
17
17
  * Responses smaller than this threshold will not be compressed to avoid overhead.
@@ -19,7 +19,7 @@ interface BatchResponseCompressionHandlerPluginOptions {
19
19
  *
20
20
  * @default 1024 (1KB)
21
21
  */
22
- threshold?: number;
22
+ threshold?: number | undefined;
23
23
  }
24
24
  /**
25
25
  * Compresses every successful [batch](https://orpc.dev/docs/plugins/batch) response, which the
@@ -60,27 +60,27 @@ interface StaticFileHandlerPluginOptions {
60
60
  *
61
61
  * @default '/'
62
62
  */
63
- path?: `/${string}`;
63
+ path?: `/${string}` | undefined;
64
64
  /**
65
65
  * The file served when the request path resolves to a directory.
66
66
  * Set to `false` to disable directory index files.
67
67
  *
68
68
  * @default 'index.html'
69
69
  */
70
- indexFile?: string | false;
70
+ indexFile?: string | false | undefined;
71
71
  /**
72
72
  * A file served with status 200 when no file matches the request path,
73
73
  * relative to `rootDir`. Useful for single-page application routing.
74
74
  *
75
75
  * @default undefined
76
76
  */
77
- fallbackFile?: string;
77
+ fallbackFile?: string | undefined;
78
78
  /**
79
79
  * The `Cache-Control` response header value. Set to `false` to omit the header.
80
80
  *
81
81
  * @default 'public, max-age=0'
82
82
  */
83
- cacheControl?: string | false;
83
+ cacheControl?: string | false | undefined;
84
84
  /**
85
85
  * Whether files and directories whose name starts with a dot can be served.
86
86
  * When disabled, names shaped like 8.3 short names, such as `ENV~1`, are refused too,
@@ -88,28 +88,28 @@ interface StaticFileHandlerPluginOptions {
88
88
  *
89
89
  * @default false
90
90
  */
91
- dotfiles?: boolean;
91
+ dotfiles?: boolean | undefined;
92
92
  /**
93
93
  * Whether precompressed sidecar files (`.br`, `.zst`, `.gz`) can be served
94
94
  * when the client accepts their encoding and the content type is compressible.
95
95
  *
96
96
  * @default false
97
97
  */
98
- precompressed?: boolean;
98
+ precompressed?: boolean | undefined;
99
99
  /**
100
100
  * Whether symbolic links whose target lies outside `rootDir` can be served.
101
101
  * Enabling this makes every file the links reach publicly readable.
102
102
  *
103
103
  * @default false
104
104
  */
105
- allowSymlinks?: boolean;
105
+ allowSymlinks?: boolean | undefined;
106
106
  /**
107
107
  * Content types keyed by lowercase file extension without the dot, taking precedence over
108
108
  * the type detected from the extension. Values are sent verbatim, so a text type needs its
109
109
  * own charset. Extensions that neither this nor the detection recognises are served as
110
110
  * `application/octet-stream`.
111
111
  */
112
- mimeTypes?: Record<string, string>;
112
+ mimeTypes?: Record<string, string> | undefined;
113
113
  }
114
114
  /**
115
115
  * Serves static files from a directory with standard HTTP semantics:
@@ -178,16 +178,18 @@ declare class StaticFileHandlerPlugin<T extends Context> implements StandardHand
178
178
  interface TmpFileUploadHandlerPluginMaxBodySize {
179
179
  /**
180
180
  * The maximum size in bytes of request body content buffered into memory:
181
- * JSON, URL-encoded forms, and the fields and part headers of a multipart
182
- * body in total, and each event of an event stream on its own. Exceeding it
183
- * rejects with `PAYLOAD_TOO_LARGE`. Usually the lowest of the three limits,
184
- * because this content cannot stream anywhere.
181
+ * JSON, URL-encoded forms, and the fields, part headers, and in-memory files
182
+ * of a multipart body in total, and each event of an event stream on its
183
+ * own. Exceeding it rejects with `PAYLOAD_TOO_LARGE`, except for uploads,
184
+ * which spool to disk instead once they no longer fit. Usually the lowest of
185
+ * the three limits, because this content cannot stream anywhere.
185
186
  */
186
187
  memory: number;
187
188
  /**
188
- * The maximum total size in bytes of upload content a request streams into
189
- * temporary files: file bodies and the file parts of a multipart body
190
- * combined. A larger body rejects the request with `PAYLOAD_TOO_LARGE`.
189
+ * The maximum total size in bytes of uploaded file content: file bodies and
190
+ * the file parts of a multipart body combined, whether held in memory or
191
+ * spooled to temporary files. A larger body rejects the request with
192
+ * `PAYLOAD_TOO_LARGE`.
191
193
  */
192
194
  file: number;
193
195
  /**
@@ -207,7 +209,7 @@ interface TmpFileUploadHandlerPluginOptions<T extends Context> {
207
209
  *
208
210
  * @default os.tmpdir()
209
211
  */
210
- tmpDir?: string;
212
+ tmpDir?: string | undefined;
211
213
  /**
212
214
  * The size limit for each kind of request body, either fixed or resolved
213
215
  * per request, so limits can follow the request itself, such as a larger
@@ -222,7 +224,16 @@ interface TmpFileUploadHandlerPluginOptions<T extends Context> {
222
224
  *
223
225
  * @default unlimited for every kind
224
226
  */
225
- maxBodySize?: Value<Promisable<TmpFileUploadHandlerPluginMaxBodySize>, [options: StandardHandlerRoutingInterceptorOptions<T>]>;
227
+ maxBodySize?: Value<Promisable<TmpFileUploadHandlerPluginMaxBodySize>, [options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
228
+ /**
229
+ * The size in bytes an uploaded file must exceed before it is spooled to a
230
+ * temporary file. Smaller files stay in memory as plain `File`s, counted
231
+ * against `maxBodySize.memory`, and spool anyway once they no longer fit.
232
+ * Set to `0` to spool every non-empty upload.
233
+ *
234
+ * @default 64 * 1024
235
+ */
236
+ spoolThreshold?: number | undefined;
226
237
  }
227
238
  /**
228
239
  * A `File` whose content lives in a temporary file on disk and is read lazily,
@@ -257,12 +268,13 @@ declare class TmpFile extends File {
257
268
  /**
258
269
  * Parses file uploads into temporary files instead of memory. Bodies the standard
259
270
  * body parser would buffer into an in-memory `File`, and multipart file parts, are
260
- * streamed to disk and surfaced as lazily read {@link TmpFile} instances, so requests
261
- * far larger than available memory parse in constant memory. Every other body is left
262
- * to the standard parser.
271
+ * streamed to disk once they outgrow the spool threshold and surfaced as lazily read
272
+ * {@link TmpFile} instances, so requests far larger than available memory parse in
273
+ * constant memory. Smaller uploads stay in memory as plain `File`s. Every other body is
274
+ * left to the standard parser.
263
275
  *
264
- * Request body sizes are limited per content category: buffered in memory, spooled
265
- * to disk, and streamed, each limit fixed or resolved per request. This subsumes the
276
+ * Request body sizes are limited per content category: buffered in memory, uploaded
277
+ * files, and streamed, each limit fixed or resolved per request. This subsumes the
266
278
  * request limit plugin while sizing each kind of body to what it actually costs.
267
279
  *
268
280
  * @remarks
@@ -287,6 +299,7 @@ declare class TmpFileUploadHandlerPlugin<T extends Context> implements StandardH
287
299
  before: string[];
288
300
  private readonly tmpDir;
289
301
  private readonly maxBodySize;
302
+ private readonly spoolThreshold;
290
303
  constructor(options?: TmpFileUploadHandlerPluginOptions<T>);
291
304
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
292
305
  private resolveBody;
@@ -295,7 +308,7 @@ declare class TmpFileUploadHandlerPlugin<T extends Context> implements StandardH
295
308
  * raw bytes before handing them back for regular parsing.
296
309
  */
297
310
  private parseLimitedBody;
298
- private spoolFileBody;
311
+ private parseFileBody;
299
312
  private parseMultipartBody;
300
313
  }
301
314
 
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ interface BatchResponseCompressionHandlerPluginOptions {
11
11
  *
12
12
  * @default ['gzip', 'deflate']
13
13
  */
14
- encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
14
+ encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[] | undefined;
15
15
  /**
16
16
  * The minimum response size in bytes required to trigger compression.
17
17
  * Responses smaller than this threshold will not be compressed to avoid overhead.
@@ -19,7 +19,7 @@ interface BatchResponseCompressionHandlerPluginOptions {
19
19
  *
20
20
  * @default 1024 (1KB)
21
21
  */
22
- threshold?: number;
22
+ threshold?: number | undefined;
23
23
  }
24
24
  /**
25
25
  * Compresses every successful [batch](https://orpc.dev/docs/plugins/batch) response, which the
@@ -60,27 +60,27 @@ interface StaticFileHandlerPluginOptions {
60
60
  *
61
61
  * @default '/'
62
62
  */
63
- path?: `/${string}`;
63
+ path?: `/${string}` | undefined;
64
64
  /**
65
65
  * The file served when the request path resolves to a directory.
66
66
  * Set to `false` to disable directory index files.
67
67
  *
68
68
  * @default 'index.html'
69
69
  */
70
- indexFile?: string | false;
70
+ indexFile?: string | false | undefined;
71
71
  /**
72
72
  * A file served with status 200 when no file matches the request path,
73
73
  * relative to `rootDir`. Useful for single-page application routing.
74
74
  *
75
75
  * @default undefined
76
76
  */
77
- fallbackFile?: string;
77
+ fallbackFile?: string | undefined;
78
78
  /**
79
79
  * The `Cache-Control` response header value. Set to `false` to omit the header.
80
80
  *
81
81
  * @default 'public, max-age=0'
82
82
  */
83
- cacheControl?: string | false;
83
+ cacheControl?: string | false | undefined;
84
84
  /**
85
85
  * Whether files and directories whose name starts with a dot can be served.
86
86
  * When disabled, names shaped like 8.3 short names, such as `ENV~1`, are refused too,
@@ -88,28 +88,28 @@ interface StaticFileHandlerPluginOptions {
88
88
  *
89
89
  * @default false
90
90
  */
91
- dotfiles?: boolean;
91
+ dotfiles?: boolean | undefined;
92
92
  /**
93
93
  * Whether precompressed sidecar files (`.br`, `.zst`, `.gz`) can be served
94
94
  * when the client accepts their encoding and the content type is compressible.
95
95
  *
96
96
  * @default false
97
97
  */
98
- precompressed?: boolean;
98
+ precompressed?: boolean | undefined;
99
99
  /**
100
100
  * Whether symbolic links whose target lies outside `rootDir` can be served.
101
101
  * Enabling this makes every file the links reach publicly readable.
102
102
  *
103
103
  * @default false
104
104
  */
105
- allowSymlinks?: boolean;
105
+ allowSymlinks?: boolean | undefined;
106
106
  /**
107
107
  * Content types keyed by lowercase file extension without the dot, taking precedence over
108
108
  * the type detected from the extension. Values are sent verbatim, so a text type needs its
109
109
  * own charset. Extensions that neither this nor the detection recognises are served as
110
110
  * `application/octet-stream`.
111
111
  */
112
- mimeTypes?: Record<string, string>;
112
+ mimeTypes?: Record<string, string> | undefined;
113
113
  }
114
114
  /**
115
115
  * Serves static files from a directory with standard HTTP semantics:
@@ -178,16 +178,18 @@ declare class StaticFileHandlerPlugin<T extends Context> implements StandardHand
178
178
  interface TmpFileUploadHandlerPluginMaxBodySize {
179
179
  /**
180
180
  * The maximum size in bytes of request body content buffered into memory:
181
- * JSON, URL-encoded forms, and the fields and part headers of a multipart
182
- * body in total, and each event of an event stream on its own. Exceeding it
183
- * rejects with `PAYLOAD_TOO_LARGE`. Usually the lowest of the three limits,
184
- * because this content cannot stream anywhere.
181
+ * JSON, URL-encoded forms, and the fields, part headers, and in-memory files
182
+ * of a multipart body in total, and each event of an event stream on its
183
+ * own. Exceeding it rejects with `PAYLOAD_TOO_LARGE`, except for uploads,
184
+ * which spool to disk instead once they no longer fit. Usually the lowest of
185
+ * the three limits, because this content cannot stream anywhere.
185
186
  */
186
187
  memory: number;
187
188
  /**
188
- * The maximum total size in bytes of upload content a request streams into
189
- * temporary files: file bodies and the file parts of a multipart body
190
- * combined. A larger body rejects the request with `PAYLOAD_TOO_LARGE`.
189
+ * The maximum total size in bytes of uploaded file content: file bodies and
190
+ * the file parts of a multipart body combined, whether held in memory or
191
+ * spooled to temporary files. A larger body rejects the request with
192
+ * `PAYLOAD_TOO_LARGE`.
191
193
  */
192
194
  file: number;
193
195
  /**
@@ -207,7 +209,7 @@ interface TmpFileUploadHandlerPluginOptions<T extends Context> {
207
209
  *
208
210
  * @default os.tmpdir()
209
211
  */
210
- tmpDir?: string;
212
+ tmpDir?: string | undefined;
211
213
  /**
212
214
  * The size limit for each kind of request body, either fixed or resolved
213
215
  * per request, so limits can follow the request itself, such as a larger
@@ -222,7 +224,16 @@ interface TmpFileUploadHandlerPluginOptions<T extends Context> {
222
224
  *
223
225
  * @default unlimited for every kind
224
226
  */
225
- maxBodySize?: Value<Promisable<TmpFileUploadHandlerPluginMaxBodySize>, [options: StandardHandlerRoutingInterceptorOptions<T>]>;
227
+ maxBodySize?: Value<Promisable<TmpFileUploadHandlerPluginMaxBodySize>, [options: StandardHandlerRoutingInterceptorOptions<T>]> | undefined;
228
+ /**
229
+ * The size in bytes an uploaded file must exceed before it is spooled to a
230
+ * temporary file. Smaller files stay in memory as plain `File`s, counted
231
+ * against `maxBodySize.memory`, and spool anyway once they no longer fit.
232
+ * Set to `0` to spool every non-empty upload.
233
+ *
234
+ * @default 64 * 1024
235
+ */
236
+ spoolThreshold?: number | undefined;
226
237
  }
227
238
  /**
228
239
  * A `File` whose content lives in a temporary file on disk and is read lazily,
@@ -257,12 +268,13 @@ declare class TmpFile extends File {
257
268
  /**
258
269
  * Parses file uploads into temporary files instead of memory. Bodies the standard
259
270
  * body parser would buffer into an in-memory `File`, and multipart file parts, are
260
- * streamed to disk and surfaced as lazily read {@link TmpFile} instances, so requests
261
- * far larger than available memory parse in constant memory. Every other body is left
262
- * to the standard parser.
271
+ * streamed to disk once they outgrow the spool threshold and surfaced as lazily read
272
+ * {@link TmpFile} instances, so requests far larger than available memory parse in
273
+ * constant memory. Smaller uploads stay in memory as plain `File`s. Every other body is
274
+ * left to the standard parser.
263
275
  *
264
- * Request body sizes are limited per content category: buffered in memory, spooled
265
- * to disk, and streamed, each limit fixed or resolved per request. This subsumes the
276
+ * Request body sizes are limited per content category: buffered in memory, uploaded
277
+ * files, and streamed, each limit fixed or resolved per request. This subsumes the
266
278
  * request limit plugin while sizing each kind of body to what it actually costs.
267
279
  *
268
280
  * @remarks
@@ -287,6 +299,7 @@ declare class TmpFileUploadHandlerPlugin<T extends Context> implements StandardH
287
299
  before: string[];
288
300
  private readonly tmpDir;
289
301
  private readonly maxBodySize;
302
+ private readonly spoolThreshold;
290
303
  constructor(options?: TmpFileUploadHandlerPluginOptions<T>);
291
304
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
292
305
  private resolveBody;
@@ -295,7 +308,7 @@ declare class TmpFileUploadHandlerPlugin<T extends Context> implements StandardH
295
308
  * raw bytes before handing them back for regular parsing.
296
309
  */
297
310
  private parseLimitedBody;
298
- private spoolFileBody;
311
+ private parseFileBody;
299
312
  private parseMultipartBody;
300
313
  }
301
314
 
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Duplex } from 'node:stream';
2
2
  import { constants, createGzip, createDeflate, createDeflateRaw } from 'node:zlib';
3
- import { negotiateResponseCompressionEncoding, toCompressedHeaders } from '@orpc/server/plugins';
3
+ import { BATCH_HEADER, negotiateResponseCompressionEncoding, toCompressedHeaders } from '@orpc/server/plugins';
4
4
  import { toArray, stringifyJSON, mergeHttpPath, safeDecodeURIComponent, matchesHttpPathPrefix, safeEncodeURIComponent, isCompressibleContentType, parseAcceptEncodingQualities, isAcceptableEncoding, getTracer, value, isAsyncIteratorObject, override, wrapAsyncIterator, wrapReadableStream } from '@orpc/shared';
5
5
  import { flattenStandardHeader, parseStandardUrl, resolveStandardBodyHint, getFilenameFromContentDisposition } from '@standard-server/core';
6
6
  import { createReadStream, openAsBlob } from 'node:fs';
@@ -32,7 +32,7 @@ class BatchResponseCompressionHandlerPlugin {
32
32
  if (!result.matched) {
33
33
  return result;
34
34
  }
35
- if (flattenStandardHeader(interceptorOptions.request.headers["orpc-batch"]) === void 0) {
35
+ if (flattenStandardHeader(interceptorOptions.request.headers[BATCH_HEADER]) === void 0) {
36
36
  return result;
37
37
  }
38
38
  const response = result.response;
@@ -613,6 +613,7 @@ class TmpFileUploadHandlerPlugin {
613
613
  before = ["~request-limit", "~request-compression"];
614
614
  tmpDir;
615
615
  maxBodySize;
616
+ spoolThreshold;
616
617
  constructor(options = {}) {
617
618
  this.tmpDir = options.tmpDir ?? tmpdir();
618
619
  this.maxBodySize = options.maxBodySize ?? {
@@ -620,6 +621,7 @@ class TmpFileUploadHandlerPlugin {
620
621
  file: Number.POSITIVE_INFINITY,
621
622
  stream: Number.POSITIVE_INFINITY
622
623
  };
624
+ this.spoolThreshold = options.spoolThreshold ?? 64 * 1024;
623
625
  }
624
626
  init(options) {
625
627
  const routingInterceptor = async ({ next, ...interceptorOptions }) => {
@@ -687,7 +689,7 @@ class TmpFileUploadHandlerPlugin {
687
689
  return this.parseMultipartBody(request, tmpFiles, maxBodySize);
688
690
  }
689
691
  if (resolvedHint === "file") {
690
- return this.spoolFileBody(request, tmpFiles, maxBodySize.file);
692
+ return this.parseFileBody(request, tmpFiles, maxBodySize);
691
693
  }
692
694
  if (resolvedHint === "json" || resolvedHint === "url-search-params") {
693
695
  return this.parseLimitedBody(request, hint, resolvedHint, maxBodySize.memory);
@@ -714,8 +716,8 @@ class TmpFileUploadHandlerPlugin {
714
716
  });
715
717
  return toStandardBody(response, { hint: resolvedHint });
716
718
  }
717
- async spoolFileBody(request, tmpFiles, fileLimit) {
718
- assertContentLengthWithin(request.headers, fileLimit);
719
+ async parseFileBody(request, tmpFiles, maxBodySize) {
720
+ assertContentLengthWithin(request.headers, maxBodySize.file);
719
721
  const stream = await request.resolveBody("octet-stream");
720
722
  if (!(stream instanceof ReadableStream)) {
721
723
  return stream;
@@ -723,12 +725,11 @@ class TmpFileUploadHandlerPlugin {
723
725
  const contentDisposition = flattenStandardHeader(request.headers["content-disposition"]);
724
726
  const fileName = contentDisposition !== void 0 ? getFilenameFromContentDisposition(contentDisposition) : void 0;
725
727
  const contentType = flattenStandardHeader(request.headers["content-type"]);
726
- const limited = fileLimit === Number.POSITIVE_INFINITY ? stream : limitStream(stream, fileLimit);
727
- const tmpPath = await tmpFiles.allocate();
728
- for await (const chunk of limited) {
729
- await tmpFiles.append(tmpPath, chunk);
728
+ const upload = new UploadWriter(tmpFiles, new Budget(maxBodySize.memory), new Budget(maxBodySize.file), this.spoolThreshold);
729
+ for await (const chunk of stream) {
730
+ await upload.write(chunk);
730
731
  }
731
- return tmpFiles.seal(tmpPath, fileName ?? "blob", contentType ?? "");
732
+ return upload.end(fileName ?? "blob", contentType ?? "");
732
733
  }
733
734
  async parseMultipartBody(request, tmpFiles, maxBodySize) {
734
735
  const contentType = flattenStandardHeader(request.headers["content-type"]);
@@ -744,21 +745,16 @@ class TmpFileUploadHandlerPlugin {
744
745
  }
745
746
  const limited = totalLimit === Number.POSITIVE_INFINITY ? stream : limitStream(stream, totalLimit);
746
747
  const form = new FormData();
747
- const used = { memory: 0, file: 0 };
748
- const charge = (category, size) => {
749
- used[category] += size;
750
- if (used[category] > maxBodySize[category]) {
751
- throw new ORPCError("PAYLOAD_TOO_LARGE");
752
- }
753
- };
748
+ const memory = new Budget(maxBodySize.memory);
749
+ const file = new Budget(maxBodySize.file);
754
750
  await parseMultipart(limited, boundary, (part) => {
755
751
  const name = part.name;
756
- charge("memory", part.headerSize);
752
+ memory.charge(part.headerSize);
757
753
  if (part.filename === void 0) {
758
754
  const chunks = [];
759
755
  return {
760
756
  write: (chunk) => {
761
- charge("memory", chunk.length);
757
+ memory.charge(chunk.length);
762
758
  chunks.push(Buffer.from(chunk));
763
759
  },
764
760
  end: () => {
@@ -768,16 +764,11 @@ class TmpFileUploadHandlerPlugin {
768
764
  }
769
765
  const filename = part.filename;
770
766
  const type = part.type ?? "text/plain";
771
- let tmpPath;
767
+ const upload = new UploadWriter(tmpFiles, memory, file, this.spoolThreshold);
772
768
  return {
773
- write: async (chunk) => {
774
- charge("file", chunk.length);
775
- tmpPath ??= await tmpFiles.allocate();
776
- await tmpFiles.append(tmpPath, chunk);
777
- },
769
+ write: (chunk) => upload.write(chunk),
778
770
  end: async () => {
779
- tmpPath ??= await tmpFiles.allocate();
780
- form.append(name, await tmpFiles.seal(tmpPath, filename, type));
771
+ form.append(name, await upload.end(filename, type));
781
772
  }
782
773
  };
783
774
  });
@@ -848,7 +839,58 @@ function indexOrEnd(bytes, byte, from) {
848
839
  const index = bytes.indexOf(byte, from);
849
840
  return index === -1 ? bytes.length : index;
850
841
  }
851
- const EMPTY_CHUNK = new Uint8Array(0);
842
+ class Budget {
843
+ constructor(limit) {
844
+ this.limit = limit;
845
+ }
846
+ used = 0;
847
+ charge(size) {
848
+ if (!this.tryCharge(size)) {
849
+ throw new ORPCError("PAYLOAD_TOO_LARGE");
850
+ }
851
+ }
852
+ tryCharge(size) {
853
+ if (this.used + size > this.limit) {
854
+ return false;
855
+ }
856
+ this.used += size;
857
+ return true;
858
+ }
859
+ refund(size) {
860
+ this.used -= size;
861
+ }
862
+ }
863
+ class UploadWriter {
864
+ constructor(tmpFiles, memory, file, spoolThreshold) {
865
+ this.tmpFiles = tmpFiles;
866
+ this.memory = memory;
867
+ this.file = file;
868
+ this.spoolThreshold = spoolThreshold;
869
+ }
870
+ held = [];
871
+ heldSize = 0;
872
+ tmpPath;
873
+ async write(chunk) {
874
+ this.file.charge(chunk.length);
875
+ if (this.tmpPath !== void 0) {
876
+ return this.tmpFiles.append(this.tmpPath, chunk);
877
+ }
878
+ if (this.heldSize + chunk.length <= this.spoolThreshold && this.memory.tryCharge(chunk.length)) {
879
+ this.held.push(Buffer.from(chunk));
880
+ this.heldSize += chunk.length;
881
+ return;
882
+ }
883
+ this.tmpPath = await this.tmpFiles.create(Buffer.concat([...this.held, chunk]));
884
+ this.memory.refund(this.heldSize);
885
+ this.held = [];
886
+ }
887
+ async end(name, type) {
888
+ if (this.tmpPath !== void 0) {
889
+ return this.tmpFiles.seal(this.tmpPath, name, type);
890
+ }
891
+ return new File([Buffer.concat(this.held, this.heldSize)], name, { type });
892
+ }
893
+ }
852
894
  class RequestTmpFiles {
853
895
  constructor(tmpDir) {
854
896
  this.tmpDir = tmpDir;
@@ -858,10 +900,12 @@ class RequestTmpFiles {
858
900
  get inUse() {
859
901
  return this.dir !== void 0;
860
902
  }
861
- async allocate() {
903
+ async create(content) {
862
904
  try {
863
905
  this.dir ??= mkdtemp(path.join(this.tmpDir, "orpc-upload-"));
864
- return path.join(await this.dir, String(this.count++));
906
+ const tmpPath = path.join(await this.dir, String(this.count++));
907
+ await appendFile(tmpPath, content);
908
+ return tmpPath;
865
909
  } catch (cause) {
866
910
  throw new ORPCError("INTERNAL_SERVER_ERROR", { cause });
867
911
  }
@@ -875,7 +919,6 @@ class RequestTmpFiles {
875
919
  }
876
920
  async seal(tmpPath, name, type) {
877
921
  try {
878
- await appendFile(tmpPath, EMPTY_CHUNK);
879
922
  return new TmpFile(await openAsBlob(tmpPath), tmpPath, name, { type });
880
923
  } catch (cause) {
881
924
  throw new ORPCError("INTERNAL_SERVER_ERROR", { cause });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/node",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.43",
4
+ "version": "2.0.0-beta.45",
5
5
  "description": "Node.js plugins for oRPC: static file serving, temporary file uploads, and batch response compression",
6
6
  "license": "MIT",
7
7
  "funding": [
@@ -36,16 +36,16 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@orpc/server": "2.0.0-beta.43",
40
- "@orpc/shared": "2.0.0-beta.43",
41
- "@standard-server/core": "~0.10.2",
42
- "@standard-server/fetch": "~0.10.2",
43
- "@standard-server/node": "~0.10.2",
44
- "mime": "^4.1.0"
39
+ "@orpc/server": "2.0.0-beta.45",
40
+ "@orpc/shared": "2.0.0-beta.45",
41
+ "@standard-server/core": "~0.11.0",
42
+ "@standard-server/fetch": "~0.11.0",
43
+ "@standard-server/node": "~0.11.0",
44
+ "mime": "^4.1.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@orpc/client": "2.0.0-beta.43",
48
- "supertest": "^7.2.2"
47
+ "@orpc/client": "2.0.0-beta.45",
48
+ "supertest": "^7.3.1"
49
49
  },
50
50
  "scripts": {
51
51
  "type:check": "tsc -b"