To read more about the farming grants platform, see this docs repo:
To read more about Land Grants API see
The capabilities of the land-grants-api include:
The data ingestion process:
Visualising parcel data with qgis
Managing the service:
Pact testing
Authentication
Starting the api via Docker
Please install Node.js >= v18 and npm >= v9. You will find it
easier to use the Node Version Manager nvm
To use the correct version of Node.js for this application, via nvm:
cd land-grants-api
nvm useCopy the env.example file to .env, ask a colleague for the missing information.
Install application dependencies:
npm installIf you would like to run the API via docker, see here: Starting the API with Docker
In order to run this api locally in order to carry out development on the api, please follow:
Please ask a colleague for access to land data.
The following command:
- will start a dockerised postgres database
- run the liquibase migration, creating the tables
npm run dev:setupIn order to ingest data into your database, edit the file scripts/local-ingest, and set the path to you data directory, currently set to ./ingestion-data/data/.
We support the ingestion of the following resources:
- ingestion-data
- data
- parcels
- covers
- moorland
- agreements
- compatibility_matrix
- data
Run the local ingest script for each resource type:
node scripts/local-ingest
If you have issues running this, and ot throws errors like : No space left on device
-
Delete your docker volumes via desktop
-
Clean your docker instance
docker system prune -a -
Edit your compose.yml file, and increase the
shm_size
land-grants-backend-postgres:
image: postgis/postgis:16-3.4
shm_size: 2gb
If you would like to run the ingestion process end to end using AWS S3, you can use localstack:
npm run docker:localstack:up
There is a script to ingest data files for local development: (./src/scripts/ingest-land-data-local.js)
You will need to run the service locally, including database and localstack.
node ./src/scripts/ingest-land-data-local.js <resource type> <file path/directory>To ingest a parcels file:
node ./src/scripts/ingest-land-data-local.js parcels parcels_1.csvnode ./src/scripts/ingest-land-data-local.js parcels ../data-files/parcels/To run the application in development mode run the following command:
npm run devIf you do not plan to carry out development on this API you might prefer to start the api via docker compose, please visit here for details:
In order to run the test(s)
npm run test
npm run test:unit
npm run test:db
npm run test:ingestThe api uses Liquibase for db migrations, the changelog folder contains our current postgres schema.
When making changes to the existing schema, we cannot update the existing seed data files, or alter existing files in the changelog, you will need to create a new migration, which are named db.changelog-(n+1).xml.
This API includes swagger documentation, this can be viewed at:
http://{host_name}:3001/documentation
To mimic the application running in production mode locally run:
npm startAll available Npm scripts can be seen in package.json. To view them in your command line run:
npm runTo update dependencies use npm-check-updates:
The following script is a good start. Check out all the options on the npm-check-updates
ncu --interactive --format groupIf you are having issues with formatting of line breaks on Windows update your global git config by running:
git config --global core.autocrlf falseWe have added an example dependabot configuration file to the repository. You can enable it by renaming
the .github/example.dependabot.yml to .github/dependabot.yml
Instructions for setting up SonarCloud can be found in sonar-project.properties
THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:
http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3
The following attribution statement MUST be cited in your products and applications when using this information.
Contains public sector information licensed under the Open Government license v3
The Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.
It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.