ali-master/skills/orpc-middleware

Claude Code and agent skill by ali-master/skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Middleware enables reusable and extensible procedures in oRPC.

Install

npx vskill@latest install ali-master/skills/orpc-middleware

SKILL.md

The same SKILL.md was published earlier as ali-master/skills/orpc-middleware.

Middleware in oRPC

Middleware is a powerful feature in oRPC that enables reusable and extensible procedures.

Overview

ts
const authMiddleware = os
.$context<{ something?: string }>() // define dependent-context
.middleware(async ({ context, next }) => {
// before
const result = await next({
context: { user: { id: 1, name: 'John' } }
})
// after
return result
})
const example = os
.use(authMiddleware)
.handler(async ({ context }) => {
const user = context.user
})

Inline Middleware

ts
const example = os
.use(async ({ context, next }) => {
return next()
})
.handler(async ({ context }) => {
// Handler logic
})

Middleware Context

ts
const setting = os
.use(async ({ context, next }) => {
return next({
context: { auth: await auth() }
})
})
.use(async ({ context, next }) => {
if (!context.auth) {
throw new ORPCError('UNAUTHORIZED')
}
return next({ context: { auth: context.auth } })
})
.handler(async ({ context }) => {
console.log(context.auth)
})

Middleware Input

ts
const canUpdate = os.middleware(async ({ context, next }, input: number) => {
return next()
})
const ping = os
.input(z.number())
.use(canUpdate)
.handler(async ({ input }) => {})
// Mapping input
const pong = os
.input(z.object({ id: z.number() }))
.use(canUpdate, input => input.id)
.handler(async ({ input }) => {})

Use .mapInput to adapt middleware:

ts
const mappedCanUpdate = canUpdate.mapInput((input: { id: number }) => input.id)

Middleware Output

ts
const cacheMid = os.middleware(async ({ context, next, path }, input, output) => {
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
})

Concatenation

ts
const concatMiddleware = aMiddleware
.concat(os.middleware(async ({ next }) => next()))
.concat(anotherMiddleware)

Built-in Middlewares

ts
import { onError, onFinish, onStart, onSuccess } from '@orpc/server'
const ping = os
.use(onStart(() => {}))
.use(onSuccess(() => {}))
.use(onError(() => {}))
.use(onFinish(() => {}))
.handler(async ({ context }) => {})

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
9
7-day trend score
17

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ali-master/skills/orpc-middleware/badge)](https://verified-skill.com/skills/ali-master/skills/orpc-middleware)

Something wrong with this skill or its page? Tell us.