- Read records from database.
- For each record issue HTTP GET for a webservice and recieve a response.
- Store resonses to corresponding document back.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function websiteContext(Component) { | |
class WebsiteContextComponent extends React.Component { | |
static propTypes = { | |
dispatch: PropTypes.func.isRequired, | |
state: PropTypes.object.isRequire, | |
params: PropTypes.shape({ | |
websiteId: PropTypes.string.isRequired | |
}) | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes = ( | |
<Route path=""> | |
<Route path="/signup" component={SignUp} /> | |
<Route path="/signin" component={SignIn} /> | |
// applied here.. | |
<Route path="/welcome-on-board" component={checkBoarded(Welcome, { withValue: true, redirectTo: '/app/dashboard'}) } /> | |
<Route path="/forgot-password" component={ForgotPassword} /> | |
<Route path="/signout" component={SignOut} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function checkBoarded(Component, { withValue, redirectTo }) { | |
class CompletedComponent extends React.Component { | |
static propTypes = { | |
state: PropTypes.object.isRequired, | |
dispatch: PropTypes.func.isRequired | |
}; | |
componentDidMount() { | |
this._checkAndRedirect(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_checkAndRedirect() { | |
const { dispatch, user } = this.props; | |
const { role, redirectTo } = options; | |
if (!user || !user.role === role) { | |
dispatch(push(redirectTo || '/signin')); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Route path="/app" component={requiresAuth(App, { role: 'user', redirectTo: '/signin' })}> | |
<Route name="dashboard" path="dashboard" component={Dashboard} /> | |
<Route name="invoices" path="user-profile" component={UserProfile} /> | |
</Route> | |
<Route path="/config" component={requiresAuth(Config, { role: 'admin', redirectTo: '/app' })}> | |
<Route name="page" path="page" component={PageConfig} /> | |
</Route> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes = ( | |
<Route path=""> | |
<Route path="/signup" component={SignUp} /> | |
<Route path="/signin" component={SignIn} /> | |
<Route path="/welcome-on-board" component={Welcome} /> | |
<Route path="/forgot-password" component={ForgotPassword} /> | |
<Route path="/signout" component={SignOut} /> /* App component is wrapped | |
with requiresAuth() */ | |
<Route path="/app" component={requiresAuth(App)}> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropTypes } from 'react'; | |
import { connect } from 'react-redux'; | |
import { push } from 'react-router-redux'; | |
export default function requiresAuth(Component) { | |
class AuthenticatedComponent extends React.Component { | |
static propTypes = { | |
user: PropTypes.object, | |
dispatch: PropTypes.func.isRequired, | |
}; | |
componentDidMount() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes = ( | |
<Route path=""> | |
{' '} | |
<Route path="/signup" component={SignUp} />{' '} | |
<Route path="/signin" component={SignIn} />{' '} | |
<Route path="/welcome-on-board" component={Welcome} />{' '} | |
<Route path="/forgot-password" component={ForgotPassword} />{' '} | |
<Route path="/signout" component={SignOut} />{' '} | |
<Route path="/" component={App}> | |
{' '} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import domain from '../../domain'; | |
const Handler = { | |
getGroups: (request, reply) => { | |
const groups = domain.groups(request, reply); | |
return Promise.resolve() | |
.then(groups.getGroups) | |
.then(groups.transformMany) | |
.then(groups.reply); |