Introduction
Fakelab is a fast, easy-config mock API server for frontend developers. Generate realistic mock data from your TypeScript interfaces with Faker annotations.
Why Fakelab?โ
- ๐ Instant Setup - Get your mock server running in seconds
- ๐๏ธ TypeScript First - Use your existing types and interfaces
- ๐ฆ Lightweight - Minimal dependencies, fast performance
- ๐๏ธ Persistent Database - Built-in database mode with seeding
- ๐ธ Snapshot Real APIs - Capture real API responses as mocks
- ๐งช Perfect for Development - Ideal for local development, prototyping, and frontend testing
Quick Startโ
- Install Fakelab:
npm install fakelab --save-dev
# or
pnpm add -D fakelab
# or
yarn add -D fakelab
- Create a configuration file:
Create fakelab.config.ts in your project root:
import { defineConfig } from "fakelab";
export default defineConfig({
sourcePath: ["./fixtures"],
server: { port: 50001 },
});
- Define your types with Faker annotations:
// fixtures/user.ts
export interface User {
/** @faker string.ulid */
id: string;
/** @faker person.fullName */
name: string;
/** @faker location.streetAddress */
address: string;
/** @faker phone.number */
phone: string;
/** @faker number.int({min:10,max:80}) */
age: number;
}
- Start the server:
npx fakelab serve
That's it! Your mock API is ready to use.
What's Next?โ
- Faker Annotations - Master Faker annotations
- Runtime API - Integrate Fakelab in your frontend code