Would you like to contribute to the Titanium docs? To get started, sign up for an account on the Appcelerator Wiki and sign our CLA.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Important fields for API Builder applications are defined below and may be different from the npm version.

Dependencies

The application can import any third-party modules that are supported by standard Node.js applications. Before publishing the app to the cloud, make sure all dependencies are listed in the dependencies field in the application's package.json file. For example, to add support for MongoDB 1.2.0 or greater: 

Code Block
{
  "dependencies":{ "mongodb": ">1.2.0" }
}

Engines

You can specify which version of Node.js to run your application on. Use the engines field in package.json to specify engine versions. To specify the Node.js version, set the node key in the engines dictionary to a specific version of Node.js to use. For example, to specify to use version 0.10.22:

...

Info
titleDeprecated Behavior

Prior to API Runtime Services 1.2.0, if this field is undefined when you publish your application, the application will use 0.10.22 by default.

If this field is undefined when you republish your application and the latest supported Node.js version changed on the API Runtime Services servers, you will receive an error message when trying to publish your application. You must set the Node.js version to republish your application.

HealthCheck

Starting with API Runtime Services 1.2.0, you may define a health-check endpoint called arrowPing.json that returns a 200 HTTP code. To let API Runtime Services know you defined the health-check endpoint, set the healthCheck field to true.  For an example, see Arrow Project: Optional Health Check

Code Block
{
  healthCheck: true
}

Main

API Runtime Services uses the main field in package.json to determine the application's main entry point. Set this field to a JavaScript file. API Runtime Services loads and runs this file first.

...

You can load a module by leaving this field blank and specifying the scripts field.

Name

Use the name field to specify the name of the application. An app's name must be unique across all apps of a user or organization. It will be used to ID the app when publishing/unpublishing to the cloud, or setup the app through CLI commands.

...

Code Block
{
  "name": "MyArrowApp"
}

npmAuthentication

To enable authenticated package installs from a private npm registry specified by npmRegistry, add the npmAuthentication field in your application's package.json file and set it to true

...

See https://www.nodejitsu.com/documentation/npm/cli/ for more information.

npmRegistry

If you want to use a different npm registry besides the official public npm registry to install dependencies, add the npmRegistry field to the package.json and set the value to the registry URL you want to use. For example, the entry below uses a European npm mirror:

...

To require authentication for npm installs, add the npmAuthentication field to your package.json file.

Scripts

Preinstall and Postinstall

Specifies a path to a script to execute before or after the application is built.  You can use the script to install custom binaries in the project folder.

...

Note

Do not name the script install.sh, located in the root folder of the project. The name is reserved to specify a script to install binaries to the container.

Start

If your application's package.json file does not specify a main field, Appcelerator Cloud will now look at the scripts.start field in package.json to determine the main module to launch. Appcelerator Cloud will execute the start script using npm start.

...

Code Block
{
  "scripts": { "start": "foo" }
}

Version

Version of the application. Used to version the application.

...