# mocking_g

> An advanced tool for creating mocked data for server and client.

Latest version **1.3.2** (published 2025-07-07) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install mocking_g
pnpm add mocking_g
yarn add mocking_g
bun add mocking_g
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2025-07-07 |
| First published | 2019-10-17 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 7.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yotam Madmon |
| Maintainers | yotam_madmon |

## Links

- npm: https://www.npmjs.com/package/mocking_g
- Homepage: https://github.com/madmonyotam/mockingG
- npm.io page: https://npm.io/package/mocking_g

## Dependencies (6)

- [cors](https://npm.io/package/cors.md) ^2.8.5
- [faker](https://npm.io/package/faker.md) ^4.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [moment](https://npm.io/package/moment.md) ^2.24.0
- [express](https://npm.io/package/express.md) ^4.17.1
- [express-favicon](https://npm.io/package/express-favicon.md) ^2.0.1

## Recent versions

- 1.3.2 (latest) — 2025-07-07
- 0.2.22 — 2020-07-09
- 0.2.21 — 2020-04-13
- 0.2.20 — 2020-04-05
- 0.2.19 — 2020-03-01
- 0.2.18 — 2020-02-19
- 0.2.17 — 2020-02-17
- 0.2.16 — 2020-02-06
- 0.2.15 — 2020-02-05
- 0.2.14 — 2020-02-05
- 0.2.13 — 2020-01-28
- 0.2.11 — 2020-01-27
- 0.2.10 — 2020-01-27
- 0.2.9 — 2020-01-23
- 0.2.8 — 2020-01-22
- … 39 more at https://npm.io/package/mocking_g/versions

## README

# GEN

## Intro

### In Short
<b>An advanced tool for creating mocked data for server and client.</b>

### In Several More Words

A very powerful and flexible framework that allows defining and generating mocked data easily and quickly. The framework is a generic one, and can be extended programmatically with new types. It is used by firstly creating a schema for our data, and then generating as many instances from that schema as needed.

## Installation

        npm i mocking_g

## Usage

- Just include the library in your project:

        const gen = require('mocking_g');

- Mocking GEN UI will run on [localhost](http://localhost:5588/mocking_G) on port 5588

- Generate your data like so:
```
const library = 'examples';
const schema = 'person';
const persons = gen.generate([library,schema], 10);
```
Or just
```
const persons = gen.generate('examples.person', 10);
```

## Terminology

* <b>Library</b> - a logical layer for separation of schemas.
* <b>Schema</b> - a JSON schema that describes our data. We can create schemas using the UI or programmatically as shown below.
* <b>Type</b> - Schemas are consisted from types. There are built-in types in the library, but we can define new types as shown below as well.

## Examples

An example for a <b>person</b> schema can be something like that: 

```
{
  "uuid": {
    "type": "id"
  },
  "firstName": {
    "type": "firstName"
  },
  "lastName": {
    "type": "lastName"
  },
  "birthDate": {
    "type": "pastDate",
    "value": {
      "dateMask": "DD-MM-YYYY",
      "years": 50
    }
  },
  "country": {
    "type": "country"
  },
  "streetName": {
    "type": "streetName"
  },
  "zipCode": {
    "type": "zipCode"
  },
  "email": {
    "type": "email"
  },
  "company": {
    "type": "company"
  },
  "jobTitle": {
    "type": "jobTitle"
  }
}
```

While the generated data can be something like this: 

```
{
    "uuid": "7f30a631-12c9-42a1-ad2d-a641b85a5647",
    "firstName": "Scot",
    "lastName": "Goodwin",
    "birthDate": "11-01-2008",
    "country": "Palau",
    "streetName": "O'Connell River",
    "zipCode": "66932-6018",
    "email": "Marlon.Marquardt@example.org",
    "company": "Altenwerth, Waelchi and Ledner",
    "jobTitle": "Lead Markets Analyst"
  }
```

## Features

* <b>Generate</b><br>

It is possible to generate data from a schema created programmatically:
```
const schema = {
    name: { type: 'firstName' },
    age: { type: 'number' }
}

const generated = gen.generate(schema, 10);
```
Or use the intuitive GEN UI and create schemas effortlessly.<br>
Then, just reference the schema and generate your data:
```
gen.generate('examples.person', 10);
```
You can set the path on which GEN will save your schemas.
In addition, GEN will use this path to load the schemas on startup.
```
gen.schemas.setPath('C:/your/path/to/folder');

```

* <b>Types</b><br>

Get existing types by:
```
gen.types.getTypes()
```
Or
```
gen.types.getTypesArrangeByGroups() // types belong in a "group"
```
You can also create your own types programmatically:
```
const myRandomNumberType = {
    randomNumber: {
        name: "Random Number",
        generate: (element) => {
            return Math.random();
        },
        group: 'new group'
    }
}

gen.types.addTypes(myRandomNumberType);
```

* <b>Libraries</b><br>

As explained earlier, libraries are just logical layers that can contain your schemas. GEN supports various CRUD operations on libraries, few of them are: 

```
gen.schemas.getAllLibraries();
gen.schemas.removeLibrary(libraryName);
gen.schemas.addLibrary(libraryName);
```

## CLIENT usage

- Use a standard get request

```
axios.get('http://localhost:5588/mocking_G/generate', { library: 'examples', category: 'person', amount: 5 }).then((res)=>{
    console.log(res.data);
})

```

Or directly from a url

```
http://localhost:5588/mocking_G/generate?library=examples&category=person&amount=3
```

#### Coming soon

- Docs and improvements

---
_Source: https://npm.io/package/mocking_g · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
