Skip to content

Commit 370978b

Browse files
authored
docs: type utility (#178)
1 parent b2e67f7 commit 370978b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

apps/content/docs/procedure.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ const example = os
3737

3838
oRPC supports [Zod](https://github.com/colinhacks/zod), [Valibot](https://github.com/fabian-hiller/valibot), [Arktype](https://github.com/arktypeio/arktype), and any other [Standard Schema](https://github.com/standard-schema/standard-schema?tab=readme-ov-file#what-schema-libraries-implement-the-spec) library for input and output validation.
3939

40+
### `type` Utility
41+
42+
For simple use-case without external libraries, use oRPC’s built-in `type` utility. It takes a mapping function as its first argument:
43+
44+
```ts twoslash
45+
import { os, type } from '@orpc/server'
46+
47+
const example = os
48+
.input(type<{ value: number }>())
49+
.output(type<{ value: number }, number>(({ value }) => value))
50+
.handler(async ({ input }) => input)
51+
```
52+
4053
## Using Middleware
4154

4255
The `.use` method allows you to pass middleware, which must call `next` to continue execution.

0 commit comments

Comments
 (0)