sjs-3

Server JavaScript v3. Run JavaScript on the server in an ECMAScript 5 interpreter.

Hello world (content)

To write a hello world content app, create the following file structure:

/hello-world             [type: "app-1"]
/hello-world/.Inline     [type: "sjs-3"]

And put the following content in the .Inline file:

response.body('hello world')

If you expect the app to show up on a page, but it doesn’t, the placeholder of the /hello-world file is probably wrong.

Hello world (page)

To write a hello world page app, create the following file structure:

/hello-world             [type: "app-1"]
/hello-world/.Request    [type: "sjs-3"]
/hello-world/.Page

And put the following content in the .Request file:

response.body('hello world')
response.attrStr('content-type', 'text/html')

Execution limit

The execution time is currently limited in 1sec.

Limitations

The interpreter is based on Otto, thus shares its limitations:

  • “use strict” will parse, but does nothing.
  • The regular expression engine is not fully compatible with the ECMA5 specification.
    • (?=) - Lookahead (positive), currently a parsing error
    • (?!) - Lookahead (backhead), currently a parsing error
    • \1 - // Backreference (\1, \2, \3, …), currently a parsing error
    • \s only includes [\t\n\f\r ], the JavaScript definition also includes \v, Unicode “Separator, Space”, etc.
  • Otto targets ES5. ES6 features (eg: Typed Arrays) are not supported.