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.

Table of Contents

Introduction

API Builder uses the configuration files in the project's conf directory to initialize the application and its connectors.  Each JavaScript file in the directory should expose an object of key-value pairs.  You may add any arbitrary key-value pair besides the one described below.  The values will be passed to any method that is passed the API Builder configuration object.  Note that the API key values and session object are auto-generated when you create a new API Builder project.

...

Since Release 5.0.0, you can override the configuration file settings with an environment variable.  For the setting you want to override, prefix variable with ARROW_.  For example, if you want to override the apikey setting, set the ARROW_APIKEY environment variable.

Example

Code Block
title./conf/foo.js
module.exports = {
    // These are generated when you create a new project
    apikey_production: 'xxxxxxxxxxxxxxxxxxxxxxxxx',
    apikey_development: 'yyyyyyyyyyyyyyyyyyyyyyyyy',
 
    // Selects the authorization type -- uses HTTP Basic Authorization by default
    APIKeyAuthType: 'basic',
 
    // All API paths will be prefixed with '/foo'
    apiPrefix: '/foo',
 
    // Sets body-parser middleware setting
    bodyParser: {
        limit: 1 * 1024 * 1024
    },
 
    // Sets busboy initialization settings
    busboy: {
        limit: {
            fieldNameSize: 100,
            fieldSize: 1 * 1024 * 1024
        } 
    },
 
    // Connector settings...
    connectors: {
        connector_name: {
            collection: 'foobar'
        },
        another_connector: {
            name: 'foobaz'
        }
    },
 
    // et cetera, et cetera, et cetera
}

 

Settings

admin

Configures the admin console. The admin object may contain the following key-value pairs:

Multiexcerpt
MultiExcerptNameadmin
KeyTypeDefaultDescription
apiDocPrefixString/apidocPath to access the generated API docs.
cssArray<String>-CSS files to inject to customize the styling of the Admin Console and API docs. Files must be relative to ./web/public/ folder or absolute URLs.

customHTMLErrorPage

String-HTML content to display for unauthorized access (HTTP 401 error code).
disableAuthBooleanfalseSet to true to disable authorization to access the admin console.
disableAPIDocBooleanfalseSet to true to not display the generated API Docs.

enableAdminInProduction

BooleantrueSet to true to enable the admin console in the production environment.
enabledBooleantrueSet to true to enable the admin console.
jsArray<String>-JavaScript files to inject to customize the styling of the Admin Console and API docs. Files must be relative to ./web/public/ folder or absolute URLs.
prefixString/arrowPath to access the admin console.

validEmails

Array<String>developer's e-mail addressWhen the application is in production, restrict access to the admin console to the specified accounts.

validOrgs

Array<Number>developer's organizationWhen the application is in production, restrict access to the admin console to the specified organizations

apikey_development

Generated API key used when testing the application, that is, running the application locally.

apikey_production

Generated API key used when running the application in production, that is, when it is deployed to API Runtime Services.

APIKeyAuthPlugin

Location of the authorization module if APIKeyAuthType is set to plugin.

For details, see API Builder Authentication Schemes.

APIKeyAuthType

String value indicating the authorization type for the application.  By default, it is set to basic.

For details, see API Builder Authentication Schemes.

apiPrefix

Prefix path to use for the API requests for Models and APIs.  Each endpoint you define in a Model or API will be prefixed by this value. By default, it is set to /api.

bodyParser

Configures body-parser middleware settings.  The bodyParser object may contain the following key-value pairs:

KeyTypeDefaultDescription
limitNumber/String'1mb'Sets the maximum request body size in bytes for the body-parser middleware.

busboy

Configuration object to pass to the busboy constructor, which is created when the API Builder middleware is initialized.  For properties you can set, see the busboy documentation.

connectors

Configures the connectors used by the application. The connectors field is an object of key-value pairs where the key is the name of the connector and the value is another key-value pair object used to configure the connector. The configuration object is specific to each connector.

Most connectors will have their own default configuration file in the conf directory.

cors

Configures the CORS settings. The cors object may contain the following key-value pairs:

KeyTypeDescription

Access-Control-Allow-Origin

StringSpecifies the URI that can access the server. Defaults to all.
safeHeadersArray<String>HTTP headers to expose and allow, that is, the specified value is set for Access-Control-Expose-Headers and Access-Control-Allow-Headers.

defaultConnector

Specify the name of the default connector. Used if a Model does not specify one.

ignoreDuplicateModels

Set to true to ignore duplicate Model definitions.  Defaults to false, which will throw an error if a model definition is duplicated.

logging

Configures the logger utility.  The logging object may contain the following key-value pairs:

KeyTypeDefaultDescription
logdirString./logsLocation of the transaction logs if enabled.

transactionLogEnabled

BooleantrueSet to true to enable transaction logs.

logLevel

Sets the log level for the logger utility.  Accepted values are debugerrorfatalinfotrace, or warn.

port

Sets the port number for the server if the PORT environment variable is not set.  By default, the port is set to 8080.

ssl

Configures SSL settings for the server.  The ssl object may contain the following key-value pairs:

...