Available Modules and Syntax

Kii Cloud supports the following modules for writing server code.

You can leverage the Kii Cloud SDK for JavaScript but the Thing-IF SDK for JavaScript cannot be used with server code.

You cannot use modules not listed above (e.g., the Crypto module) in your server code. This restriction is to ensure the performance and security.

You cannot use the HTTP module, but you can access other servers using the jQuery. You can achieve cross-domain communication, but you cannot connect to an HTTPS server with a self-signed certificate. See the sample in Getting an Object Body via the REST API.

Using modules

You do not have to install the modules on the servers. Some modules, however, require you to execute the "require" at the head of your JavaScript code. The following table summarizes if you need to execute the "require".

Module Need to execute the "require"?
Node.js punycode Yes
Query String Yes
UDP/Datagram Sockets Yes
URL Yes
jQuery No
Underscore.js Yes
JSON object No
Kii Cloud *1 Kii Cloud SDK for JavaScript No

*1 You cannot use the Thing-IF SDK for JavaScript with server code.

For example, this is an example of checking the size of the list with Underscore.js.

var _ = require("underscore");
function main(params, context) {
    return _.size({a:1, b:2, c:3});
}

When you are using Kii SDK for JavaScript, no initialization (e.g. executing the Kii.initializeWithSite()) is needed.

Available syntax

The specification of ES6 or later is not supported even Node.js v16.X is used as the JavaScript engine. Use the ES5 syntax for JavaScript.