Sample Plugin Code
BioT provides sample JavaScript and Python plugin code that demonstrates the steps needed for plugin development.
Prerequisites
To pack and deploy the sample, install the following on your machine:
Download the Code
You can find the sample code here:
To download the code, make sure you have Git installed and run:
git clone https://bitbucket.org/softimize/plugin-lambda-seed-public.gitgit clone https://bitbucket.org/softimize/plugin-lambda-seed-python-public.gitNext, download the dependencies using the instructions in each repository’s README and you should be good to go.
Basic Plugin Flow
The following boilerplate functions run before your main code (feel free to adjust them):
- extractDataFromEvent Extracts the data and metadata from the event.
- getTraceIdReturns the trace ID from the event or creates a new one. Used for tracking the full flow in the logs.
- configureLogger Sets up the log structure (including traceId).
- authenticate Validates the JWT token sent by the platform.
- login Logs in to BioT with a service user and gets a token.
- perform placeholder for your business logic.
- response Creates the final response (see errorResponseCreator for errors).
extractDataFromEvent
A helper that reads the raw JSON payload from the event.
getTraceId
Each API call includes a trace ID that also appears in the logs. This lets you follow the complete flow from the plugin through all internal API calls.
configureLogger
Prepares the log format so searching and debugging is easier.
authenticate
Validates the JWT token to make sure the call really came from BioT.
login
Before calling BioT APIs, the plugin needs to log in and get a fresh token using a service user.
perform
Maps the event type to the correct handler. Under the src folder, each plugin type has its own handler, for example:
- Notification handler: "./notification/index.js"
- Interceptor Post: "./interceptorPost/index.js"
- Interceptor Pre: "./interceptorPre/index.js"
- Interceptor Post Entity: "./interceptorPostEntity/index.js"
Check the relevant handler to see how to process the event and make API calls.
response
The response depends on your logic and should be updated accordingly.
Deploy the Plugin
Before deploying, zip the source code. You’ll find instructions for this in each repository’s README.
To deploy, follow the steps in Custom Plugin Deployment.
Test Your Plugin
Register your plugin as a Notification or Interceptor and verify it works as expected.
Updated 6 days ago
