| copyright |
|
||
|---|---|---|---|
| lastupdated | 2017-07-18 |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen: .screen} {:codeblock: .codeblock} {:pre: .pre}
{: #tutorial}
The following end-to-end tutorial walks through the steps to create a project from the BFF Basic Starter. Steps include installing prerequisite tools, and the steps to run the project code.
{: #dev_tools}
Ensure that you install the prerequisite developer tools {: new_window}.
{: #choose_how}
Create a project by using either the web-based {{site.data.keyword.dev_console}} or through the command-driven {{site.data.keyword.dev_cli_notm}}. Once the project is created, you can then run the project.
{: #create-devex}
-
Create a project in the {{site.data.keyword.Bluemix}} {{site.data.keyword.dev_console}}.
-
From the Getting Started
page in the {{site.data.keyword.dev_console}}, click Create Project.
You can alternatively click Create Project from the Projects page.
-
Select Backend for Frontend and click Next.
-
Select Basic Backend and click Next.
-
Enter your project name. For this tutorial, use
BFFProject. -
Enter a unique hostname, such as your initials plus
-devhost. For example:
abc-devhost-
Select your language platform. For this tutorial, use
Node. -
Click Create.
-
-
Optional: Add the Data capability.
- Click View for Data on the Project Overview page.
You can alternatively select Create or Add Existing on the Capabilities > Data page.
- Enter your service name and click Create.
-
Generate your project code:
-
Click Get the Code on the Project Overview page to select your language.
You can alternatively click on the Code page.
-
Click Generate Code.
-
When the project code is finished generating, click Download Code to download your project archive.
-
-
Begin working with your downloaded project:
-
Expand the archived file.
-
Navigate to the new project directory.
-
Use the {{site.data.keyword.dev_cli_notm}} to proceed.
-
-
Optional: Update your project to generate a new language.
{: #create-cli}
-
Ensure that you install the {{site.data.keyword.dev_cli_short}}.
-
In your Terminal prompt, navigate to a local directory of your choice and run the following command.
bx dev create{: codeblock}
-
Provide the following values when prompted:
- Select a pattern: 3 (for Backend for Frontend)
- Select a starter: 1 (for Basic Backend)
- Select a language: 1 (for Node)
- Enter a name for your project:
BFFProjectCLI - Enter a hostname for your project:
abc-devhost-
Enter a unique hostname, such as your initials plus
-devhost. For example:abc-devhost
-
-
After your
BFFProjectCLIis saved, navigate to theBFFProjectCLIfolder. -
Add your own code, build, and run the project.
-
Build your project with the following command:
bx dev build{: codeblock}
-
Run your project with the following command:
bx dev run{: codeblock}
-
{: #running-bff}
You can run the application locally on your host system if you install the necessary build tools, or by using the available container support in the {{site.data.keyword.dev_cli_notm}}.
{: #using-blumix}
-
To build the project in your current project directory, enter the following command:
bx dev build{: codeblock}
-
To run the project in your current project directory, enter the following command:
bx dev run{: codeblock}
-
You can run curl on your server with:
curl http://localhost:8080{: codeblock}
-
You can view the API document on your server at:
http://localhost:8080/swagger/api{: codeblock}
-
You can explore the API on your server at:
http://localhost:8080/explorer{: codeblock}