-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[http] Expose isKibanaReponse helper in public API #182392
[http] Expose isKibanaReponse helper in public API #182392
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
@@ -24,10 +24,6 @@ import type { | |||
} from '@kbn/core-http-server'; | |||
import mime from 'mime'; | |||
|
|||
export function isKibanaResponse(response: Record<string, any>): response is IKibanaResponse { | |||
return typeof response.status === 'number' && typeof response.options === 'object'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the most thorough check and would be nice to add unit tests for before making public but overall happy with the idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jloleysens I added some tests in d1a8d60 and made some small changes to the helper to make it a bit more strict, let me know what you think!
…ultgren/kibana into expose-is-kibana-response-helper
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: |
describe('isKibanaResponse', () => { | ||
it('expects the status to be a number', () => { | ||
expect( | ||
isKibanaResponse({ | ||
status: 200, | ||
options: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue having this exposed from the public type package is that we can't even test it against our concrete implementation 😅.
However it's probably fine for now, I don't have a better suggestion / place to put it that wouldn't imply create yet another package, so if @jloleysens is fine with the approach, I'm too.
For some other changes I'm working on, I need to be able to distinguish if a route handler returned a
IKibanaResponse
/KibanaResponse
object or some other object that needs to be wrapped before being sent back.Rather than duplicating this little helper I want to expose it as part of the public API of
core.http
.