Skip to content

Commit 747a17b

Browse files
author
Andrews
committed
use lambdas/backend/catalog.json; update README; do not show Subscribe button when not signed in; added screenshots
1 parent eaf402c commit 747a17b

File tree

9 files changed

+254
-494
lines changed

9 files changed

+254
-494
lines changed

README.md

+27-8
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,37 @@ aws-serverless-developer-portal is a reference implementation for a developer po
55
It also optionally supports subscription/unsubscription through a SaaS product offering through the AWS Marketplace.
66

77
## Setup
8-
First, ensure you have the latest AWS CLI installed http://docs.aws.amazon.com/cli/latest/userguide/installing.html.
8+
9+
### Prerequisites
10+
First, ensure you have the [latest AWS CLI installed](http://docs.aws.amazon.com/cli/latest/userguide/installing.html) (version >= 1.11.19) as well as [Node.js](https://nodejs.org/en/download/) 4+. Then, clone this repo into a local directory
11+
12+
### List your products (APIs/Usage Plans)
13+
Add your API Gateway APIs to the array in the `lambdas/backend/catalog.json` file, using the following format. If you have not yet created an API and Usage Plan, see [blog post]() for a detailed walkthrough. Alternatively, skip this step for now if you just want to get started with your developer portal (A placeholder API with swagger definition is provided for you for demonstration purposes, however, some features such as __Subscribe__ will not work)
14+
15+
```json
16+
{
17+
"apiId": "YOUR_API_ID",
18+
"usagePlanId": "YOUR_USAGE_PLAN_ID",
19+
"image": "http://example.com/your-api-product-image.svg",
20+
"swagger": {
21+
"swagger": "2.0",
22+
...
23+
}
24+
}
25+
```
26+
27+
__TIP:__ If you put your api product images in the `dev-portal/public` directory, you can simply do `"image": "/your-api-product-image.svg"`. `image` is also optional.
28+
29+
Add your swagger definition to the `swagger` property to enable documentation for your API.
30+
31+
### Setup and deploy
32+
Run:
933

1034
```js
11-
npm install
12-
npm run pre-config
1335
npm run setup
14-
npm run post-setup
1536
```
1637

17-
Enter your new API Id, Dev Portal Function Name, Cognito User Pool ID, Cognito Client ID, and Cognito Identity Pool ID, available in Cloudformation __Outputs__. Click the WebsiteURL in the __Outputs__ section of your CloudFormation stack.
18-
19-
Update dev-portal/src/catalog.json with your API Gateway APIs and Usage Plans (if you do not yet have one, you will need to create it), and run `npm run upload-site`.
38+
Follow the prompts and enter your account id, region, and names for your S3 buckets, CloudFormation stack, and API. The names you provide for the S3 buckets must be unique to that region (ie. not just unique to your account) so it is recommended to add a prefix or suffix (eg. my-org-dev-portal). You can choose to provide an existing bucket for the __artifacts__ S3 bucket name, or a new one (in which case it will be created for you). The __site__ S3 bucket must __NOT__ exist, as this is managed by the CloudFormation stack.
2039

2140
## Components
2241

@@ -64,7 +83,7 @@ Deploy changes to the application UI:
6483
npm run upload-site
6584
```
6685

67-
Deploy changes to CloudFormation, Swagger, backend function, and the listener function:
86+
Deploy changes to CloudFormation, Swagger, or lambda functions:
6887

6988
```js
7089
npm run package-deploy

dev-portal/src/catalog.json

-240
This file was deleted.

dev-portal/src/components/ApiCatalog/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ const SubscribedApiActionsDropdown = ({api}) => (
2525
</Dropdown.Menu>
2626
</Dropdown>)
2727

28-
const SubscribeButton = ({api}) => isAuthenticated() ? <Button onClick={event => handleSubscribe(event, api)}>Subscribe</Button> : ''//<a href='https://aws.amazon.com/marketplace/' target='_blank'><Button>Subscribe!</Button></a>
28+
2929
const ApiCard = api => (
3030
<Card key={api.apiId} style={{textAlign: 'center'}}>
31-
<Link to={`apis/${api.apiId}`} style={{background: 'rgba(0, 0, 0, 0.05)'}}><Image src={api.image} style={{margin: 'auto'}} /></Link>
31+
<Link to={`apis/${api.apiId}`} style={{background: 'rgba(0, 0, 0, 0.05)'}}>{ api.image ? <Image src={api.image} style={{margin: 'auto'}} /> : ''}</Link>
3232
<Card.Content>
3333
<Card.Header><Link to={`apis/${api.apiId}`}>{api.swagger.info.title}</Link></Card.Header>
3434
<Card.Meta>
3535
<span className='date'>Version {api.swagger.info.version}</span>
3636
</Card.Meta>
3737
<Card.Description>{api.swagger.info.description}</Card.Description>
3838
</Card.Content>
39-
<Card.Content extra>
40-
{ isSubscribed(api) ? <SubscribedApiActionsDropdown api={api} /> : <SubscribeButton api={api} />}
41-
</Card.Content>
39+
{ isAuthenticated() ? (<Card.Content extra>
40+
{ isSubscribed(api) ? <SubscribedApiActionsDropdown api={api} /> : <Button onClick={event => handleSubscribe(event, api)}>Subscribe</Button>}
41+
</Card.Content>) : ''}
4242
</Card>)
4343

4444
export default ({ apis }) => (

dev-portal/src/services/api-catalog.js

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
import { getApiGatewayClient } from './api'
2-
import apis from '../catalog.json'
32
export let subscriptions
4-
// let apis
3+
let apis
54

65
export function getApis() {
7-
return Promise.resolve(apis)
6+
if (apis) return Promise.resolve(apis)
87

9-
// NOTE: if you prefer to expose your catalog.json only to authenticated users,
10-
// use the code below and manage lambdas/backend/catalog.json instead
11-
// if (apis) return Promise.resolve(apis)
12-
13-
// return fetchApis()
14-
// .then(({data}) => {
15-
// apis = data
16-
// return data
17-
// })
8+
return fetchApis()
9+
.then(({data}) => {
10+
apis = data
11+
return data
12+
})
1813
}
1914

2015
export function getApi(id) {

0 commit comments

Comments
 (0)