Skip to content

Commit

Permalink
5.0 (#8)
Browse files Browse the repository at this point in the history
* 5.0 release
  • Loading branch information
melil02 authored Oct 16, 2020
1 parent c601ff4 commit ed7a8cb
Show file tree
Hide file tree
Showing 550 changed files with 19,282 additions and 27,822 deletions.
Empty file modified LICENSE.md
100644 → 100755
Empty file.
29 changes: 24 additions & 5 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ build-example: ## Build the example
build-healthcare: ## Build the healthcare
@yarn build-healthcare

build-storybook: ## Build the storybook
@yarn build-storybook


#### Run ####

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

storybook: ## Starts storybook
@yarn storybook

#### Tests ####

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


#### Deployment ####

copy-deploy-config-example: ## Copy config of the example. Usage DEPLOY_ENV=[dev|integration|staging] make copy-deploy-config-example.
cp packages/example/config/config-${DEPLOY_ENV}.js packages/example/build/config.js

copy-deploy-config-healthcare: ## Copy config of the healthcare. Usage DEPLOY_ENV=[dev|integration|staging] make copy-deploy-config-healthcare.
cp packages/healthcare/config/config-${DEPLOY_ENV}.js packages/healthcare/build/config.js

deploy-example: copy-deploy-config-example ## Deploy the example on AWS S3. Usage DEPLOY_ENV=[dev|integration|staging] make deploy-example.
aws s3 rm s3://broadcom-apihub.marmelab.com/example --recursive
aws s3 sync packages/example/build/ s3://broadcom-apihub.marmelab.com/example
aws s3 cp packages/example/build/index.html s3://broadcom-apihub.marmelab.com/example/index.html --cache-control="max-age=120"
aws cloudfront create-invalidation --distribution-id E1AOZQ3R1CQ7R6 --paths "/*"

deploy-healthcare: copy-deploy-config-healthcare ## Deploy the healthcare on AWS S3. Usage DEPLOY_ENV=[dev|integration|staging] make deploy-healthcare.
aws s3 rm s3://broadcom-apihub.marmelab.com/healthcare --recursive
aws s3 sync packages/healthcare/build/ s3://broadcom-apihub.marmelab.com/healthcare
aws s3 cp packages/healthcare/build/index.html s3://broadcom-apihub.marmelab.com/healthcare/index.html --cache-control="max-age=120"
aws cloudfront create-invalidation --distribution-id E2X6V50RZK09GM --paths "/*"

deploy: build build-example build-healthcare ## Deploy all on AWS S3. Usage DEPLOY_ENV=[dev|integration|staging] make deploy.
make deploy-example
make deploy-healthcare
Empty file modified OVERVIEW.md
100644 → 100755
Empty file.
77 changes: 77 additions & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,81 @@ Copy the contents of the `packages/example/build` directory to your favorite web
docker run --name APIHub -v `pwd`/packages/example/build:/usr/share/nginx/html:ro -p 8888:80 nginx
```

## Create an API Hub Implementation

Follow these steps:

1. From the root of this repository, initialize a new react-app called `my-own-apihub` by issuing the following commands:

```sh
$ cd packages && yarn create react-app my-own-apihub --scripts-version=3.2.0
```
2. Add the `layer7-aphub`, `layer7-apihub-mock`, and `react-admin` packages as dependencies in the new package.json:

```
# in packages/my-own-apihub/package.json
"dependencies": {
"layer7-apihub": "~1.0.0",
"layer7-apihub-mock": "~1.0.0",
"react": "~16.13.1",
"react-admin": "~3.6.2",
"react-scripts": "~3.2.0"
},
```

3. Copy the config files to the `example` package by issuing the following commands:
```sh
$ cp -r packages/example/config packages/my-own-apihub/config/
$ cp packages/my-own-apihub/config/config-dev.js packages/my-own-apihub/public/config.js
```

4. Update the public `index.html` file to include the `config.js` file:
```html
<!-- in packages/my-own-apihub/public/index.html -->
<head>
...
<script type="text/javascript" src="%PUBLIC_URL%/config.js"></script>
...
</head>
```

5. Include the base API Hub component in the `App.js` file:
```js
// in packages/my-own-apihub/src/App.js
import { ApiHubAdmin } from 'layer7-apihub';
const App = () => {
const { APIHUB_URL, TENANT_NAME, ORIGIN_HUB_NAME } = global.APIHUB_CONFIG;
return (
<ApiHubAdmin
url={APIHUB_URL}
tenantName={TENANT_NAME}
originHubName={ORIGIN_HUB_NAME}
/>
);
};
```

6. Add the mock server to the `index.js` file:
```js
// in packages/my-own-apihub/src/index.js
import { startApiHubMockedServer } from 'layer7-apihub-mock';
...
const { ENABLE_MOCK, MOCK_SERVER_INDICATOR_LINK } = global.APIHUB_CONFIG;
export const shouldEnableMock = (enableMock = ENABLE_MOCK) =>
enableMock === 'true' || enableMock === true;
if (!shouldEnableMock(ENABLE_MOCK)) {
ReactDOM.render(<App />, document.getElementById('root'));
} else {
console.log('Starting the mocked server');
startApiHubMockedServer({
runningIndicatorLink: MOCK_SERVER_INDICATOR_LINK,
}).then(() => ReactDOM.render(<App />, document.getElementById('root')));
}
```

7. Start the bare-bones my-own-apihub app by issuing the following commands:
```
$ cd packages/my-own-apihub
$ yarn install
$ yarn start
```
Empty file modified cypress/.eslintrc
100644 → 100755
Empty file.
Empty file modified cypress/README.md
100644 → 100755
Empty file.
Empty file modified cypress/cypress.json
100644 → 100755
Empty file.
Loading

0 comments on commit ed7a8cb

Please sign in to comment.