Skip to content

Commit ed7a8cb

Browse files
authored
5.0 (#8)
* 5.0 release
1 parent c601ff4 commit ed7a8cb

550 files changed

Lines changed: 19282 additions & 27822 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE.md

100644100755
File mode changed.

Makefile

100644100755
Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ build-example: ## Build the example
3131
build-healthcare: ## Build the healthcare
3232
@yarn build-healthcare
3333

34-
build-storybook: ## Build the storybook
35-
@yarn build-storybook
36-
3734

3835
#### Run ####
3936

@@ -46,8 +43,6 @@ start-healthcare: copy-config-healthcare build ## Starts the application in deve
4643
watch-lib: ## Starts the library in development mode
4744
@yarn start-lib
4845

49-
storybook: ## Starts storybook
50-
@yarn storybook
5146

5247
#### Tests ####
5348

@@ -68,3 +63,27 @@ test-e2e-local: ## Opens the end-to-end tests GUI. Usage make test-e2e-local.
6863
lint: ## Runs linting tools
6964
@yarn lint
7065

66+
67+
#### Deployment ####
68+
69+
copy-deploy-config-example: ## Copy config of the example. Usage DEPLOY_ENV=[dev|integration|staging] make copy-deploy-config-example.
70+
cp packages/example/config/config-${DEPLOY_ENV}.js packages/example/build/config.js
71+
72+
copy-deploy-config-healthcare: ## Copy config of the healthcare. Usage DEPLOY_ENV=[dev|integration|staging] make copy-deploy-config-healthcare.
73+
cp packages/healthcare/config/config-${DEPLOY_ENV}.js packages/healthcare/build/config.js
74+
75+
deploy-example: copy-deploy-config-example ## Deploy the example on AWS S3. Usage DEPLOY_ENV=[dev|integration|staging] make deploy-example.
76+
aws s3 rm s3://broadcom-apihub.marmelab.com/example --recursive
77+
aws s3 sync packages/example/build/ s3://broadcom-apihub.marmelab.com/example
78+
aws s3 cp packages/example/build/index.html s3://broadcom-apihub.marmelab.com/example/index.html --cache-control="max-age=120"
79+
aws cloudfront create-invalidation --distribution-id E1AOZQ3R1CQ7R6 --paths "/*"
80+
81+
deploy-healthcare: copy-deploy-config-healthcare ## Deploy the healthcare on AWS S3. Usage DEPLOY_ENV=[dev|integration|staging] make deploy-healthcare.
82+
aws s3 rm s3://broadcom-apihub.marmelab.com/healthcare --recursive
83+
aws s3 sync packages/healthcare/build/ s3://broadcom-apihub.marmelab.com/healthcare
84+
aws s3 cp packages/healthcare/build/index.html s3://broadcom-apihub.marmelab.com/healthcare/index.html --cache-control="max-age=120"
85+
aws cloudfront create-invalidation --distribution-id E2X6V50RZK09GM --paths "/*"
86+
87+
deploy: build build-example build-healthcare ## Deploy all on AWS S3. Usage DEPLOY_ENV=[dev|integration|staging] make deploy.
88+
make deploy-example
89+
make deploy-healthcare

OVERVIEW.md

100644100755
File mode changed.

README.md

100644100755
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,81 @@ Copy the contents of the `packages/example/build` directory to your favorite web
126126
docker run --name APIHub -v `pwd`/packages/example/build:/usr/share/nginx/html:ro -p 8888:80 nginx
127127
```
128128

129+
## Create an API Hub Implementation
129130

131+
Follow these steps:
132+
133+
1. From the root of this repository, initialize a new react-app called `my-own-apihub` by issuing the following commands:
134+
135+
```sh
136+
$ cd packages && yarn create react-app my-own-apihub --scripts-version=3.2.0
137+
```
138+
2. Add the `layer7-aphub`, `layer7-apihub-mock`, and `react-admin` packages as dependencies in the new package.json:
139+
140+
```
141+
# in packages/my-own-apihub/package.json
142+
"dependencies": {
143+
"layer7-apihub": "~1.0.0",
144+
"layer7-apihub-mock": "~1.0.0",
145+
"react": "~16.13.1",
146+
"react-admin": "~3.6.2",
147+
"react-scripts": "~3.2.0"
148+
},
149+
```
150+
151+
3. Copy the config files to the `example` package by issuing the following commands:
152+
```sh
153+
$ cp -r packages/example/config packages/my-own-apihub/config/
154+
$ cp packages/my-own-apihub/config/config-dev.js packages/my-own-apihub/public/config.js
155+
```
156+
157+
4. Update the public `index.html` file to include the `config.js` file:
158+
```html
159+
<!-- in packages/my-own-apihub/public/index.html -->
160+
<head>
161+
...
162+
<script type="text/javascript" src="%PUBLIC_URL%/config.js"></script>
163+
...
164+
</head>
165+
```
166+
167+
5. Include the base API Hub component in the `App.js` file:
168+
```js
169+
// in packages/my-own-apihub/src/App.js
170+
import { ApiHubAdmin } from 'layer7-apihub';
171+
const App = () => {
172+
const { APIHUB_URL, TENANT_NAME, ORIGIN_HUB_NAME } = global.APIHUB_CONFIG;
173+
return (
174+
<ApiHubAdmin
175+
url={APIHUB_URL}
176+
tenantName={TENANT_NAME}
177+
originHubName={ORIGIN_HUB_NAME}
178+
/>
179+
);
180+
};
181+
```
182+
183+
6. Add the mock server to the `index.js` file:
184+
```js
185+
// in packages/my-own-apihub/src/index.js
186+
import { startApiHubMockedServer } from 'layer7-apihub-mock';
187+
...
188+
const { ENABLE_MOCK, MOCK_SERVER_INDICATOR_LINK } = global.APIHUB_CONFIG;
189+
export const shouldEnableMock = (enableMock = ENABLE_MOCK) =>
190+
enableMock === 'true' || enableMock === true;
191+
if (!shouldEnableMock(ENABLE_MOCK)) {
192+
ReactDOM.render(<App />, document.getElementById('root'));
193+
} else {
194+
console.log('Starting the mocked server');
195+
startApiHubMockedServer({
196+
runningIndicatorLink: MOCK_SERVER_INDICATOR_LINK,
197+
}).then(() => ReactDOM.render(<App />, document.getElementById('root')));
198+
}
199+
```
200+
201+
7. Start the bare-bones my-own-apihub app by issuing the following commands:
202+
```
203+
$ cd packages/my-own-apihub
204+
$ yarn install
205+
$ yarn start
206+
```

cypress/.eslintrc

100644100755
File mode changed.

cypress/README.md

100644100755
File mode changed.

cypress/cypress.json

100644100755
File mode changed.

0 commit comments

Comments
 (0)