External JS services must be packaged in a web app. Therefore, before creating a JS service, make sure you have a web app to package with the external JS service. If such a web app is not available, create a web app as described in Creating Web Apps.
Creating JS Services
JS services can be created and deployed using CLI commands that are provided by webOS OSE SDK. This topic describes the steps to create an external JS service. For detailed information on the commands, see Command-Line Interface.
Once you generate the service, JS service directory should be configured as below.
APP_DIR: Directory of the web app.
SERVICE_DIR: Directory of the service. This directory will include sub-directories of the services that are included in the web app.
Developing an external JS service requires the following steps:
Note If the JS service uses methods of external services, you must add the group information of the external methods to the requiredPermissions field in appinfo.json of the web app used for packaging the JS service. See Configuring the Web App for details.
Step 5: Install the JS Service
The JS service must be installed along with the web app.
About launching the JS service Because external JS services are installed as a dynamic service type, the service becomes active only when another application or service use the service by calling its method. If its method has been called as subscription, the service remains active without exiting. If the service is not used, it exits after 5 seconds. For more information on the 5-second timeout, see FAQ.
Debugging JS Services
To debug a JS service, Node’s Inspector is used. (Not to be confused with the legacy node-inspector, which has been deprecated as of Node 7.7.0. See Legacy Debugger for details.)
To enable the Inspector on a webOS OSE device, use the ares-inspect command. For detailed usage of the command, see ares-inspect.
To start debugging the JS service, open a client tool, such as Chrome DevTools and Visual Studio Code, and connect to the Inspector. For a list of tools that can connect to Node’s Inspector, see Inspector Clients.
The following shows an example screenshot of debugging with Chrome DevTools and Node’s Inspector.