Skip to content
This repository was archived by the owner on Jan 11, 2019. It is now read-only.

Commit afdb8e5

Browse files
author
Rick
committed
Add comments to explain the example's proxy use.
1 parent 115b90d commit afdb8e5

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-isomorphic-starterkit",
33
"description": "Isomorphic starterkit with server-side React rendering.",
4-
"version": "2.3.2",
4+
"version": "2.3.3",
55
"license": "BSD-3",
66
"repository": {
77
"type": "git",

src/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ server.route({
2424
});
2525

2626
/**
27-
* Endpoint that proxies all requests to api.github.com
27+
* Endpoint that proxies all GitHub API requests to https://api.github.com.
2828
*/
2929
server.route({
3030
method: "*",
3131
path: "/api/github/{path*}",
3232
handler: {
3333
proxy: {
3434
passThrough: true,
35-
mapUri: function (request, callback) {
35+
mapUri (request, callback) {
3636
callback(null, url.format({
3737
protocol: "https",
3838
host: "api.github.com",

src/views/Main.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,22 @@ export default Transmit.createContainer(Main, {
145145
* Return a Promise of the previous stargazers + the newly fetched stargazers.
146146
*/
147147
allStargazers (queryParams) {
148+
/**
149+
* On the server, connect to GitHub directly.
150+
*/
148151
let githubApi = "https://api.github.com";
149152

153+
/**
154+
* On the client, connect to GitHub via the Hapi proxy route.
155+
*/
150156
if (__CLIENT__) {
151157
const {hostname, port} = window.location;
152158
githubApi = `http://${hostname}:${port}/api/github`;
153159
}
154160

161+
/**
162+
* Load a few stargazers using the Fetch API.
163+
*/
155164
return fetch(
156165
githubApi + "/repos/RickWong/react-isomorphic-starterkit/stargazers" +
157166
`?per_page=100&page=${queryParams.nextPage}`

0 commit comments

Comments
 (0)