RESTApp resources

Static resources are stored in the /resource folder.


The AppResource utility is used to access resources within a RESTApp. RESTApp resources are ONLY open to its enclosing RESTApp, i.e. its content cannot be extracted or downloaded elsewhere.

// retrieve an instance of the appResource utility
var appResource = require('appResource');

Resources can be accessed in three different ways, where pathToResource is the path to the file in the resource folder.


Returns the resource as a UTF-8 based string.


Returns the resource as a JCR Node (sv:image or sv:file).


Returns the resource as a

(function() {
   'use strict';

      router       = require('router'),
      appResource  = require('appResource'),
      logUtil      = require('LogUtil'),
      propertyUtil = require('PropertyUtil');

   router.get('/text', function(req, res) {
      var message = appResource.getContent('message.txt');
      res.json({message: message});
   router.get('/pdf', function(req, res) {
      var pdf = appResource.getNode('pdf/info.pdf');
   , 'jcr:primaryType')); // sv:file