Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

Add support for Shields.IO integration #83

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ The middleware writes the data returned by the Cloud Health module as JSON, and
```
If no readiness or liveness checks are registered, this will report `200 OK` and `UP`.

6. Register a shield health endpoint:

```js
app.use('/shield', health.ShieldEndpoint(healthcheck, label, logo));
```

- `label` - optional label string, default is 'health'
- `logo` - optional logo (SVG string), default is <img src="src/connect-cloud-health/healthcheck.svg" height="12"> as shown below

This is an endpoint suitable for [Shields.IO](https://shields.io/) integration (see balow).

For information on how to register startup, readiness, liveness and shutdown checks, see the [Cloud Health documentation](https://github.com/CloudNativeJS/cloud-health/blob/master/README.md).

#### Health, Liveness and Readiness endpoints
Expand All @@ -75,6 +86,44 @@ The difference between liveness and readiness endpoints is the purpose: readines

The combined health endpoint is designed for cloud technologies, such as Cloud Foundry which only support a single endpoint for both liveness and readiness checking.

#### Shield endpoint

The Shield endpoint is compatible with the [Shields.IO Endpoint API](https://shields.io/endpoint).

If your Shields endpoint is served as `https://example.com/shield` then the Shields.IO URL is:
- `https://img.shields.io/endpoint?url=https://example.com/shield`

This will return one of the images:

![health: unknown](examples/unknown.svg)
![health: starting](examples/starting.svg)
![health: up](examples/up.svg)
![health: stopping](examples/stopping.svg)
![health: stopped](examples/stopped.svg)
![health: down](examples/down.svg)

For a custom label to differentiate deployments, use the `label` query parameter:

- `https://img.shields.io/endpoint?label=production&url=https://example.com/shield`

![production: down](examples/production-down.svg)

You can also use a custom label or logo as optional parameters to the `health.ShieldEndpoint()` function (see above).

Optional `style` query parameter can be used to change the appearance of the image:

- `https://img.shields.io/endpoint?label=production&style=plastic&url=https://example.com/shield`

Supported values for the `style` parameter:

![social](examples/production-up-social.svg) `social`
<br>![plastic](examples/production-up-plastic.svg) `plastic`
<br>![flat](examples/production-up-flat.svg) `flat` (default)
<br>![flat-square](examples/production-up-flatsquare.svg) `flat-square`
<br>![for-the-badge](examples/production-up-forthebadge.svg) `for-the-badge`

See the [Shields.IO](https://shields.io/) documentation for more options.

### Using Cloud Health Connect with Typescript
The Cloud Health Connect module is created in TypeScript and as such provides out of the box TypeScript support.

Expand Down
1 change: 1 addition & 0 deletions examples/down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/production-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/production-up-flat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/production-up-flatsquare.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/production-up-forthebadge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/production-up-plastic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/production-up-social.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/starting.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading