Versions Compared

Key

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

...

  • 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" }
}