Skip to content

Using Third Party Libraries in Rulesets (server side)

NOTE -- This article is under initial construction and review. Content may change while this notice is present.

Overview

Third party NodeJS libraries can now be utilised from within server side rulesets.

It is necessary to copy the node js files of the library to a specific folder within the Formbird application folder structure. In this way, only fully sanctioned libraries can be used from within a ruleset.

This usage is for scripting within server side rulesets only.

Requirements

  • Formbird app version 2.1.5 or later

Method

  • Copy the third-party node library into Formbird server folders (see section below)
  • Use the following code to "import" the library
var ourObject = require('./server/vendor/object-folder/object-file.js');
-- OR --
var ourObject = require('./server/vendor/object-file.js');

depending on how you have copied the third party library.

  • Utilise the imported object as per the library's syntax.

Example

   turf = require('./server/vendor/turf.js');

   var line = turf && turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
   ntf.logger.info("********************* Turf js result : " + JSON.stringify(line));

Installing the 3rd Party Node Library to Formbird

  • Install the third party node library at any location on your hard drive, eg npm install turf

  • Copy the content from within the resulting node_modules folder (eg, folder called "turf"), to your Formbird application folder, formbird-app/server/vendor/ folder.

-- OR --

  • Find the single js file that encapsulates the library (eg, ./turf/turf.js), and copy only that to formbird-app/server/vendor/ folder.