You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@charlietango/msw-fastify-middleware

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@charlietango/msw-fastify-middleware

Create a middleware for MSW to use with [Fastify](https://www.fastify.io/).

3.1.0
latest
npmnpm
Version published
Maintainers
2
Created
Source

@charlietango/msw-fastify-middleware

Create a middleware for MSW to use with Fastify.

Usage with SSR Vite

Load the async handlers inside the server file. They will be reloaded on change, so you get the latest data on every request.

import { mswFastifyMiddleware } from '@charlietango/msw-fastify-middleware';

app.all(
  "/api/*",
  mswFastifyMiddleware(async () => {
    const { handlers } = await vite.ssrLoadModule(
      "./src/api/mocks/handlers.ts"
    );
    return handlers;
  })
);

Params

  • handlers Handlers Set the MSW request handlers. Either as an array, or as an async function that returns the handlers.
  • handleRequestOptions Options to pass to the MSW handleRequest function.

FAQs

Package last updated on 09 Feb 2024

Did you know?

Socket

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.

Install

Related posts