RESTApps 2

RESTApps 2 available since 9.0 intoduces a few changes to how to build a RESTApp. Changes includes the following:

Loop protection

Sitevision will transform bundled apps to protect against infinite loops. The protection process takes place when a bundled app is deployed as opposed to runtime in RESTApps 1. This may take a couple of seconds depending on the size of the bundled app. Calls to the bundled app will not be possible until the protection process is complete. Hence, it is not recommended to force-deploy a bundled app in a production environment.

Structure and importing

Structure of RESTApps 1 and 2 are very similar but RESTApps 2 is less rigid. If you needed to create utilities for separating your code it had to be done in the module folder.

Imports no longer is done by the require function. Use import and define the path.

import banana from '../fruits/Banana';
import chocolate from '../candy/Chocolate';

import router from '@sitevision/api/common/router';
import portletContextUtil from '@sitevision/api/server/PortletContextUtil';

Inaccessible requireables

Given the architecture of a bundled app, some app-requireables are inaccessible during render due to no longer being needed or no longer supported:

  • require('/module/*')
  • require('underscore')

New property in manifest.json

The app's manifest.json now accepts a new property:

  • bundled. Boolean to tell Sitevision whether this is a bundled app or not.