Versions Compared

Key

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

...

File/Folder NameDescription
apisContains API JavaScript files, used to create custom entry points for the application. For details, see API Builder APIs.
app.jsEntry The entry point to the application if it is used as a server. You can monitor the startup and shutdown sequence.
appc.jsonContains component dependencies and API Runtime Services deployment settings. For details, see API Runtime Configuration.
blocksContains Block JavaScript files, used to create pre- and post-processing filters. For details, see API Builder Blocks.
codeblocks
Contains Codeblock, JSON, and Javascript files, used for defining custom functions for use in Flows.
confContains configuration files in JSON format for the project and required connectors. For details, see Console Configuration.
docs

Contains generated docs for your project's APIs.

endpoints
Contains Endpoint JSON files, these are OpenAPI 2.0 (Swagger) documents used to create custom entry points for the application, with execution logic defined by linked Flows
flows
Contains Flow JSON files, used for defining business logic for Endpoints.
index.jsEntry The entry point to the application if it is used as a module.
logsContains generated log files when running your project locally.
modelsContains Model JavaScript files, used to define the schema for your data. For details, see Models.
node_modulesContains project dependencies. API Builder automatically installs any project dependencies declared in the package.json file.
nodesContains custom flow-nodes for use in Flows. Flow-nodes must be Node.js packages in their own folders named nodehandler-*.
package.jsonNPM configuration file to declare project dependencies and other build or runtime configurations. For details, see NodeJS Configuration.
package-lock.jsonNPM configuration file that is generated when NPM modifies either the node_modules tree or the package.json file. It describes the exact tree that was generated so that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates. The npm shrinkwrap command repurposes the package-lock.json file into a publishable npm-shrinkwrap.json file. For additional information on shrink wrapping a project, refer to npm shrinkwrap.
serviceconnectorsContains installed service connectors used within Flows for connecting to and interacting with external services.
webContains Web files, used to create endpoints that render UI.
web/publicContains static assets, such as CSS, HTML, image, or JavaScript files, for your Web interface.
web/routesContains Route JavaScript files, used to define the API endpoint and logic for your Web interface.
web/viewsContains template files for your Web interface. Files must have one of the following extensions: ejs, hbs, md, or jsx.

...

To deploy an application to API Runtime Services, run the appc publish command from the API Runtime Services project directory. Your project source code will be uploaded to the API Runtime Services where npm install will be executed against the project, which downloads and installs any NPM module dependencies. When the installation completes, the application is executed using node.

...

Multiexcerpt
MultiExcerptNamemigration

Node.js version

Prior to API Runtime Services (formerly known as Arrow Cloud) 1.2.0, the only Node.js versions you could use were 0.8.26 and 0.10.22.

Starting with API Runtime Services 1.2.0, you may specify any version of Node.js. Node.js 0.8.26, 0.10.22 and 0.12.4 are built in, but other versions will be downloaded from https://nodejs.org/ when the application is built prior to running npm install.

To specify a Node.js version, in the package.json file, set the engines.node key to the version of Node.js you want to use. DO NOT SPECIFY A RANGE. If you do not specify a Node.js version, the application will use 4.4.7 by default (as of SDK 6.0.0).

Code Block
titlepackage.json
{
  "engines": {
    "node": "0.12.4"
  }
}

Port binding

Starting with API Runtime Services 1.2.0, you may explicitly set the port the application listens on. Set the cloud.environment.PORT key in appc.json file. or use the appc cloud config --set "PORT=<PORT_NUMBER>" command to set the special environment variable PORT. If you do not set PORT explicitly before publishing your application, API Runtime Services sets it to 80 by default.

Code Block
titleappc.json
{
  cloud: {
    environment: {
      PORT: 8080
    }
  }
}

Verify that the application listens on PORT, otherwise your app cannot be connected. Use process.env.PORT in the application to verify the application is connected to a port.

Install custom binaries

API Runtime Services allows you to install additional binaries before your application is built.

Starting with API Runtime Services 1.3.0, to install additional third-party tools, create a script called install.sh in the project's root folder, which installs the required packages.

Info
titleImageMagick and PhantomJS

Both ImageMagick and PhantomJS are pre-installed on the containers. 

Below is a sample script located at in the ./install.sh folder in the application's directory.

Code Block
titleinstall.sh
languagebash
#!/bin/bash

echo "---"
echo "Start installing some tools..."
echo "(This bash script is run at npm preinstall.)"
echo "---"

apt-get install -qq tar bzip2 libaio1

apt-get install -y wget

echo "---"
echo "done installing additional tools!"
echo "---"

Prior to Release 1.3.0, you needed to create a script in your project folder (no name restrictions) and add the script to the package.json file. In the  package.json  file, set the  scripts.preinstall  or scripts.postinstall field to the path to the script:

Code Block
titlepackage.json
  "scripts": {
    "preinstall": "myscript.sh"
  }

Note that from API Runtime Services 1.3.0 and later, you can still use the above method but do not name the script install.sh or it will run twice, and only install the binaries in the project directory. Prior to API Runtime Services 1.3.0, binaries could be installed outside the project directory.

...

To set environment variables, use the appc cloud config --set <key>=<value> command. To set more than one variable at a time, comma-separate the key-value pairs.

...

To use this feature you application uses cluster.setupMaster() to set a path to a custom file to use for each child process. A cluster should listen on port 9000 or greater to avoid port conflicts. If the port your application is trying to listen on is in use, an EADDRINUSE error will result. Your application must also have privileges to listen on the specified port, otherwise, an EACCES error will result.

...

Code Block
titlechild.js
var http = require('http');

console.log('Running in child process of a cluster.')

http.createServer(function(req, res) {
    res.writeHead(200);
    res.end("hello world!!!\n");
}).listen(9000);

Application limitations

DiskspaceDisk space

Each application can use 1.8 GB of diskspacedisk space. The application can only write files to the project's root directory and to the /tmp folder.

...