
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
A utility library for simplifying the mocking of [`@orpc/contract`](https://orpc.unnoq.com) procedures (specifically for OpenAPI-based `orpc` contracts) using [Mock Service Worker (MSW)](https://mswjs.io) for testing. This library is currently designed fo
A utility library for simplifying the mocking of @orpc/contract procedures (specifically for OpenAPI-based orpc contracts) using Mock Service Worker (MSW) for testing. This library is currently designed for OpenAPI orpc and does not support orpc's RPCHandler.
@orpc/contract for type-safe API definitions.orpc procedures.orpc contract types.HttpResponse or Response objects.Install orpc-msw and its peer dependencies:
pnpm add -D orpc-msw @orpc/contract @orpc/openapi-client msw
Here's a quick example of how to use orpc-msw to mock an orpc procedure:
First, define your orpc contract:
// contract.ts
import { os } from "@orpc/server";
import { z } from "zod";
export const myContract = os.router({
greeter: os
.route({ method: "GET", path: "/hello" })
.input(z.object({ name: z.string() }))
.output(z.object({ message: z.string() }))
});
Then, create your MSW handlers using createMSWUtilities:
// msw-handlers.ts
import { setupWorker } from "msw/browser";
import { createMSWUtilities } from "orpc-msw";
import { myContract } from "./contract";
const msw = createMSWUtilities({
router: myContract,
baseUrl: "http://localhost:3000", // Your API base URL
});
export const handlers = [
msw.greeter.handler(({ input }) => ({
message: `Hello, ${input.name}! This is a mock response.`,
})),
];
// In your setup file (e.g., src/mocks/browser.ts for browser environments)
export const worker = setupWorker(...handlers);
Start the worker in your application:
// main.ts or test-setup.ts
import { worker } from "./msw-handlers";
if (import.meta.env.DEV) {
worker.start();
}
For more detailed information, guides, and API reference, please visit the documentation website.
This project is licensed under the MIT License.
FAQs
A utility library for simplifying the mocking of [`@orpc/contract`](https://orpc.unnoq.com) procedures (specifically for OpenAPI-based `orpc` contracts) using [Mock Service Worker (MSW)](https://mswjs.io) for testing. This library is currently designed fo
The npm package orpc-msw receives a total of 38 weekly downloads. As such, orpc-msw popularity was classified as not popular.
We found that orpc-msw demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.