The require function in RESTApps
The require function is available in RESTApps
Requireables
// RESTApp-specific requireables
const
_ = require('underscore'), // [example](https://underscorejs.org/)
router = require('router'), // [example](/docs/rest-api/restapps/index.js#Routing)
appData = require('appData'), // [example](/docs/rest-api/restapps/configuration#h-AppData)
appResource = require('appResource'), // since 4.5.1 [example](/docs/rest-api/restapps/resource#h-AppResource)
appInfo = require('appInfo'), // since 4.5.3 [example](/docs/rest-api/restapps/require/appinfo)
events = require('events'), // since 4.5.2 [example](/docs/rest-api/restapps/events)
oauth2 = require('oauth2'), // since 7.0 [example](/docs/rest-api/restapps/require/oauth2)
privileged = require('privileged'), // since 7.0 [example](/docs/rest-api/restapps/require/privileged)
i18n = require('i18n'), // since 2024.04.2 [example](/docs/rest-api/restapps/i18n)
myModule = require('/module/nameOfModule'); // [example](/docs/rest-api/restapps/module)
The Sitevision Public API is always accessible server-side. All interfaces, classes and enums that are anotated with the @Requireable annotation is available via the require function.
Note that Public API requireables always has a leading capital letter (requireable name matches the name of the Public API interface/class/enum).
// Server context (e.g. index.js, server module etc.)
const
requester = require('Requester'),
properties = require('Properties'),
propertyUtil = require('PropertyUtil'),
resourceLocatorUtil = require('ResourceLocatorUtil'),
portletContextUtil = require('PortletContextUtil'),
permissionUtil = require('PermissionUtil'),
publishingUtil = require('PublishingUtil'),
versionUtil = require('VersionUtil'),
metadataUtil = require('MetadataUtil'),
metadataDefinitionUtil = require('MetadataDefinitionUtil'),
outputUtil = require('OutputUtil'),
userIdentityUtil = require('UserIdentityUtil'),
mimeTypeUtil = require('MimeTypeUtil'),
nodeIteratorUtil = require('NodeIteratorUtil'),
nodeTreeUtil = require('NodeTreeUtil'),
nodeComparatorUtil = require('NodeComparatorUtil'),
nodeFilterUtil = require('NodeFilterUtil'),
nodeTypeUtil = require('NodeTypeUtil'),
localInboundRestApi = require('RestApi'),
...
Config [@since 5.0]
Objects available server-side via the require function in config/index.js. Note that only server modules are available.
// Server context, e.g. config/index.js
const
_ = require('underscore'), // [example](https://underscorejs.org/)
router = require('router'), // [example](/docs/webapps/webapps-1/index.js#h-Routing)
i18n = require('i18n'), // [example](/docs/webapps/webapps-1/i18n)
appInfo = require('appInfo'), // since 4.5.3 [example](/docs/webapps/webapps-1/require/appinfo)
storage = require('storage'), // since 5.0
appData = require('appData'), // since 5.2 [example](/docs/webapps/webapps-1/configuration/appdata)
globalAppData = require('globalAppData'), // since 5.2 [example](/docs/webapps/webapps-1/configuration/appdata)
appResource = require('appResource'), // since 5.2 [example](/docs/webapps/webapps-1/resource)
privileged = require('privileged'), // since 7.0 [example](/docs/webapps/webapps-1/require/privileged)
myServerModule = require('/module/server/nameOfServerModule'); // [example](/docs/webapps/module)