---
version: '3'

tasks:
  benchmark:
    deps:
      - :install:npm:autocannon
      - :install:npm:clinic
    desc: Initiate a web server benchmarking session (with `clinic`)
    hide: '{{ne (print .REPOSITORY_TYPE "-" .REPOSITORY_SUBTYPE) "npm-app"}}'
    summary: |
      # Initiate a web server benchmarking session with `clinic`

      This task runs a basic stress test on an endpoint that is `/` by default.
      See the examples below for stress testing an endpoint other than the default.
      For more information, see the [`clinic` GitHub page](https://github.com/clinicjs/node-clinic).

      **Example usage:**
      `task npm:benchmark`

      **Example with custom endpoint:**
      `task npm:benchmark -- /custom/endpoint`
    log:
      error: Error encountered while running clinic with autocannon on `dist/main.js`
      start: Running clinic with autocannon on `dist/main.js`
      success: Finished running clinic with autocannon on `dist/main.js`
    cmds:
      - clinic doctor --autocannon [ {{if .CLI_ARGS}}{{.CLI_ARGS}}{{else}}/{{end}} --method POST ] -- node ./dist/main.js