npm.io
4.0.0 • Published 2 years ago

@fabernovel/heart-api

Licence
MIT
Version
4.0.0
Deps
5
Size
10 kB
Vulns
3
Weekly
0
Stars
6

Description

Heart API is a runner module of Heart, which exposes an HTTP API that starts an analysis when it is requested.

Note that you must install an analysis module too, to have a minimum viable installation of Heart.

Read more about the description and design of Heart.

Usage

  1. Install the package and an analysis module, for example Heart GreenIT

    npm install @fabernovel/heart-api @fabernovel/heart-greenit

    If you are using Yarn, npm < 7 or PNPM < 8, you also have to install Heart CLI (which is automatically installed in more recent versions of these packages managers):

    npm install @fabernovel/heart-cli
  2. Start the server

    npx heart api

    You now have an HTTP server listening to 127.0.0.1:3000, with a /greenit endpoint where you could POST your analysis configuration (JSON-formatted) to start an analysis.

    You can change the default port with the --port option, and specify HTTP CORS headers with the --cors one.

  3. Start an analysis

    POST /greenit
    Content-type: application/json
    {
      "config": {
        "url": "https://www.fabernovel.com"
      }
    }

    The analysis configuration set with the request's body follows the JSON format, and depends of the analysis module; read their README.