Skip to content

Script Environment

Craig Edwards edited this page Jul 10, 2020 · 5 revisions

Sporks' Scripting environment is a ES6-compatible javascript interpreter designed for embedded systems.

It can run many scripts you may decide to throw at it, so long as they fit within the restrictions of the execution limits.

Before each request is passed to the scripting engine, the following occurs:

  • The scripting engine is reset, creating a new context to contain the code - this means that global variables you set will be lost between event invocations. You should ensure that all events you create are stateless

During execution of your event, the following applies:

  • There is no I/O access except for the objects and functions provided by the Sporks API. You cannot create TCP sockets, or open files, except via the get(), post(), load() and save() functions. In fact, the virtual machine has no concept of a file system or network stack as you'd expect to find it in for example node.js, these features are not compiled in.
  • Node.js/V8 features such as 'require' are not available for use, as this is not a V8 based JavaScript engine.
  • If your event causes any messages to be sent, this overrides any learned responses from Sporks that may otherwise be produced. This allows you to override responses on a per-server basis.
Clone this wiki locally