File and folder structure
Navigate your local collection module folder with confidence
Overview
This guide will introduce you to the different files and folders you will find within your collection module folder when you clone a collection module from Root (or from GitHub).
.root-config.json
.root-config.json
This config file represents your collection module's basic setup and settings.
Property | Definition |
---|---|
collectionModuleKey | String. The unique key used to identify your collection module across Root. To link a collection module to a product module, you need to update the .root-config.json in the collection module with this key in the collectionModules section. |
collectionModuleName | String. The name of your collection module. |
organizationId | String. The UUID of the organisation that owns the collection module. |
host | String. For most collection modules, this is api.uk.rootplatform.com (UK multi-tenant)"api.rootplatform.com" (South Africa multi-tenant). If you have questions about this property, please contact support at [email protected]. |
.root-auth
.root-auth
This file contains your API key, which authorises you to pull and push collection module changes to Root. Your API key needs to be included in this file as follows:
ROOT_API_KEY=<your API Key>
When you clone a collection module from Root to your local machine, this file will automatically be included in the folder.
However, if you are cloning a collection module from GitHub, this file will not be included, as it is listed in the .gitignore
file, which tells git to ignore it. In this case, you will need to create the file yourself and add a valid sandbox or production API key created under the organisation that owns the collection module.
README.md
README.md
You can add a README file to a collection module to communicate important information about the project. This file can contain information such as:
- What the product is
- Who the client, underwriting insurer and IP owner are
- Links to any related files on Google Drive
- Who maintains and contributes to the project
- What are the outstanding tasks still to complete in this module
lifecycle-hooks
lifecycle-hooks
This file contains all of the render functions. Read more about how these work in Rendering UI Components
webhook-hooks
webhook-hooks
This file contains the processWebhookRequest
function. This function handles webhook requests, typically from payment providers like Stripe.
config
config
This file handles the configuration for the project. This is where your environment variables and configuration will live.
You are free to update this to suit your requirements.
code
code
Type checking in JavaScript
By default, we add a VS Code setting to your collection module code directory to enable type checking. This allows you to leverage some of TypeScript's advanced type checking and error reporting functionality in regular JavaScript files - a great way to catch common programming mistakes.
These type checks use the type declaration files included under
code > types
andcode > unit-tests > types
.To turn off type checking, open the relevant
jsconfig.json
file and setcompilerOptions.checkJs
tofalse
.
This folder contains your collection module code. Most of the collection module code will live within handlers called from the webhook-hooks.ts
file. This file handles
The collection module code consists of multiple JavaScript files. These files are compiled into a single distribution file when uploaded to AWS Lambda.
Split collection module code into separate files
You can use the collection module code files to organise your code into logical sections. For example, you can include the code for each hook in a separate file, with a further file for helper functions.
You are free to add or remove code files to suit your requirements.
Controllers
The controllers folder houses the root-event-processors, and will often be where you place your payment provider processors as well.
Other files and folders
The .gitignore
file is only relevant if you use GitHub to collaborate with others on a product module. This file ensures that your secret API key is not uploaded to GitHub.
The .vscode
folder is used by VS Code's IntelliSense feature to generate Root-specific code snippets.
Updated 5 months ago