Cat-middleware
Middleware of koa server. See more information in code and here.
Middleware
koa-react-render
Render html
with react
and nunjucks
. If you need to use radium
. You will get radiumConfig
as props
to your component
.
Install
nunjucks
react
react-dom
Arguments
component
: This component is used to render to the template.options(default: {})
root(default: './views')
: This is the folder of the templates which is fornunjucks
.renderKey(default: 'content')
: This is the variable in template which will be replace withcomponent
.template(default: 'template.html'
): This is the template of the html.- You can add other variables for your template.
Example
; ...app;...
koa-i18n
Read json file and use it as string. It will read the cookies from client
. You can set i18n
in cookies to change the language.
Arguments
options(default: {})
root(default: './i18n')
: This is the folder of the files.i18n(default: 'en-us')
: This is the default language for this middleware.
Example
; ...app;...// Then you can use `i18n` in your `ctx`.
koa-authentication
Use to check the authentication. You must have user
in ctx.state
and authentication
in user
. You can use koa-passport
to do this.
koa-authentication.configure
- Arguments
authentication_levels(default: {})
: This is used to check the authentication. For example, it will be like{none: 0, user: 1, superuser: 999}
.env(default: true)
: If this is false, this middleware will not check the authentication. Remeber to use this withprocess.env.NODE_ENV
.
koa-authentication.set
- Arguments
authentication(default: 'none')
: Use to set authentication inurl
.redirect(default: '/')
: Redirect to the url when user dose not pass the authentication.
Example
; ...app; ...router;...
koa-relay-data
Use to get the data from fetch
with react-relay
.
Install
babel-polyfill
fetch-everywhere
react-relay
Arguments
link
query
variables
Example
; ...app;...// Then you can get the data `graphql_data` in your `ctx`.
License
MIT © hsuting