Switch branches/tags
moleculer-twilio@1.0.10 moleculer-twilio@1.0.9 moleculer-twilio@1.0.8 moleculer-twilio@1.0.7 moleculer-twilio@1.0.6 moleculer-twilio@1.0.5 moleculer-twilio@1.0.4 moleculer-twilio@1.0.3 moleculer-twilio@1.0.2 moleculer-twilio@1.0.1 moleculer-twilio@1.0.0 moleculer-slack@1.1.0 moleculer-slack@1.0.0 moleculer-mail@1.2.1 moleculer-mail@1.2.0 moleculer-mail@1.1.1 moleculer-mail@1.1.0 moleculer-mail@1.0.8 moleculer-mail@1.0.7 moleculer-mail@1.0.6 moleculer-mail@1.0.5 moleculer-mail@1.0.4 moleculer-mail@1.0.3 moleculer-mail@1.0.2 moleculer-mail@1.0.1 moleculer-mail@1.0.0 moleculer-fake@1.0.12 moleculer-fake@1.0.11 moleculer-fake@1.0.10 moleculer-fake@1.0.9 moleculer-fake@1.0.8 moleculer-fake@1.0.7 moleculer-fake@1.0.6 moleculer-fake@1.0.5 moleculer-fake@1.0.4 moleculer-fake@1.0.3 moleculer-fake@1.0.2 moleculer-fake@1.0.1 moleculer-fake@1.0.0 moleculer-elasticsearch@1.1.1 moleculer-elasticsearch@1.1.0 moleculer-elasticsearch@1.0.6 moleculer-elasticsearch@1.0.5 moleculer-elasticsearch@1.0.4 moleculer-elasticsearch@1.0.3 moleculer-elasticsearch@1.0.2 moleculer-elasticsearch@1.0.1 moleculer-elasticsearch@1.0.0 moleculer-db@0.6.3 moleculer-db@0.6.2 moleculer-db@0.6.1 moleculer-db@0.6.0 moleculer-db@0.5.2 moleculer-db@0.5.1 moleculer-db@0.5.0 moleculer-db@0.4.5 moleculer-db@0.4.4 moleculer-db@0.4.3 moleculer-db@0.4.2 moleculer-db@0.4.1 moleculer-db@0.4.0 moleculer-db@0.3.3 moleculer-db@0.3.2 moleculer-db@0.3.1 moleculer-db@0.3.0 moleculer-db@0.2.0 moleculer-db@0.1.3 moleculer-db@0.1.2 moleculer-db@0.1.1 moleculer-db@0.1.0 moleculer-db-adapter-sequelize@0.1.4 moleculer-db-adapter-sequelize@0.1.3 moleculer-db-adapter-sequelize@0.1.2 moleculer-db-adapter-sequelize@0.1.1 moleculer-db-adapter-sequelize@0.1.0 moleculer-db-adapter-mongoose@0.4.4 moleculer-db-adapter-mongoose@0.4.3 moleculer-db-adapter-mongoose@0.4.2 moleculer-db-adapter-mongoose@0.4.1 moleculer-db-adapter-mongoose@0.4.0 moleculer-db-adapter-mongoose@0.3.1 moleculer-db-adapter-mongoose@0.3.0 moleculer-db-adapter-mongoose@0.2.0 moleculer-db-adapter-mongoose@0.1.2 moleculer-db-adapter-mongoose@0.1.1 moleculer-db-adapter-mongoose@0.1.0 moleculer-db-adapter-mongo@0.1.4 moleculer-db-adapter-mongo@0.1.3 moleculer-db-adapter-mongo@0.1.2 moleculer-db-adapter-mongo@0.1.1 moleculer-db-adapter-mongo@0.1.0 moleculer-bull@0.2.2 moleculer-bull@0.2.1 moleculer-bull@0.2.0 moleculer-bull@0.1.8 moleculer-bull@0.1.7 moleculer-bull@0.1.6 moleculer-bull@0.1.5 moleculer-bull@0.1.4 moleculer-bull@0.1.3
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
examples
src
test/unit
.gitignore
LICENSE
README.md
index.js
package-lock.json
package.json

README.md

Moleculer logo

moleculer-fake NPM version

Fake data generator by Fakerator

Install

npm install moleculer-fake --save

Usage

"use strict";

const { ServiceBroker } = require("moleculer");

const broker = new ServiceBroker();

broker.createService(require("moleculer-fake"), { settings: { locale: "es-ES" }});

// Generate a full name
broker.call("fake.name").then(console.log);
/* Result: "Soledad Lozada Tejada" */

