open-index/open-npm huggingface dataset:
npm package: @revolttv/redux-fetch-middleware
Description: Middleware for fetching remote resources
Author: REVOLT TV
Latest version: 1.2.2

# redux-fetch-middleware

[![Build Status](https://travis-ci.org/RevoltTV/redux-fetch-middleware.svg?branch=master)](https://travis-ci.org/RevoltTV/redux-fetch-middleware)
[![Coverage Status](https://coveralls.io/repos/github/RevoltTV/redux-fetch-middleware/badge.svg?branch=master)](https://coveralls.io/github/RevoltTV/redux-fetch-middleware?branch=master)

A middleware for Redux that uses `isomorphic-fetch` to perform network requests

# Usage

Install the package

```
npm install --save @revolttv/redux-fetch-middleware
```

Create the middleware, and then apply it to your store

```
import { applyMiddleware, createStore } from 'redux';
import FetchMiddleware from '@revolttv/redux-fetch-middleware';

let fetchMiddleware = FetchMiddleware({
    // Config
});
let store = createStore(reducers, initialState, applyMiddleware(fetchMiddleware));
```

Specify actions that leverage the middleware

```
function getUser(userId) {
    return {
        type: 'GET_USER',
        fetch: {
            url: `https://example.com/api/users/${userId}`,
            method: 'GET',
            headers: {
                'X-Application-Id': 'abc123'
            },
            auth: (state) => { return `Bearer ${state.auth.token}`; }
        }
    };
}
```

While a request is in flight, an action is emitted in the form of `${action.type}_PENDING`. For example, the action
`GET_USER` would produce an action `GET_USER_PENDING`, with a `payload` of the original action.

If the request completes successfully, the original action is dispatched (`GET_USER`), with the response body in
the payload.

If the request fails (either connection error or HTTP error code returned), then an action in the form of
`${action.type}_FAILURE` is dispatched, with a key `error: true`, and the `payload` being the received error.

## Configuration

When creating the middleware, a configuration object can be passed in to provide some defaults

```
{
    // Specify how the Authorization header is constructed
    auth: (state, action) => { return state.auth.token; },

    // Custom headers that will be applied to all requests
    headers: {
        'X-Your-Header': 'Header Value'
    },

    // How to deal with cookies (see fetch specification)
    credentials: 'include' || 'same-origin' || 'omit'

}
```
npm package: @revolttv/sequelize-to-joi
Description: Converts a sequelize Model schema to a Joi validator
Author: REVOLT TV
Latest version: 2.0.2

# Sequelize to Joi

Takes a Sequelize model and constructs a Joi validator from it

## Usage

```
sequelizeToJoi(model, [options = {}])
```

### Example:

```
import sequelizeToJoi from '@revolttv/sequelize-to-joi';

let model = sequelize.define('YourModel', {
    name: Sequelize.STRING,
    json: {
        type: Sequelize.JSONB,
        sequelizeToJoiOverride: Joi.object({
            here: Joi.string().valid('you','can','override','autogenerated','validators');
        }),
    },
});

let validator = sequelizeToJoi(model);

Joi.validate({
        id: 1,
        name: 'wow',
        nope: 'failure',
        createdAt: '2016-07-22T12:00:00.000Z',
        updatedAt: '2016-07-22T12:00:00.000Z'
    },
    validator,
    (err, result) => {
        console.log(err); // will error out about `nope` key
    }
)

let validator2 = sequelizeToJoi(model, { omitAutoGenerated: true });
Joi.validate({ name: 'wow' , json: { here: "you" } }, validator2, (err, result) => {
    console.log(err); // null
    console.log(result); // { name: 'wow' , json: { here: "you" } }
});
```

### Options

* `omitAssociations` : `bool` : omits associated models from the resulting validation schema (`belongsTo` or `hasOne` associations)
* `omitAutoGenerated` : `bool` : omits automatically generated properties from validation schema (like `id`, `createdAt`, and `updatedAt`)