Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In a LiteFarm deployment, the database runs as litefarm-db, a Docker container built from the official Postgres image.

The API code

An Application Programming Interface (API) is an interface that a software product provides for use by other software, rather than by human users.

...

Auto-Increment ID Conventions as of August 2024

In our migration strategy:

  • Manually Set IDs: Used for the permissions table to ensure consistent IDs across different environments (local, beta, production).

    • Previously, hard-coding IDs led to "UniqueViolationError" issues when inserting new rows.

      • #2857 (comment)

      • Jira Legacy
        serverSystem Jira
        serverId815f41e5-e5fb-3402-8587-82eccc3ffab0
        keyLF-3651

  • Auto-Increment IDs: Applied by default unless there's a specific reason to manually set IDs. This helps avoid conflicts and simplifies record management.

The API code

An Application Programming Interface (API) is an interface that a software product provides for use by other software, rather than by human users.

The code for the LiteFarm API is in the packages/api/src folder. In a LiteFarm deployment, this Node.js server runs in a Docker container named litefarm-api. The container is built to put the API code in a standard Node image, and also uses a standard Nginx image to create a reverse proxy server.

...

For example, the middleware function above queries the Objection userFarmModel class to determine if the user making this request is an authorized user for the farm identified in the request. If so, the middleware calls next() which activates the route handler that we have already discussed. But if the user is not authorized for the farm, the middleware does not use next to activate the route handler. Instead, it handles the response itself by sending an HTTP status code 403 ("Forbidden") and a description of the problem.

LiteFarm generally follows the REST conventions for endpoints and status codes used in responses.

Backend tests

The packages/api/tests folder contains tests of the API built with Jest. You can read more about this here.

Auto-Increment ID Conventions as of August 2024

In our migration strategy:

...

Manually Set IDs: Used for the permissions table to ensure consistent IDs across different environments (local, beta, production).

  • Previously, hard-coding IDs led to "UniqueViolationError" issues when inserting new rows.

    • #2857 (comment)

    • Jira Legacy
      serverSystem Jira
      serverId815f41e5-e5fb-3402-8587-82eccc3ffab0
      keyLF-3651

...

the Objection userFarmModel class to determine if the user making this request is an authorized user for the farm identified in the request. If so, the middleware calls next() which activates the route handler that we have already discussed. But if the user is not authorized for the farm, the middleware does not use next to activate the route handler. Instead, it handles the response itself by sending an HTTP status code 403 ("Forbidden") and a description of the problem.

LiteFarm generally follows the REST conventions for endpoints and status codes used in responses.

Backend tests

The packages/api/tests folder contains tests of the API built with Jest. You can read more about this here.