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

feat: custom unhandled request strategies (#9) #149

Merged

Conversation

diego-aquino
Copy link
Member

@diego-aquino diego-aquino commented May 19, 2024

Features

  • [#zimic] Added support to custom unhandled request strategies. Now, the default configuration is log: true, meaning that requests that did not match any handlers or interceptors are logged as a warning to the console. When type: 'local', unhandled requests are always bypassed and might reach the real service if it is running. This is because we have no way of "aborting" the request and returning a fetch error in the local mode. However, when type: 'remote', this is possible and unhandled requests result in a fetch error to the client. The logging configuration enables or disables only the warnings logged to the console, not affecting the bypass vs reject behavior per interceptor type.
  • [#zimic] Improved the error messages to include [#zimic] at the start.
  • [#zimic] Included the restriction unhandled request strategy types to exports:
    • UnhandledRequestStrategy
    • HttpRequestHandlerRestriction
    • HttpRequestHandlerComputedRestriction
    • HttpRequestHandlerHeadersStaticRestriction
    • HttpRequestHandlerSearchParamsStaticRestriction
    • HttpRequestHandlerStaticRestriction
    • HttpRequestHandlerBodyStaticRestriction

Build

  • [#zimic] Reverted chalk to version 4, which still supports CommonJS. This is necessary to allow importing chalk from bundled applications such as the Next.js and Playwright examples.

Refactoring

  • [#zimic] Freezed constant objects to avoid editions.

Example log for an unhandled request:

image

Closes #9.

@diego-aquino diego-aquino linked an issue May 19, 2024 that may be closed by this pull request
9 tasks
@diego-aquino diego-aquino added this to the v0.5.0 milestone May 19, 2024
@diego-aquino diego-aquino force-pushed the @diego-aquino/9-custom-unhandled-request-strategies branch from 80eee09 to 983999d Compare May 20, 2024 22:02
@diego-aquino diego-aquino force-pushed the @diego-aquino/9-custom-unhandled-request-strategies branch from 983999d to 8bf02ed Compare May 21, 2024 18:26
@diego-aquino diego-aquino enabled auto-merge (squash) May 25, 2024 00:24
@diego-aquino diego-aquino merged commit 69bea21 into canary May 25, 2024
14 checks passed
@diego-aquino diego-aquino deleted the @diego-aquino/9-custom-unhandled-request-strategies branch May 25, 2024 00:27
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.

Custom unhandled request strategies
1 participant