Message:

JavaScript (10 posts)

For anyone developing business logic in JS, we have put together some suggestions for troubleshooting your deployment. The page is added to the product documentation. One of the new features described in the doc is the ability to redirect console.log  messages to Backendless logging. Once your JS code is deployed to production, messages from the console.log  calls will be routed to the log file wit the SERVER_CODE  logging category.

timerlog - Troubleshooting JS business logic

BLOG typescript - Developing TypeScript apps with BackendlessOne of the goals we have at Backendless is to make the platform uniformly available for different types of client technologies. The platform is truly cross-platform and it is a matter of time/effort to make it available to a new client environment.

Since we already have a super powerful SDK for JavaScript, creating a bridging technology for TypeScript was rather straight-forward. I am happy to announce that if you are building TypeScript apps, you can start taking advantage of everything Backendless has to offer. We put together a Quick Start Guide for integrating TypeScript with Backendless to make it easier for you to get started. Please give it a try and let us know how you liked it.

Posted in JavaScript

angular2 - Backendless and Angular 2If you have been waiting for Angular 2 support in Backendless, the wait is over. We have finished the integration of the Backendless SDK for JS and now it is available for TypeScript. An important side effect of this integration is support for the Angular 2 framework. The integration enables complete support of all Backendless APIs from an Angular 2 application. To help you get started with Backendless and Angular 2, we put together a Quick Start guide. Please let us know what you think. If you run into any problems, please post to the Backendless support forum.

Posted in JavaScript

We just pushed a new release to our production servers. The release includes multiple new features and a ton of improvements. Below is a summary of what went into the release. There will be a blog post with a video providing an in-depth review of each new feature:

Continue reading

Tizen is an open source platform residing within the Linux Foundation. It includes an operating system which can run smartphones, tablets, netbooks, onboard devices in smart cars as well as smart TVs. We wanted to see what it would take to integrate a Tizen app with Backendless because the benefits of such integration would be huge. For instance, data can be easily shared between different implementations of an app: a Tizen version of the app can easily communicate with the one running on Android or iOS by the means of Backendless service APIs.

Continue reading

In this write-up we review a JavaScript application we recently ported to Backendless. The application is an “editable invoice” which automatically saves its data including invoice line items, customer address, your own address, invoice number, etc. It is a good example demonstrating how to work with “related persistent data”, which means you can save a hierarchy or objects containing other objects (the “Invoice” object, contains a collection of “Line Items”). The application also demonstrates the functionality of user registration and login, although we stopped short of connecting the invoices with the user accounts (which would be fairly simple to add).

The Editable Invoice application is an effort by noBackend.org which helps educating the developers about the advantages of BaaS. The vision is to provide a reference implementation with various backends.

backendless editable invoice - JavaScript 'Invoice' App - with BaaS Data Management, User Registration and Login

The source code for the application has been push to our Github account.

Follow the steps below to setup and see the application in action:

  1. Register/login to the Backendless console. An application is created during the registration process or you can create one later at any time.
  2. Select an application once you login to console.
  3. Click the Manage icon. The App Settings screen will open up. The screen contains many useful settings and properties, but for now you will need only the Application ID and the Secret Key for the JavaScript clients.
    backendless app id secret key - JavaScript 'Invoice' App - with BaaS Data Management, User Registration and Login
  4. Keep the browser window open (you will need to copy/paste the ID and the Key from that screen) and open /editable-invoice/backendless/applogic.js in a text editor.
  5. Copy/paste the Application ID and Secret Key into the code on line 1:
  6. There is only one additional configuration step needed before you can run the application. Click the Users icon in the Backendless Console. The “User Properties” screen will open by default. Using this screen you can define the user properties which will be used by the Editable Invoice app. Click the “Add Custom Property” button and add the “login” property.
    adding login property - JavaScript 'Invoice' App - with BaaS Data Management, User Registration and Login
  7. Click “Save”. Make sure to select the “login” property as “Identity” by selecting the radio button for that property. The User Properties screen should look as shown below:
    editable invoice user properties - JavaScript 'Invoice' App - with BaaS Data Management, User Registration and Login
  8. Run the example. You can open the editable-invoice/index.html in a browser directly from the file system. Alternatively, you can deploy the entire application to a web server and load editable-invoice/index.html through a URL.

