Skip to content

Commit cf45b53

Browse files
committed
feat(hapi-17): updated the api to be compatible with hapi v17
BREAKING CHANGE: compatibility with the hapi v17 api prevents backwards compatibility with previous hapi versions
1 parent 0ac02ae commit cf45b53

14 files changed

+275
-702
lines changed

README.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
# hapi-react-router
22

3-
hapi route to delegate routing for html content to react-router
3+
[hapi](https://hapijs.com) route to delegate routing for html content to react-router
44

5-
[![npm](https://img.shields.io/npm/v/@travi/hapi-react-router.svg?maxAge=2592000)](https://www.npmjs.com/package/@travi/hapi-react-router)
6-
[![license](https://img.shields.io/github/license/travi/hapi-react-router.svg)](LICENSE)
75
[![Build Status](https://img.shields.io/travis/travi/hapi-react-router.svg?style=flat&branch=master)](https://travis-ci.org/travi/hapi-react-router)
86
[![Codecov](https://img.shields.io/codecov/c/github/travi/hapi-react-router.svg)](https://codecov.io/github/travi/hapi-react-router)
97

10-
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
11-
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
12-
[![Greenkeeper badge](https://badges.greenkeeper.io/travi/hapi-react-router.svg)](https://greenkeeper.io/)
8+
## Usage
139

14-
## Installation
10+
[![npm](https://img.shields.io/npm/v/@travi/hapi-react-router.svg?maxAge=2592000)](https://www.npmjs.com/package/@travi/hapi-react-router)
11+
[![license](https://img.shields.io/github/license/travi/hapi-react-router.svg)](LICENSE)
12+
13+
### Installation
1514

1615
```sh
1716
$ npm install @travi/hapi-react-router -S
1817
```
1918

20-
## Usage
19+
### Register with your [Hapi](https://hapijs.com) v17 server
2120

2221
Include this plugin in the [manifest](https://github.com/hapijs/glue) of your
2322
hapi application to direct all requests to `/html` to a server-side renderer
@@ -30,19 +29,16 @@ will be triggered and rendering will wait for all related requests to complete.
3029
This enables populating the data store based on the components that are mounted
3130
for the current route.
3231

33-
:warning: [a regenerator runtime](https://babeljs.io/docs/plugins/transform-regenerator/)
34-
is required since this package leverages async functions
35-
3632
### Example
3733

3834
```js
3935
export default {
40-
connections: [{port: 8090}],
41-
registrations: [
42-
{plugin: '@travi/hapi-html-request-router'},
43-
{
44-
plugin: {
45-
register: '@travi/hapi-react-router',
36+
server: {port: process.env.PORT},
37+
register: {
38+
plugins: [
39+
{plugin: '@travi/hapi-html-request-router'},
40+
{
41+
plugin: '@travi/hapi-react-router',
4642
options: {
4743
respond: (reply, {renderedContent}) => {
4844
reply.view('layout', {renderedContent});
@@ -63,8 +59,8 @@ export default {
6359
configureStore: ({session}) => createStore(reducer, composeMiddlewares(session))
6460
}
6561
}
66-
}
67-
]
62+
]
63+
}
6864
}
6965
```
7066

@@ -90,7 +86,11 @@ required.
9086
so that your component can inject it into the context through a provider
9187
component.
9288

93-
## Local Development
89+
## Contribution
90+
91+
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
92+
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
93+
[![Greenkeeper badge](https://badges.greenkeeper.io/travi/hapi-react-router.svg)](https://greenkeeper.io/)
9494

9595
### Install dependencies
9696

example/manifest.js

+24-20
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
import {createStore} from 'redux';
2+
import mustache from 'mustache';
23
import respond from './respond';
34
import routes from './routes';
45
import Root from './components/root';
56

67
export default {
7-
connections: [{port: 8090}],
8-
registrations: [
9-
{plugin: 'vision'},
10-
{
11-
plugin: {
12-
register: 'visionary',
8+
server: {port: 8090},
9+
register: {
10+
plugins: [
11+
{
12+
plugin: 'vision',
1313
options: {
14-
engines: {mustache: 'hapi-mustache'},
14+
engines: {
15+
mustache: {
16+
compile: template => {
17+
mustache.parse(template);
18+
19+
return context => mustache.render(template, context);
20+
}
21+
}
22+
},
1523
path: './example'
1624
}
17-
}
18-
},
19-
{
20-
plugin: {
21-
register: 'good',
25+
},
26+
{
27+
plugin: 'good',
2228
options: {
2329
ops: {
2430
interval: 1000
@@ -35,14 +41,12 @@ export default {
3541
]
3642
}
3743
}
38-
}
39-
},
40-
{plugin: '@travi/hapi-html-request-router'},
41-
{
42-
plugin: {
43-
register: '../src/route',
44+
},
45+
{plugin: '@travi/hapi-html-request-router'},
46+
{
47+
plugin: '../src/route',
4448
options: {respond, routes, Root, configureStore: () => createStore(() => undefined)}
4549
}
46-
}
47-
]
50+
]
51+
}
4852
};

example/respond.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export default function respond(reply, {renderedContent, status}) {
2-
reply.view('layout', {
1+
export default function respond(h, {renderedContent, status}) {
2+
return h.view('layout', {
33
renderedContent,
44
title: '<title>Example Title</title>'
55
}).code(status);

0 commit comments

Comments
 (0)