[go: up one dir, main page]

chaca
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

🌚 Think your data and let Chaca create it.

😀 Intro

Welcome to Chaca, a powerful Nodejs library that revolutionizes mock data generation for testing and development processes. With Chaca, you can effortlessly generate realistic and diverse fake data to simulate different scenarios for your application.

📦 Installation

npm install chaca

📘 Documentation

Visit our website to read the documentation. Chaca Docs

😎 Usage

import { chaca, modules } from "chaca";

const movieSchema = chaca.schema({
  id: chaca.key(() => modules.id.uuid()),
  authors: {
    type: () => modules.person.fullName({ language: "es" }),
    isArray: { min: 1, max: 3 },
  },
  image: () => modules.image.film(),
  likes: () => modules.datatype.int({ min: 0, max: 500000 }),
  category: chaca.enum(["Horror", "War", "History", "Comedy"]),
  adultMovie: ({ currentFields: docFields }) => {
    return (
      docFields.category === "Horror" ||
      docFields.category === "War" ||
      docFields.category === "Action"
    );
  },
});

// Generate 20 objects with the defined schema
const docs = movieSchema.array(20);

/*
[
  {
    id: "4136cd0b-d90b-4af7-b485-5d1ded8db252",
    authors: ["Olivia Gonzalez Gomez", "Santiago Torres Gil"],
    image: "https://loremflickr.com/480/480/film",
    likes: 21456,
    category: "Horror",
    adultMovie: true,
  },
  ...rest, // 19 more documents
];
*/

// Generate 20 objects and export them in a json file
await movieSchema.export(20, {
  filename: "movies",
  format: "json",
  location: "./folder",
});

🕹️ CLI

See CLI guide

🌐 Try our REST API

If you don't want to use our npm package you can use our REST API to create your mock data

🗂️ Changelog

Detailed changes for each release are documented in the CHANGELOG.md.

Contributing

The Chaca project welcomes all constructive contributions. Contributions take many forms, from code for bug fixes and enhancements, to additions and fixes to documentation, additional tests, triaging incoming pull requests and issues, and more!. See CONTRIBUTING.md

License

MIT

Package Sidebar

Install

npm i chaca

Weekly Downloads

22

Version

2.0.0

License

MIT

Unpacked Size

1.35 MB

Total Files

537

Last publish

Collaborators

  • chaca_ponquin