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

Fix #83: Allow custom response from healthCheck function #84

Merged
merged 5 commits into from
Feb 3, 2021

Conversation

p16
Copy link
Contributor

@p16 p16 commented Feb 2, 2021

This PR fixes #83

This PR gives the ability to extend the { status: 'ok' } response using the result of the healthCheck function call.
To allow that we had also to adda new option routeResponseSchemaOpts to the exposeStatusRoute object.

To return something like

{
  status: 'ok',
  extraValue: 'anotherValue'
}

We can configure under-pressure like this

fastify.register(underPressure, {
  ...
  exposeStatusRoute: {
    routeResponseSchemaOpts: {
      extraValue: { type: 'string' },
    }
  },
  healthCheck: async () => {
    return {
        extraValue: 'anotherValue'
    }
  },
}

Checklist

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

README.md Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
p16 and others added 3 commits February 2, 2021 17:31
Co-authored-by: Simone Busoli <[email protected]>
Co-authored-by: Simone Busoli <[email protected]>
index.js Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom response from healthCheck function
3 participants