To build your own functionality using our JavaScript block and SDK we wanted to give you the possibility to write your code in your favorite IDE and publish it to your app with zero effort. To do so we are using NPM (Node Package Modules) and Grunt (JavaScript Task Runner). 


Installing Node.js


Both NPM and grunt relay on Node.js thus to use either of both you need to have Node.js installed on your machine. To install node.js follow the steps below:


  1. Go to Nodejs.org and click the "Install" button.
  2. Start the installer and follow the installation instructions that appear on the screen.
  3. Once the installation is completed you should be able to use Node.js (and thus NPM) on your machine.


Creating a new JavaScript block


After you've installed Node.js on your machine you can start coding! To do so you need to have a JavaScript block in your app. If you don't you can add one following these simple steps:


  1. Go to https://design.appmachine.com and log in;

  2. Open the app to which you want to add the JavaScript block;
  3. Open the "Content" section of the app;
  4. Click the "Add Block" button;
  5. Select the "Pro" tab and then select the "JavaScript" block;
  6. Click "Add block";
  7. Give your JavaScript block a name and click "Finish";


Alright once you've added a new JavaScript block or selected your existing JavaScript block we can start building.


  1. First we need to setup the block on your machine. To do so, click the "Get me started" button;
  2. This will automatically download a zip file to your machine. Once the download is complete, unpack the zip folder to a directory on your machine.
  3. Now we need to do a little configuration, first we need to start a Terminal - for OS X or Linux users or a Command Prompt for Windows Users;
  4. Navigate to the directory you used to unpack the files in your Terminal or Command Prompt window;

  5. Once your working directory of the Terminal or Command Prompt is the same as the directory you used to unpack the zip file you can type the following command in your console:
    npm install

    Note: you might need to run this command with elevated permissions.

  6. Next we need to install grunt, to do so type the following commands:
    npm install grunt -g
    npm install grunt-cli -g

    Note: you might need to run this command with elevated permissions.

  7. Once all all the packages are installed you can already run the "Hello world" sample on your local machine. The only thing you need to do is type the following command:
    grunt init

  8. This will update the AppMachine Modules and start a local web server. Once completed your browser should open up and show you the default Hello world sample;


PLEASE NOTE:


This feature operates under the following two limitations:


1. A 15MB maximum for all save-file calls from the JavaScript zip file 


2. A 100MB maximum for all requests. 


 


If your file or requests exceed the maximums stated above, you will get an error message stating that this is the case. 


 


Next: Publishing your changes >