Try the following once you run the application:

  • Modify the invoice name by changing the main header at the top.
  • Modify the “Your Address” field.
  • Modify the “Your client’s address” field.
  • Add a new item to the invoice – enter item code, description, unit price and quantity. Click the “Add item” button.
  • Reload the application – you should see the invoice you just modified.
  • Check out the Sign Up/Sign In forms.
  • Login to Backendless Console and check the registered users in Data > Users, as well as data stored by the application in the “invoice” and “item” tables – the tables will be created automatically once you start using the example.

Reviewing Code

Below you will find some of the examples of using the Backendless API in the application:

  • Loading all invoices upon the start of the application. (/backendless/applogic.js, lines 3-15)

    Line 5 obtains a reference to the “invoices” data store in Backendless. The returned object provides access to the CRUD (Create, Retrieve, Update, Delete) operations for that table.
    Line 8 (find) sends a request to load all the previously saved invoice objects.
    Lines 10-13 request that the invoice objects returned by Backendless included references to the related “items” objects (an Invoice contains line items or just “items”).
  • Saving/Updating an Invoice. (/backendless/applogic.js, lines 39-62)

    Lines 3-7: check if the invoice has been previously saved. Uses the “condition” parameter where it specifies to search for the invoice by the “id” property.
    Lines 10-19: if the invoice is found (i.e. it has been previously saved), iterate through the items and assign the item’s “objectId”. In this example each “item” has an “id” assigned on the client-side (/shared/js/invoice.js, lines 14 and 28). On top of this, Backendless assigns its own ID to each saved object. That ID is stored in the “objectId” property. It is important to maintain consistency between the objects by correlating the IDs. This block of code accomplishes it for the save operation.
    Line 22: once the IDs are assigned, the entire invoice (with all the items) is saved.
  • Deleting an Invoice. (/backendless/applogic.js, lines 64-68)
  • User Registration. (/backendless/applogic.js, lines 82-93)

    Lines 2-5: Create a Backendless.User object which contains the values for all the user properties defined in step 7 above.
    Lines 6-11: Send a request to Backendless to register the user. The request is asynchronous with the Backendless.Async object handling the callbacks for success and error functions.
  • User Login. (/backendless/applogic.js, lines 94-104)

    Line 2: Send a login request to Backendless. The first argument must be a value for the property defined as “Identity” (see step 7 above).
Posted in Examples, JavaScript

The Backendless API for JavaScript can be used not only from the browser-based JavaScript applications, but also from a Node.js program. Using the API is very straight-forward. The instructions below describe the steps for setting up and running a basic Node.js example with Backendless. The example demonstrates registering a user with your Backendless application. It gathers email address and password and uses the User Registration API call to create an account.

  1. Just like with the browser JavaScript, an application must be identified using the application ID and a secret key. To get the ID and the key, login to the Backendless console, create/select your application and click the Manage icon. The default subsection is App Settings:
    appsettings - Using Backendless API with Node.js
  2. Save the code shown below into a file. Name the file example.js.
  3. Use the “Copy” buttons to copy the application id value and the secret key for JavaScript. The copied values must be assigned to the “appId” and “secretKey” variables accordingly.
  4. Download the Backendless JavaScript library file and save it in the same directory where you created example.js (step 2).
  5. Open a command prompt window and run the example using the following command:
    node example.js

The source code of the example is below (double-click the code to remove the highlighting, or click the <> button to toggle it):

Have fun and please let us know if you run into any problems!

Developing JavaScript applications with a backend-as-a-service platform like Backendless significantly simplifies and speeds up the development process. With the latest release of our SDK for JavaScript, this equally applies to both mobile and browser-based apps as well as Node.js applications. The video below reviews the available APIs and demonstrates sample applications showing the simplicity, ease-of-use and the power of Backendless services. Enjoy!

Posted in JavaScript, Video

js 300x300 - Backendless SDK for JavaScript is updated - now with Node.js supportWe have just updated our JavaScript library enabling API access to the Backendless services. The update includes support for Node.js applications as well as several bug fixes. The SDK is available for download in the downloads section of the website. Additionally, if you develop JS applications, you can always import the latest version of the Backendless JavaScript library using the following URLs:

Please let us know about any problems or if you have any suggestions, post them to the Backendless Community Support site.

Posted in JavaScript