npm package: @safagayret/bemirror
Description: Fake mirror your backend, fast
Author: Safa Gayret
Latest version: 2.2.2

# be.mirror

> **Fake mirror your backend, fast.**

![Screenshot](image.png)

**be.mirror** is an ultra-lightweight, zero-backend, local Node.js API mock server built for frontend teams. It allows you to visualize, create, and interact with complex mock endpoints completely locally without the heavy setup of databases or third-party cloud tools.

## ✨ Features

- **Zero Backend Database:** Everything runs in `localStorage` or in a flat `JSON` file.
- **Instant Prod URL Mapping:** Effortlessly configure endpoints to a production format.
- **Live Network Delay Testing:** Set specific request delays (e.g. 500ms) to test your frontend loaders safely.
- **Strict Parameter & Body Validation:** Expect precise queries or payloads; returns HTTP 400 automatically if not met.
- **Export / Import Seamlessly:** Share your endpoint configurations with other developers via JSON without hassle. Merge or overwrite local instances.
- **Code Generator:** Instantly copy valid cURL or JS `fetch()` requests directly from the UI.
- **Responsive UI:** Works nicely on mobile devices and tablets using an intuitive postman-style flow.

## 🚀 Getting Started

### Prerequisites

Make sure you have Node.js installed (v18+ recommended).

### Installation

Install `bemirror` as a development dependency:

```bash
npm install --save-dev @safagayret/bemirror
# or
pnpm add -D @safagayret/bemirror
# or
yarn add -D @safagayret/bemirror
```

### Run the server

Start the mock server directly with `npx`:

```bash
npx @safagayret/bemirror
```

Or add it to your project scripts:

```json
{
  "scripts": {
    "bemirror": "npx @safagayret/bemirror --port=9000"
  }
}
```

Then run:

```bash
npm run bemirror
```

You can also set a custom port:

```bash
npx @safagayret/bemirror --port=9000
```

Once started, open `http://localhost:8000` (or your configured port) to use the UI.

## Data Storage

Your mock data is stored in JSON files in your project root directory:

- `endpoints.json`: Contains your project, entity, and endpoint configurations
- `variables.json`: Contains global variables for use in endpoints

These files are automatically created when you add data through the UI. You can commit them to your repository to share mock configurations with your team.

## 🛠 Usage

- Focus on the **Sidebar**: Create a **Project** first, then an **Entity**, and add your mapped **Endpoints**.
- **Edit your Endpoint:** In the main view, define routing paths, params, and payload rules.
- **Mock URL Test:** Consume APIs by pointing your React/Vue/Svelte frontend directly to the provided **Mock URL**.
- **Proxy Test:** Use the built in proxy to make real network requests to external URLs avoiding standard CORS errors in the browser.

## 🤝 Contributing

Contributions are totally welcome! This is an open-source tool aiming at significantly reducing friction during frontend development phases.

1. Fork the repo and create your feature branch (`git checkout -b feature/amazing-feature`)
2. Commit your changes (`git commit -m 'Added amazing feature'`)
3. Push to the branch (`git push origin feature/amazing-feature`)
4. Open a pull request.

## 📄 License

This project is licensed under the MIT License.