元数据
过程元数据允许你添加可选的过程特定 meta 属性,该属性将在所有 中间件 函数参数中可用。
¥Procedure metadata allows you to add an optional procedure specific meta property which will be available in all middleware function parameters.
提示
如果你想为应用公开与 REST 兼容的端点,请将元数据与 trpc-openapi 一起使用。
¥Use metadata together with trpc-openapi if you want to expose REST-compatible endpoints for your application.
使用类型化元数据创建路由
¥Create router with typed metadata
tsx
tsx
每个路由身份验证设置的示例
¥Example with per route authentication settings
server.tstsx
server.tstsx
默认元、链接和浅合并
¥Default meta, chaining, and shallow merging
你可以为元类型设置默认值,如果你将元链接到基本过程之上,它将进行浅合并。
¥You can set default values for your meta type, and if you chain meta on top of a base procedure it will be shallow merged.
tsx
tsx