// Generate 5 numbers between 0 and 20
broker.call("fake.number", { max: 20, times: 5 }).then(console.log);
/* Result: [ 18, 4, 16, 11, 11 ] */

// Generate 5 unique number between 0 and 10
broker.call("fake.number", { max: 10, utimes: 5 }).then(console.log);
/* Result: [ 5, 1, 4, 8, 0 ] */

// Generate a user name in a specified locale
broker.call("fake.name", { locale: "ru-RU"}).then(console.log);
/* Result: "Лобанова Матвей Николаевна" */

// Generate a complete user object
broker.call("fake.user").then(console.log);
/* Result:
    { 
        firstName: 'Marsha',
        lastName: 'Berge',
        userName: 'marsha_berge35',
        password: 'huhefehuje',
        email: 'marsha.berge@yahoo.com',
        phone: '319.071.6645 x2269',
        dob: 2005-04-07T17:10:26.030Z,
        website: 'http://laurence.biz',
        ip: '236.82.114.84',
        avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/guillemboti/128.jpg',
        gravatar: 'https://www.gravatar.com/avatar/c89beff0132a6eaad9d03e9058b5378e',
        address: 
        { country: 'Tristan da Cunha',
            countryCode: 'TA',
            state: 'Utah',
            city: 'Carrollview',
            street: '317 Veum Lakes Apt. 459',
            zip: '10032',
            geo: { latitude: -57.1798, longitude: -64.1921 } },
        status: false
    }
*/

Try it on Runkit

Settings

Property Description
locale Initial locale to Fakerator (Available values: cs-CZ, de-DE, en-AU, en-CA, es-ES, fr-FR, hu-HU, it-IT, nb-NO, pl-PL, ru-RU, sk-SK, sv-SE)
seed Initial seed value to Fakerator

Actions

Name Params Result Description
fake.boolean likelihoodPercent Boolean Generate a random boolean
fake.number min, max Number Generate a random number
fake.digit - Number Generate a digit (0..9)
fake.letter - String Generate a letter (a..z)
fake.arrayElement array any Give a random element from the array
fake.objectElement object Object Give a random { key: value } from the object
fake.masked mask String Generate a masked string ( a - lowercase letter, A - uppercase letter, 9 - digit, * - letter or digit)
fake.hex length String Generate a random hexadecimal number
fake.string length String Generate a random string
fake.name - String Generate a full name
fake.nameM - String Generate a male full name (*)
fake.nameF - String Generate a female full name (*)
fake.firstName - String Generate a first name
fake.firstNameM - String Generate a male first name (*)
fake.firstNameF - String Generate a female first name (*)
fake.lastName - String Generate a last name
fake.lastNameM - String Generate a male last name (*)
fake.lastNameF - String Generate a female last name (*)
fake.prefix - String Generate a name prefix
fake.suffix - String Generate a name suffix
fake. - String Generate a name suffix
fake.country - String Give a random country name
fake.countryCode - String Give a random country code
fake.countryAndCode - Object Give a random country object
fake.city - String Give a random city
fake.street - String Give a random street address
fake.streetName - String Give a random street name
fake.buildingNumber - String Give a random building number
fake.postCode - String Give a random post code
fake.geoLocation - Object Give a random geolocation
fake.altitude - String Give a random altitude
fake.phoneNumber - String Generate a random phone number
fake.companyName - String Generate a random company name
fake.companySuffix - String Generate a random company name suffix
fake.companySuffix - String Generate a random company name suffix
fake.userName firstName, lastName String Generate a random username
fake.password - String Generate a random password
fake.domain - String Generate a domain name
fake.url - String Generate an URL
fake.email firstName, lastName String Generate an email address
fake.image width, height, category String Generate an image URL
fake.mac - String Generate a MAC address
fake.ip - String Generate an IPv4 address
fake.ipv6 - String Generate an IPv6 address
fake.color - String Generate a random color
fake.avatar - String Give a random avatar URL
fake.gravatar email String Generate a gravatar URL
fake.word - String Give a random word
fake.sentence - String Generate a sentence
fake.paragraph - String Generate a paragraph
fake.uuid - String Generate an UUID
fake.user gender String Generate a User entity
fake.address - String Generate an Address entity
fake.company - String Generate a Company entity
fake.post - String Generate a Post entity
fake.populate template String Populate a template string

(*) - if supported by localization

Test

$ npm test

In development with watching

$ npm run ci

License

The project is available under the MIT license.

Contact

Copyright (c) 2016-2018 MoleculerJS

@moleculerjs @MoleculerJS