Giter VIP home page Giter VIP logo

joinerator's Introduction

JOInerator

Use Joi configurations as the primary record for your data.

The goal of this library is to, without anything more than a joi configuration:

It started as a simple data generator, but I realized the potential to use a single source of truth to both avoid replication within a project and make the work surface much simpler, as well as guarantee consistent validation throughout the application.

Joinerator.FakeData

    const Joinerator = require('joinerator');
    let definition = new Joinerator.FakeData(joiSchema);
    let generatedData = definition.create('my-seed-value');
    //generatedData contains the data we created

Joinerator.SQLTable

    const Joinerator = require('joinerator');
    let definition = new Joinerator.SQLTable(joiSchema);
    let sql = definition.table('my-table-name', 'sql');
    //sql contains the staements we created

Joinerator.API

To bind a specific URL to an already existing express instance(expressInstance):

    const Joinerator = require('joinerator');
    let definition = new Joinerator.Data(joiSchema);
    definition.attach({
        app : expressInstance,
        path : '/url/path/'
    });
    expressInstance.listen(port);
    //now requests to `/url/path/` generate data

Alternatively, given a directory structure:

└── v1
   ├── error.spec.js
   ├── resultSet.spec.js
   ├── transaction.spec.js
   └── user.spec.js

error.spec.js and resultSet.spec.js are special files which tell the API how to wrap result sets and how to return errors.

transaction.spec.js and user.spec.js are just Joi configurations which will be generated via /v1/user/list, /v1/user/:id, /v1/transaction/list and /v1/transaction/:id

const Joinerator = require('joinerator');
new Joinerator.API({
    app: expressInstance,
    directory: '/directory/to/scan'
}, ()=>{
    //dir has been scanned, instance augmented
    expressInstance.listen(port);
});

There aren't many options, everything is currently JSON and incoming validation isn't quite ready yet. Otherwise, go crazy.

Roadmap

  • validate your data
  • generate infinite, validatable, sample data
  • generate table definitions
  • generate DB migrations
  • guarantee an always valid datastore
  • crud backend with expand verb and pluggable sources, caches and streams
  • client library (auto-loading data from store)
  • JSON+comments compatible schema format (JSOSN)
  • support deep JSON in relational DBs
  • reference-free usage*
    • using proxies to replicate infinite data space in async fns

Testing

./node_modules/mocha/bin/mocha

joinerator's People

Contributors

khrome avatar

Stargazers

Tim Ambler avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.