apeman-middleware-react
apeman middleware package for react
Last updated a year ago by okunishinishi .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install apeman-middleware-react 
SYNC missed versions from official npm registry.

apeman-middleware-react

Build Status Code Climate Code Coverage npm Version JS Standard

apeman middleware package for react

Installation

$ npm install apeman-middleware-react --save

Usage

create an middleware instance and attach to server settings like $api of apeman projects.

Apemanfile.js

/** This is an example Apemanfile to use apeman-middleware-react */

'use strict'

const co = require('co')

module.exports = {
  $pkg: { /* ... */ },
  $ui: {
    /* ... */
    ':page_name': co.wrap(function * renderPage (ctx, next) {
      let { params } = ctx
      let PageComponent = require('./example-page-components')[ params[ 'page_name' ] ]
      if (PageComponent) {
        let props = { /* ... */ }
        // Use `.react` method to render react static markup to provided by `apeman-middleware-react` package.
        ctx.react(PageComponent, props)
      } else {
        yield next()
      }
    }),
    $middlewares: [
      require('apeman-middleware-react')({})
    ]
  }
}

Signature

apemanMiddlewareReact(options) -> function

Create an middleware function

Args
Name Type Default Description
options Object {} Optional settings

License

This software is released under the MIT License.

Links

Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (17)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |