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(native fetch): Implement Node.js fetch #1243

Merged

Conversation

syamsudotdev
Copy link
Contributor

@syamsudotdev syamsudotdev commented Mar 1, 2024

Monika Pull Request (PR)

This PR resolves #1241

What feature/issue does this PR add

  1. Implement Node.js fetch under --native-fetch

How did you implement / how did you fix it

  1. Change flag --experimental-fetch to --native-fetch
  2. Implement Node.js fetch under flag --native-fetch
  3. Change typings from AxiosRequestHeaders to be compatible with plain TypeScript / fetch
  4. Change typings from AxiosRequestConfig to be compatible with plain TypeScript / fetch
  5. Generalize typing for sending HTTP request into one type HttpRequestParams
  6. Map Node.js fetch result

How to test

  1. Given below config
probes:
  - id: '1'
    name: GitHub
    description: Multiple
    interval: 5
    requests:
      - url: https://github.com
        timeout: 7000
      - url: https://github.com/hyperjump
        timeout: 7000
  - id: '2'
    name: HTML form submission
    description: simulate html form submission
    interval: 5
    requests:
      - url: https://httpbin.org/post
        method: POST
        headers:
          Accept: application/json
        body:
          username: someusername
          password: somepassword
  1. Run npm run start -- --native-fetch --verbose
  2. Observe log statements for Probing URL with Node.js fetch
    image

Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 62.50000% with 24 lines in your changes are missing coverage. Please review.

Project coverage is 63.25%. Comparing base (a069bae) to head (cf12667).

Files Patch % Lines
src/components/probe/prober/http/request.ts 62.00% 13 Missing and 6 partials ⚠️
src/utils/http.ts 61.53% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1243      +/-   ##
==========================================
- Coverage   63.52%   63.25%   -0.27%     
==========================================
  Files         111      111              
  Lines        3304     3326      +22     
  Branches      567      574       +7     
==========================================
+ Hits         2099     2104       +5     
- Misses       1016     1032      +16     
- Partials      189      190       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@syamsudotdev syamsudotdev self-assigned this Mar 4, 2024
Copy link
Contributor

@sapiderman sapiderman left a comment

Choose a reason for hiding this comment

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

all running here! Nice work @syamsudotdev
🍺 🍻 🥂

Copy link
Contributor

@raosan raosan left a comment

Choose a reason for hiding this comment

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

LGTM

docs/src/pages/guides/cli-options.md Outdated Show resolved Hide resolved
@syamsudotdev syamsudotdev merged commit ca5c3ac into hyperjumptech:main Mar 7, 2024
7 checks passed
@syamsudotdev syamsudotdev deleted the implement-fetch-under-flag branch March 7, 2024 03:04
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.

Implement HTTP request with native fetch Node.js
3 participants