Skip to content

Latest commit

 

History

History

README.md

LandGriffon API


Test Coverage

1. Dependencies

2. API Documentation

API documentation is done using OpenAPI (formerly known as Swagger) and is available through the /swagger endpoint.

3. Installation

3.1. Database setup

PostgreSQL server needs two additional extensions to manage the geospatial data properly:

Be sure to review the installation process for both these extensions and follow the respective steps prior to running the API application.

You also need to manually create a database prior to the first execution of this API, and both extensions above need to be enabled for said database.

Once that's in place, you can start the application, which will populate the database structure.

3.2. Redis

Redis serves as both a message broker and a caching mechanism for certain precomputed results. While caching can be disabled through configuration environment variables, Redis is essential for message broker functionality and cannot be turned off.

3.3. Application setup

The API application uses Nodejs (see the .nvmrc file for the exact version) and Nest+ TypeORM. For dependency management, it uses yarn.

Start by installing all dependencies using yarn. You then have two options:

  • Start the application in development mode by running yarn start
  • Start the application in production mode by running yarn build followed by yarn start:prod

Configuration is done using Config based on the /config folder. Be sure to set the correct values to match your database configuration.

On its initial execution, provided everything is configured correctly, the application will automatically connect to the database and create the necessary table structure.

You should now be able to reach the API on the configured port on your server

3.4. Seed data

By default, the database for a new application has structure but no seed data. However, the application requires seed data for many of its operations. You need to import this data before using the API.

This seed data is managed inside the /data folder at the root of the project. Refer to its documentation for more info on how to import said data.

3.5. Creating user with cli

To create user via cli, use the following command yarn nestjs-command create:user <email> <password> For more details use yarn nestjs-command create:user --help

4. Configuration

TODO: Configuration for the api is in this document and in the ENV_VARS.md document.

  • IMPORT_MISSING_DATA_FALLBACK_STRATEGY: When calculating impact data as part of a spreadsheet import, how to handle scenarios where a given material does not have impact data for a given year:
  • error: Fail the import process.
  • fallback: Use the impact data for the same material and most recent year.
  • ignore: Do not calculate impact values for these material/year pairs.
  • PASSWORD_MIN_LENGTH (number, optional, default 6): Minimal password length accepted by the api.
  • PASSWORD_INCLUDE_NUMERICS (boolean, optional, default false): if true, password will be required to contain at least one digit.
  • PASSWORD_INCLUDE_UPPER_CASE (boolean, optional, default false): if true, password will be required to contain at least one upper case character.
  • PASSWORD_INCLUDE_SPECIAL_CHARACTERS (boolean, optional, default false): if true, password will be required to contain at least one special character.
  • SIGN_UP_IS_PUBLIC (boolean, optional, default true): if true, non-authenticated users will be able to sign up for a new account. Otherwise, new user accounts can only be created by existing users.
  • REQUIRE_USER_AUTH (boolean, optional, default true): if true, most endpoints will require user authentication false disables user authentication requirement on all endpoints. Using false is deprecated.

↩️ GO TO ROOT DOC