Skip to content

Commit 30091c7

Browse files
committed
more info on running the example
1 parent a2dc578 commit 30091c7

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

github-repo-labels/README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
11
# Dynamic SVG labels with basic stats for GitHub repositories
22

3-
This example shows how to generate simple SVG labels using Lambda, such as the one below:
3+
This example project serves simple SVG labels using Lambda, such as the one below:
44

55
[![claudiajs/claudia](https://repolabels.net/claudiajs/claudia/large.svg)](https://github.com/claudiajs/claudia/)
66

7-
See [repolabels.net](repolabels.net) for a live version of this example, and generate labels for your own repositories.
7+
See [repolabels.net](https://repolabels.net) for a live version of this example, and generate labels for your own repositories.
8+
9+
This example demonstrates how to:
10+
11+
- Bind method parameters to URL path components (requests are processed as `{owner}/{repo}/{template}`)
12+
- Customise response content types (this serves `image/svg+xml`)
13+
- Manage development/testing/production API versions
14+
- Connect to a third party REST API (github)
15+
- store keys for development/testing/production access
16+
- Protect API access using API keys
17+
- reduce costs by caching results using CloudFront
818

919
## How it works
1020

1121
The code in [web.js](web.js) just connects to the GitHub developer API to retrieve repository statistics, and then
12-
performs a simple string replacement on [SVG template files](svg/).
22+
performs a simple string replacement on [SVG template files](svg/). The URL request format is:
1323

14-
This example demonstrates how to:
24+
```
25+
https://<API ID>.execute-api.<REGION>.amazonaws.com/<STAGE>/<OWNER>/<NAME>/<TEMPLATE>.svg
26+
```
27+
28+
where:
29+
30+
- `API ID` is the ID of your API (check the `claudia.json` file after deployment)
31+
- `REGION` is the region where the API is deployed (eg `us-east-1` if you use the standard `package.json`)
32+
- `STAGE` is the version of the API (eg `dev` or `production`, see the Getting Started section below for more info)
33+
- `OWNER` is the owner of the GitHub repository you want to create a label for (eg `claudiajs`)
34+
- `NAME` is the repository name (eg `claudia`)
35+
- `TEMPLATE` is the name of a file from the [svg](svg) directory used to create the label (eg `large` or `small`)
36+
37+
## Getting started
38+
39+
Create the development version of the API using `npm run start`, and deploy the production version using `npm run release`.
40+
41+
Github limits the rate of unauthenticated requests severely, this example allows you to optionally specify two stage variables to authenticate requests to GitHub, and increase rate limits. Check out your deployed API in the AWS web console, and add two stage variables to the production stage - `githubClientId` and `githubSecret`. [Create a GitHub applications](https://github.com/settings/applications/new) to get access keys. You can optionally also create a development GitHub application and store its keys in the development stage.
42+
43+
You can change the development version and run `npm run deploy`, and you will see that the development version changed, but the production version did not. For example, uncomment `apiKeyRequired: true` in the last line of `web.js` before deploying. This will cause the API calls to require an API key before allowing the request. See [Use an API Key in API Gateway](http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-api-keys.html) for more information on how to create an use an API key.
1544

16-
- connect to a third party REST API (github)
17-
- store and use third party API keys in stage variables
18-
- use path parameters for API requests (requests are processed as `{owner}/{repo}/{template}`)
19-
- enforce the usage of an API key
45+
To push the currently released version to production, run `npm run release` again.

github-repo-labels/web.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ api.get('/{owner}/{name}/{template}', function (request) {
5252
});
5353
return template;
5454
});
55-
}, {apiKeyRequired: true, success: {contentType: 'image/svg+xml'}});
55+
}, {/*apiKeyRequired: true,*/ success: {contentType: 'image/svg+xml'}});

0 commit comments

Comments
 (0)