Mocky Balboa and Fastify
How to use Mocky Balboa with your Fastify server.
Supported versions
≥ 3.0.0
Installation
- pnpm
- npm
- yarn
pnpm add -D @mocky-balboa/server
npm install -D @mocky-balboa/server
yarn add -D @mocky-balboa/server
Usage
- TypeScript
- JavaScript
import Fastify from "fastify";
import fastifyExpress from "@fastify/express";
import { mockyBalboaMiddleware, startServer } from "@mocky-balboa/server";
void (async () => {
const app = Fastify();
await fastify.register(fastifyExpress);
// Register the Mocky Balboa middleware
app.use(mockyBalboaMiddleware());
// Start the Mocky Balboa server.
// Pass optional server options here:
// https://api-reference.mockybalboa.com/functions/_mocky-balboa_server.startServer
await startServer();
// Your app goes here
app.listen({ port: 3000 });
})();
import Fastify from "fastify";
import fastifyExpress from "@fastify/express";
import { mockyBalboaMiddleware, startServer } from "@mocky-balboa/server";
(async () => {
const app = Fastify();
await fastify.register(fastifyExpress);
// Register the Mocky Balboa middleware
app.use(mockyBalboaMiddleware());
// Start the Mocky Balboa server.
// Pass optional server options here:
// https://api-reference.mockybalboa.com/functions/_mocky-balboa_server.startServer
await startServer();
// Your app goes here
app.listen({ port: 3000 });
})();
import Fastify from "fastify";
import fastifyExpress from "@fastify/express";
import { mockyBalboaMiddleware, startServer } from "@mocky-balboa/server";
(async () => {
const app = Fastify();
await fastify.register(fastifyExpress);
// Register the Mocky Balboa middleware
app.use(mockyBalboaMiddleware());
// Start the Mocky Balboa server.
// Pass optional server options here:
// https://api-reference.mockybalboa.com/functions/_mocky-balboa_server.startServer
await startServer();
// Your app goes here
app.listen({ port: 3000 });
})();