Versions Compared

Key

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

...

File/Folder Name
Description
app.jsThe entry point to the connector for testing, which launches a server instance.
appc.jsonProject configuration file. Do not modify this file.
confContains configuration files in JSON format for the connector. The file default.js is used for testing the connector. You can create an example configuration file, which is copied to the project when it is installed. See the  Connector Configuration File section.
index.jsThe entry point to the connector.
libContains the logic for your connector. Requires a index.js file. See the Connector Logic section.
logsContains generated log files when running your project locally. If you test the connector, the generated log files will get packaged with the application. You may want to disable logging by setting the transactionLogEnabled property to false in the conf/default.js file.
modelsContains Model JavaScript files, used to declare the schema for your data and generate API endpoints for the connector. See Models and API Endpoints below.
node_modulesContains project dependencies. API Builder automatically installs any project dependencies declared in the package.json file.
package.jsonNPM configuration file to declare project dependencies and other build or runtime configurations.

...

  • Select  Component for the type of component
  • Select Connector for the component
  • Select Empty Connector Project to use a boilerplate project.
  • Enter a name and directory name for your project.
Code Block
languagebash
collapsetrue
$ appc generate
Appcelerator Command-Line Interface, version 0.2.230
Copyright (c) 2014-2015, Appcelerator, Inc.  All Rights Reserved.
 
? What type of component would you like to generate? Arrow Component
? What Arrow component would you like to generate? Arrow Connector
? Which Connector would you like to generate? Empty Connector Project
? What is the connector name? sample.connector
? Which directory to generate into? sample.connector

...

Like an API Builder project, you can locally run the Connector project and make APIs calls to it. From the project directory, execute: 

Code Block
languagebash
appc run

Once the server starts, you can make cURL or other requests to the server. Open the admin console, then go to the API Docs tab to retrieve the cURL commands for the methods. Copy and paste a command in a terminal to test it.

...

To publish the connector, execute the following command from the project directory: 

Code Block
languagebash
appc publish

By default, the access level for the connector is set to private, so only the creator can access the connector. To share the connector with other people or publicly, specify a different access level with the appc access command and add people or organizations to your component using the appc userand commandsappc org.

...

Code Block
titlelib/index.js
languagejs
collapsetrue
/*
 Welcome to your new connector!
 TODO: First things first, look at the "capabilities" array TODOs down below.
 */
var _ = require('lodash');

/**
 * Creates your connector for Arrow.
 */
exports.create = function (Arrow) {
        var Connector = Arrow.Connector,
                Capabilities = Connector.Capabilities;

        return Connector.extend({
                filename: module.filename,
                capabilities: [
                        // TODO: Get started by uncommenting the next line and running `appc run`.
                        //Capabilities.ConnectsToADataSource,


                        // TODO: Each of these capabilities is optional; add the ones you want, and delete the rest.
                        // (Hint: I've found it to be easiest to add these one at a time, running `appc run` for guidance.)
                        //Capabilities.ValidatesConfiguration,
                        //Capabilities.ContainsModels,
                        //Capabilities.GeneratesModels,
                        //Capabilities.CanCreate,
                        //Capabilities.CanRetrieve,
                        //Capabilities.CanUpdate,
                        //Capabilities.CanDelete,
                        //Capabilities.AuthenticatesThroughConnector
                ]
        });
};

...

Code Block
titleconf/example.config.js
languagejs
module.exports = {
    connectors: {
        'connector.name': {
            setting1: 'foo',
            setting2: 'bar',
            setting3: 'baz'
        }
    }
};

...

Code Block
titlelib/index.js
languagejs
exports.create = function(Arrow) {
    var Connector = Arrow.Connector;
    return Connector.extend({
        defaultConfig: require('fs').readFileSync(__dirname + '/../conf/example.config.js', 'utf8'),
        ...
    });
}

...

Code Block
titleconf/myconnector.default.js
languagejs
module.exports = {
    connectors: {
        'connector.name': {
            setting1: 'foo',
            setting2: 'bar',
            setting3: 'baz',
            modelAutogen: false
        }
    }
};

You may specify specific models to generate from a connector. Set the generateModels key to an array of model names you want to include.

Code Block
languagejs
module.exports = {
    connectors: {
        'connector.name': {
            generateModels: [
                'foo',
                'bar',
                'baz'
            ]
        }
    }
}

...

Code Block
titlepackage.json
languagejs
{
    "dependencies":{ "mongodb": ">1.2.0" }
}