docs

Page

Getting started with Chorus is very easy!

If you are new to Node.js and/or MongoDB there are many introductions you can look at. I like the one Elliot Bonneville wrote recently because it talks about both at the same time.

1. Let’s run our first sample

Please install node.jsmongodb and meteor first.

You can either run our install script in the directory in which you want to install and run the sample:

$ cd /directory/of/the/sample
$ curl http://www.chorusjs.com/install | sh

or you can enter the same instructions manually:

$ cd /directory/of/the/sample
$ mkdir logs

[copy the sample files in the /directory/of/the/sample]

$ npm install
$ node calculateArea_v1.js

At that point you should see in the terminal window:

[WARN] [default] - ------------ Process Endpoints ---------------
[WARN] [default] - [ENDPOINT] calculateArea_calculateRectangleArea_receive
[WARN] [default] - [ENDPOINT] calculateArea_calculateArea_invoke
[WARN] [default] - 
------------ Admin Console -------------------
[WARN] [default] - [ENDPOINT] /chorus/calculateArea/util/instances
[WARN] [default] - 
------------ Server started ------------------
[WARN] [default] - [SERVER] listening on port 3000

Note that Chorus.js expects that MongoDB will be listening on the standard port: 27017 and that you would have created a “chorus” database. You can use Robomongo to manage your MongoDB stores.

Now you can test everything is running properly by POSTing some values to the orchestration:

curl -H "Content-Type: application/json" -d '{ "input" : { "a" : "60" , "b" : "200" }}' http://localhost:3000/calculateArea/v1/receive/calculateRectangleArea 

If all goes well, you should see a record like that one in the chorus database. This is the context of the API orchestration.
robomongo-output

You can also check the orchestration instances at this location:

http://localhost:3000/chorus/calculateArea/util/instances

Chorus.js comes also with a Meteor-based admin console that provides a far better experience, but needs to be deployed as a separate Node.js application, running on a different port.

First you will need to install Meteor and meteorite:

$ curl https://install.meteor.com/ | sh
$ npm install -g meteorite

$ cd /path/to/the/admin/console

$ meteor create admin
$ cd admin 
$ rm *.*

Now copy the content of the admin folder generated by Chorus.js’ SDK to the meteor admin directory and start the admin console with:

$ sh start_chorus_admin.sh

The result should look like this:

drwxr-xr-x 5 root root 4096 Jun 21 03:35 .
drwxr-xr-x 5 root root 4096 Jun 21 03:33 ..
drwxr-xr-x 2 root root 4096 Jun 21 03:33 client
drwxr-xr-x 3 root root 4096 Jun 21 03:35 .meteor
-rw-r--r-- 1 root root 1287 Jun 21 03:35 model.js
drwxr-xr-x 2 root root 4096 Jun 21 03:33 server
-rw-r--r-- 1 root root   21 Jun 21 03:35 smart.json
-rw-r--r-- 1 root root   87 Jun 21 03:35 smart.lock
-rw-r--r-- 1 root root  557 Jun 21 03:35 start_chorus_admin.sh
root@gliiph:/home/chorus/calculateArea/admin# sh start_chorus_admin.sh 
accounts-ui: already using
autopublish: not in project

Stand back while Meteorite does its thing

Done installing smart packages

Ok, everything's ready. Here comes Meteor!

[[[[[ /home/chorus/temp/meteor2/calculateArea/admin/admin ]]]]]

=> Started proxy.
=> Started your app.   

=> App running at: http://localhost:3001/

If you open the console at http://localhost:3001 you should see:

meteor-console

You like what you see? let’s continue by installing the CORD authoring tool.

2. Install Chorus.js development tool

Chorus.js is based on Eclipse Xtext 2.6.1. We recommend that you install the full Eclipse Xtext distro.

Start Eclipse and chose the default workspace (or the one of your choice). In the help menu select “Install new software”:

install-plugin

In the “Available Software” dialog enter the chorus.js plugin address in the “work with” field, select all and click finish.

http://www.chorusjs.com/site.xml

install-plugin-dialog

Since the plugin is not signed (yet), Eclipse will ask you if you’d want to install it anyways. 

Once the plugin’s installation is complete you can create your first Chorus.js project. 

Right-click on the project explorer and select New -> Project and enter a project name.

new-project

Then, right click on the project and select New -> File and enter a filename. The first time you add a .cord file to a project, Eclipse will ask you if you want to add the Xtext nature to the project, just answer yes. 

xtext-nature

That’s it, you are ready to code your first cord!!  You can also download one of our samples.

Leave a Reply