0.1.0 • Published 2 years ago

joinerator v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

JOInerator

Turn Joi configurations into deterministic sample data APIs with little to no effort.

The results are deterministic (the same inputs always produce the same outputs), but not coherent (various fields may not make sense (IE: a zipcode in one location, an area code from another, etc.)).

Programmatic Usage

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

API Attachment

    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

API Usage

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.

Testing

./node_modules/mocha/bin/mocha
0.1.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago