All Projects → lexich → Redux Api

lexich / Redux Api

Licence: mit
Flux REST API for redux infrastructure

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Redux Api

Huobi python
Python SDK for Huobi Spot API
Stars: ✭ 391 (-22.11%)
Mutual labels:  api, rest
Purest
REST API Client Library
Stars: ✭ 448 (-10.76%)
Mutual labels:  api, rest
Koa Rest Api Boilerplate
💯 Boilerplate for Node.js Koa RESTful API application with Docker, Swagger, Jest, CodeCov and CircleCI
Stars: ✭ 420 (-16.33%)
Mutual labels:  api, rest
Snickers
🍫 An open source alternative to the video cloud encoding services.
Stars: ✭ 498 (-0.8%)
Mutual labels:  api, rest
Typescript Rest
This is a lightweight annotation-based expressjs extension for typescript.
Stars: ✭ 458 (-8.76%)
Mutual labels:  api, rest
Django Api Domains
A pragmatic styleguide for Django API Projects
Stars: ✭ 365 (-27.29%)
Mutual labels:  api, rest
Jsonplaceholder
A simple online fake REST API server
Stars: ✭ 4,377 (+771.91%)
Mutual labels:  api, rest
Thehivedocs
Documentation of TheHive
Stars: ✭ 353 (-29.68%)
Mutual labels:  api, rest
Django Rest Framework
Web APIs for Django. 🎸
Stars: ✭ 22,406 (+4363.35%)
Mutual labels:  api, rest
Normalizr
Normalizes nested JSON according to a schema
Stars: ✭ 20,721 (+4027.69%)
Mutual labels:  api, flux
Javacord
An easy to use multithreaded library for creating Discord bots in Java.
Stars: ✭ 368 (-26.69%)
Mutual labels:  api, rest
Zerocode
A community-developed, free, open source, microservices API automation and load testing framework built using JUnit core runners for Http REST, SOAP, Security, Database, Kafka and much more. Zerocode Open Source enables you to create, change, orchestrate and maintain your automated test cases declaratively with absolute ease.
Stars: ✭ 482 (-3.98%)
Mutual labels:  api, rest
Vuex Rest Api
A utility to simplify the use of REST APIs with Vuex
Stars: ✭ 365 (-27.29%)
Mutual labels:  api, rest
Diet
A tiny, fast and modular node.js web framework. Good for making fast & scalable apps and apis.
Stars: ✭ 394 (-21.51%)
Mutual labels:  api, rest
Service Proxy
API gateway for REST and SOAP written in Java.
Stars: ✭ 355 (-29.28%)
Mutual labels:  api, rest
Crudl
CRUDL is a backend agnostic REST and GraphQL based admin interface
Stars: ✭ 438 (-12.75%)
Mutual labels:  api, rest
React Refetch
A simple, declarative, and composable way to fetch data for React components
Stars: ✭ 3,418 (+580.88%)
Mutual labels:  api, rest
Loopback Next
LoopBack makes it easy to build modern API applications that require complex integrations.
Stars: ✭ 3,972 (+691.24%)
Mutual labels:  api, rest
Goa
Design-based APIs and microservices in Go
Stars: ✭ 4,493 (+795.02%)
Mutual labels:  api, rest
Gearbox
Gearbox ⚙️ is a web framework written in Go with a focus on high performance
Stars: ✭ 455 (-9.36%)
Mutual labels:  api, rest

Redux-api

Flux REST API for redux infrastructure

Build Status NPM version Coverage Status

Introduction

redux-api solves the problem of writing clients to communicate with backends. It generates actions and reducers for making AJAX calls to API endpoints. You don't need to write a lot of boilerplate code if you use redux and want to exchange data with server.

Inspired by Redux-rest and is intended to be used with Redux.

Documentation

See DOCS.md for API documentation.

Use cases

Install

With npm:

npm install redux-api --save

With bower:

bower install redux-api --save

If you don't use tools like webpack, browserify, etc and you want to load redux-api manually, the best way to add redux-api to your project is:

<script src="(...)/redux-api.min.js"></script>
<script>
  window.ReduxApi = window["redux-api"];
  // or
  var ReduxApi = window["redux-api"];
  // initialization code
</script>

=======

Remote calls

redux-api doesn't bind you to a technology to make AJAX calls. It uses configurable adapters - a pretty simple function which receives 2 arguments: endpoint and options, and returns a Promise as result. The default adapter uses isomorphic-fetch, and has an implementation like this:

function adapterFetch(url, options) {
  return fetch(url, options);
}

However, you are not tied to using isomorphic-fetch. For instance, if you prefer to use jQuery, you can use the following adapter:

function adapterJquery(url, options) {
  return new Promise((success, error)=> {
    $.ajax({ ...options, url, success, error });
  });
}

This implementation allows you to make any request and process any response.

And of course you have to set up adapter to your redux-api instance before using.

  reduxApi(....).use("fetch", adapterFetch)

=======

Examples

examples/isomorphic - React + Redux + React-Router + Redux-api with webpack and express + github API

Example

rest.js

import "isomorphic-fetch";
import reduxApi, {transformers} from "redux-api";
import adapterFetch from "redux-api/lib/adapters/fetch";
export default reduxApi({
  // simple endpoint description
  entry: `/api/v1/entry/:id`,
  // complex endpoint description
  regions: {
    url: `/api/v1/regions`,
    // reimplement default `transformers.object`
    transformer: transformers.array,
    // base endpoint options `fetch(url, options)`
    options: {
      headers: {
        "Accept": "application/json"
      }
    }
  }
}).use("fetch", adapterFetch(fetch));

index.jsx

import React, {PropTypes} from "react";
import { createStore, applyMiddleware, combineReducers } from "redux";
import thunk from "redux-thunk";
import { Provider, connect } from "react-redux";
import rest from "./rest"; //our redux-rest object

const createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
const reducer = combineReducers(rest.reducers);
const store = createStoreWithMiddleware(reducer);

function select(state) {
  return { entry: state.entry, regions: state.regions };
}

class Application {
  static propTypes = {
    entry: PropTypes.shape({
      loading: PropTypes.bool.isRequired,
      data: PropTypes.shape({
        text: PropTypes.string
      }).isRequired
    }).isRequired,
    regions: PropTypes.shape({
      loading: PropTypes.bool.isRequired,
      data: PropTypes.array.isRequired
    }).isRequired,
    dispatch: PropTypes.func.isRequired
  };
  componentDidMount() {
    const {dispatch} = this.props;
    // fetch `/api/v1/regions
    dispatch(rest.actions.regions.sync());
    //specify id for GET: /api/v1/entry/1
    dispatch(rest.actions.entry({id: 1}));
  }
  render() {
    const {entry, regions} = this.props;
    const Regions = regions.data.map((item)=> <p>{ item.name }</p>)
    return (
      <div>
        Loading regions: { regions.loading }
        <Regions/>
        Loading entry: {entry.loading}
        <div>{{ entry.data.text }}</div>
      </div>
    );
  }
}

const SmartComponent = connect(select)(Application);

React.render(
  <Provider store={store}>
    <SmartComponent />
  </Provider>,
  document.getElementById("content")
);

Releases Changelog

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].