Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/content/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ export default withMermaid(defineConfig({
items: [
{ text: 'Batch', link: '/docs/plugins/batch' },
{ text: 'Body Compression', link: '/docs/plugins/body-compression' },
{ text: 'Body Limit', link: '/docs/plugins/body-limit' },
{ text: 'CORS', link: '/docs/plugins/cors' },
{ text: 'CSRF Guard', link: '/docs/plugins/csrf-guard' },
{ text: 'Dedupe', link: '/docs/plugins/dedupe' },
{ text: 'OpenAPI Reference', link: '/docs/plugins/openapi-reference' },
{ text: 'Request Compression', link: '/docs/plugins/request-compression' },
{ text: 'Request Headers', link: '/docs/plugins/request-headers' },
{ text: 'Request Limit', link: '/docs/plugins/request-limit' },
{ text: 'Request Validation', link: '/docs/plugins/request-validation' },
{ text: 'Response Headers', link: '/docs/plugins/response-headers' },
{ text: 'Response Validation', link: '/docs/plugins/response-validation' },
Expand Down
32 changes: 0 additions & 32 deletions apps/content/docs/plugins/body-limit.md

This file was deleted.

8 changes: 8 additions & 0 deletions apps/content/docs/plugins/request-compression.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,11 @@ const handler = new RPCHandler(router, {
```

<!--@include: @/shared/common-plugin-handler-compatibility.md -->

::: tip
Combine with the [Request Limit Plugin](/docs/plugins/request-limit) to limit the decompressed payload size.
:::

## Learn More

For implementation details, see the [RequestCompressionLinkPlugin source code](https://github.com/middleapi/orpc/blob/main/packages/client/src/plugins/request-compression.ts) or the [RequestCompressionHandlerPlugin source code](https://github.com/middleapi/orpc/blob/main/packages/server/src/plugins/request-compression.ts).
32 changes: 32 additions & 0 deletions apps/content/docs/plugins/request-limit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Request Limit Plugin

Restricts the size of incoming request bodies to protect the server from oversized payloads.

## Setup

Use `RequestLimitHandlerPlugin` to limit the size of incoming request bodies.

```ts
import { RequestLimitHandlerPlugin } from '@orpc/server/plugins'

const handler = new RPCHandler(router, {
plugins: [
new RequestLimitHandlerPlugin({
/**
* The maximum allowed request body size in bytes.
*/
maxBodySize: 1024 * 1024, // 1MB
}),
],
})
```

<!--@include: @/shared/common-plugin-handler-compatibility.md -->

::: info
When used with [Request Compression](/docs/plugins/request-compression), `maxBodySize` applies to the **decompressed** payload size, not the compressed wire size.
:::

## Learn More

For implementation details, see the [source code](https://github.com/middleapi/orpc/blob/main/packages/server/src/plugins/request-limit.ts).
93 changes: 0 additions & 93 deletions packages/server/src/adapters/fetch/body-limit-plugin.test.ts

This file was deleted.

78 changes: 0 additions & 78 deletions packages/server/src/adapters/fetch/body-limit-plugin.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/server/src/adapters/fetch/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
it('exports RPCHandler, BodyCompressionHandlerPlugin, BodyLimitHandlerPlugin', async () => {
it('exports RPCHandler, BodyCompressionHandlerPlugin', async () => {
await expect(import('.')).resolves.toMatchObject({
RPCHandler: expect.any(Function),
BodyCompressionHandlerPlugin: expect.any(Function),
BodyLimitHandlerPlugin: expect.any(Function),
})
})
1 change: 0 additions & 1 deletion packages/server/src/adapters/fetch/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './body-compression-plugin'
export * from './body-limit-plugin'
export * from './handler'
export * from './plugin'
export * from './rpc-handler'
Loading
Loading