Giter VIP home page Giter VIP logo

redux-express-actions's Introduction

This package let's you to connect your redux actions in express js server

Ations.js from client app

dispatch({type: Actions.FECH_DATA, id, xhr: true})    

Express router in server side

const api = require("biskut/expressMiddleware")

const handler = async ({id}, req, res, next)=>{
    const data = await DB.findById(id)
       return { 
           type: Actions.POST_CREATE_SUCCESS,
           data
    }
})

const myApi = api({
    [Actions.FECH_DATA] :  handler
})

app.use(myApi)

Features

  1. It use action in both server and client to communicate
  2. fetches the data from server automatically when dispatches the action
  3. Reducer can modify the store immediately for server response without any extra handler

Getting started

  1. npm install biskut in both server and client side
  2. Create Actions which can use by both server and client
  3. Update your redux midleware
import createApiMiddleware from 'biskut/reduxMiddleware';

const store = createStore(reducers, initialState, applyMiddleware(
    thunkmiddleware, .... other middleware,
    createApiMiddleware({ url })
));
  1. Update server code
const expressMiddleware = require("biskut/expressMiddleware")
const Actions = require("../src/Actions.json")

const controller = {
    [Actions.FECH_DATA]: <your handler>
}
app.use(api(handlers));

redux-express-actions's People

Contributors

cloud-sk avatar msbadar 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.