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
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ updates:
- '@antfu/eslint-config'
- 'eslint-plugin-*'
- '@hey-api/*'
- compression # inline dependency
update-types:
- minor
- patch
1 change: 1 addition & 0 deletions apps/content/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default withMermaid(defineConfig({
{ text: 'Dedupe Requests', link: '/docs/plugins/dedupe-requests' },
{ text: 'Batch Requests', link: '/docs/plugins/batch-requests' },
{ text: 'Client Retry', link: '/docs/plugins/client-retry' },
{ text: 'Compression', link: '/docs/plugins/compression' },
{ text: 'Body Limit', link: '/docs/plugins/body-limit' },
{ text: 'Simple CSRF Protection', link: '/docs/plugins/simple-csrf-protection' },
{ text: 'Strict GET method', link: '/docs/plugins/strict-get-method' },
Expand Down
4 changes: 4 additions & 0 deletions apps/content/docs/plugins/body-limit.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ const handler = new RPCHandler(router, {
],
})
```

::: info
The `handler` can be any supported oRPC handler, such as [RPCHandler](/docs/rpc-handler), [OpenAPIHandler](/docs/openapi/openapi-handler), or another custom handler.
:::
33 changes: 33 additions & 0 deletions apps/content/docs/plugins/compression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: Compression Plugin
description: A plugin for oRPC that compresses response bodies.
---

# Compression Plugin

The **Compression Plugin** compresses response bodies to reduce bandwidth usage and improve performance.

## Import

Depending on your adapter, import the corresponding plugin:

```ts
import { CompressionPlugin } from '@orpc/server/node'
import { CompressionPlugin } from '@orpc/server/fetch'
```
Comment thread
dinwwwh marked this conversation as resolved.

## Setup

Add the plugin to your handler configuration:

```ts
const handler = new RPCHandler(router, {
plugins: [
new CompressionPlugin(),
],
})
```

::: info
The `handler` can be any supported oRPC handler, such as [RPCHandler](/docs/rpc-handler), [OpenAPIHandler](/docs/openapi/openapi-handler), or another custom handler.
:::
9 changes: 9 additions & 0 deletions packages/server/build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
/**
* Disable warnings as errors because we need to inline the `compression` package,
* which is not ESModule-friendly.
*/
failOnWarn: false,
})
2 changes: 2 additions & 0 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@
"cookie": "^1.0.2"
},
"devDependencies": {
"@types/compression": "^1.8.1",
"@types/ws": "^8.18.1",
"compression": "^1.8.1",
"crossws": "^0.4.1",
Comment thread
dinwwwh marked this conversation as resolved.
"next": "^15.4.5",
"supertest": "^7.1.4",
Expand Down
Loading