hyperjumptech / monika

Monika is a command line application to monitor every part of your web app using a simple YAML configuration file. Get alert not only when your site is down but also when it's slow.
https://monika.hyperjump.tech
MIT License
604 stars 66 forks source link

feat(node.js fetch): #1268 implement redirect for fetch #1271

Closed syamsudotdev closed 6 months ago

syamsudotdev commented 6 months ago

Monika Pull Request (PR)

This PR resolves #1268

What feature/issue does this PR add

  1. Handle HTTP status code 3xx for Node.js fetch implementation

How did you implement / how did you fix it

  1. Manually handle status code 3xx on Node.js fetch function
  2. Move HTTP client's dependency to flag to parameter function
  3. Add tests

How to test

  1. npm run test
  2. Create monika.yml config file below
probes:
  - id: 'Example'
    requests:
      - url: https://httpbin.org/redirect/3
        timeout: 60000
    interval: 5
    incidentThreshold: 1
    recoveryThreshold: 1
    alerts:
      - assertion: response.time >= 60000
        message: HTTP response time is {{ response.time }}, expecting 10000
  1. npm run start -- --native-fetch -c monika.yml -r 1