For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


Create JavaScript adapters

You create adapters with Maven, the MobileFirst Platform CLI, or the MobileFirst Operations Console.

Parent topic: Working with JavaScript adapters


Creating adapters by using Maven


Before you begin

To work with Maven, ensure that you have it installed. For more information, see https://maven.apache.org/install.html.


Procedure

In the command line, cd to the location for the new Maven project, then type in the following command:

mvn archetype:generate -DarchetypeGroupId=com.ibm.mfp -DarchetypeArtifactId=<adapter-maven-archetype-type> -DarchetypeVersion=<latest_version> -DgroupId=<created_project_groupId> -DartifactId=<created_project_artifactId> -Dversion=<created_project_version> The following is an explanation of the parameters for the archetype:generate command:

archetypeGroupId
Archetype group ID. Identifies the MobileFirst adapter archetype template. Specify com.ibm.mfp in all cases.
archetypeArtifactId
Archetype artifact ID. Identifies the MobileFirst adapter archetype template. Specify one of the following:

  • adapter-maven-archetype-http to create a JavaScript adapter with HTTP connectivity
  • adapter-maven-archetype-sql to create a JavaScript adapter with SQL connectivity
archetypeVersion
Archetype version. Identifies the MobileFirst adapter archetype template. Specify the latest version available in the repository.
groupId
Sets the group of the new Maven project. Specify your own value. For more information, see What is the POM?
artifactId
Sets the artifact ID of the new Maven project. This value will later be used as the adapter name. Specify your own value.

Note: The artifact ID can contain alphanumeric characters and underscores, and must start with a letter.

version
Sets the version of the new Maven project. Set your own value. The default is 1.0-SNAPSHOT.


Creating adapters using MobileFirst Platform CLI


Before you begin

Ensure that you have installed MobileFirst Platform CLI and Maven.


Procedure

In the command prompt, run the following command:

mfpdev adapter create <adapter_name> -t <adapter_type> -p <adapter_package_name> -g <maven_project_groupid> The following is an explanation of the parameters for the mfpdev adapter create command:

adapter_name
Adapter name. Specify a value.
adapter_type
Adapter type. Specify one of the following:

  • HTTP to create a JavaScript adapter with HTTP connectivity
  • SQL to create a JavaScript adapter with SQL connectivity
maven_project_groupid
Group ID of the Maven project.


Creating adapters with the MobileFirst Operations Console


Procedure

We can also create an adapter in the MobileFirst Operations Console by clicking New in the Adapters area and following the instructions.