Creating Callable Profound.js Modules
Â
Profound.js modules are units of code that you can either call directly or call from another module.
A low-code / no-code module is created visually using the Visual Designer tool and saved as a Rich Display File with a .json extension. If you prefer to use code to create your module, it can be written in JavaScript and saved to a file with a .js extension.
The files should be placed within a subdirectory of the modules directory within your Profound.js installation. These subdirectories can represent Workspaces in Profound.js.
When used on IBM i, subdirectories of modules map to IBM i libraries. The pathlist or the IBM i library list searches these subdirectories.
In PJS 7.10 onwards, enabling appendPJSpathlist in config.js will append the IBM i library list onto the default PJS pathlist. Modules are then searched starting from the default PJS pathlist before the IBM i library.
When using JavaScript code, in order to create a callable Profound.js module, the JavaScript file you create must export a runable function by specifying the exports.run or export.default property. The following example shows a skeleton for module code. Every runable module must have a similar setup.
mytest.js
function mytest() {
// executable code goes here
}
Â
exports.default = mytest;
Once a module is created, it can be called one of several ways:
As a workspace start file
As configured workspace route
Directly as an initial module through a URL alias
By another module using the pjs.call() API
As a Web Service using the profoundjs.express() API
Using the PJSCALL command from an interactive Genie session
Using a Proxy Program from an interactive Genie session
Â
Some documentation pages have recently moved to a new section: Profound AppDev. If you are having trouble finding specific pages, try the documentation search capability or reach out to our Support team!