redux-effects-aws

1.0.0 • Public • Published

redux-effects-aws

Build status Git tag NPM version Code style

AWS SDK effect driver.

Installation

$ npm install redux-effects-aws

Why

Makes it easy to write testable server side code that interacts with AWS services without mocking or running development services.

Usage

import awsMiddleware, {aws} from 'redux-effects-aws'
import flow, {flo} from 'redux-flo'
import bind from '@f/bind-middleware'
 
const io = bind([
  flow()
  awsMiddleware()
])
 
// run update
io(flo(testableUpdate))
 
// Action creator that updates an s3 object.
function * testableUpdate () {
  // get object
  let data = yield aws('S3', 'getObject', {
    Bucket: 'test-bucket.weo.io',
    Key: 'test.json'
  })
  let obj = JSON.parse(data.BODY.toString())
 
  // update
  obj.foo = 'qux'
 
  // put object
  yield aws('S3', 'putObject', {
    Bucket: 'test-bucket.we.io',
    Key: 'test.json',
    Body: JSON.stringify(obj)
  })
}

API

awsMiddleware (config)

Effect driver.

  • config - global aws config (e.g. region, output...)

Returns: redux effects middleware

aws (service, method, params)

Action creator.

  • service - The service to use. Optionally can be an object with the signature, {service, options}, if you need to specify service options.
  • method - Method to call on service.
  • params - Params to use for call.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i redux-effects-aws

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • yaws