Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom endpoint documentation #30

Merged
merged 1 commit into from
Mar 31, 2020
Merged
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
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Table of Contents
- [Typescript](#typescript)
- [Usage](#usage)
- [Configuring Actuator](#configuring-actuator)
- [Custom Endpoints](#custom-endpoints)
- [Deprecated mode](#deprecated-mode)
- [Endpoints Examples](#endpoints-examples)
- [info](#info)
Expand Down Expand Up @@ -67,11 +68,33 @@ All defined options are optional:
```js
const options = {
basePath: '/management', // It will set /management/info instead of /info
infoGitMode: 'simple' // the amount of git information you want to expose, 'simple' or 'full'
infoGitMode: 'simple', // the amount of git information you want to expose, 'simple' or 'full'
customEndpoints: [] // array of extra endpoints
};

app.use(actuator(options));
```
### Custom Endpoints
You can add your own validations using the `customEndpoints` option:

```js
const options = {
customEndpoints: [
{
id: 'dependecies', // used as endpoint /dependencies or ${basePath}/dependencies
controller: (req, res) => { // Controller to be called when accessing this endpoint
// Your custom code here
}
}
]
};

app.use(actuator(options));
```
> **_IMPORTANT:_**
>1. Even if you call your custom endpoint as **"info"** it will not override the default info.
>2. If you provide `basePath`, your id will be available as `${basePath}/${id}`, otherwise, just `/${id}`.
>3. Consider lightweight code being processed by your endpoint controller or it will compete with your main application.

### Deprecated mode
To have backward compatibility with previous versions (<= 1.2.0) the legacy way is still available:
Expand Down