oRPC Metadata
Enhance your procedures with metadata.
SKILL.mdskills/orpc-metadata/SKILL.md
GitHubMetadata
oRPC procedures support metadata — simple key-value pairs that customize behavior.
Basic Example
import { os } from '@orpc/server'
interface ORPCMetadata {
cache?: boolean
}
const base = os
.$meta<ORPCMetadata>({}) // require initial metadata
.use(async ({ procedure, next, path }, input, output) => {
if (!procedure['~orpc'].meta.cache) {
return await next()
}
const cacheKey = path.join('/') + JSON.stringify(input)
if (db.has(cacheKey)) {
return output(db.get(cacheKey))
}
const result = await next()
db.set(cacheKey, result.output)
return result
})
const example = base
.meta({ cache: true })
.handler(() => {
// Implement your procedure logic
})
.metacan be called multiple times; each call spread-merges new metadata with existing.