Skip to main content

Mocky Balboa and Express

How to use Mocky Balboa with your Express server.

Supported versions

≥ 4.0.0

Installation

pnpm add -D @mocky-balboa/server

Usage

import express from "express";
import { mockyBalboaMiddleware, startServer } from "@mocky-balboa/server";

void (async () => {
const app = express();

// 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(3000);
})();