Docs‎ > ‎Live API‎ > ‎Node SDK‎ > ‎

Espresso Node Demo

The Espresso Node Demo is a sample application demonstrating how the Espresso Logic SDK package interacts with rules and resources defined in Logic Designer. We can navigate customer purchase orders, edit their attributes, and add line items. Almost all the application interactions with the Logic Demo project API use a single resource hierarchy: the CustomerBusinessObject, a neatly packaged custom endpoint which queries and structures purchase orders, line items, and products belonging to a customer.

Getting Started

Deploying only takes 2 commands and a browser (http://localhost:3000), then you're up and running:
> npm install espressodemo
> npm start espressodemo

Nuts and Bolts: Express, AngularJS, & npm espressologic

Express will likely be familiar to many node developers as an http server, and of interest here for the purpose of EntroSpect is the routes/index.js file. In the express router we have examples of several requests, their parameters, and some helpful comments on what is happening at each stage of the SDK method.

AngularJS acts as a facade for the interesting stuff taking place within the express router, though to understand what might be happening during each request, the OrderDetailsCtrl.js contains the best slice of the client side behaviors.

The espressologic package is connected, by default, to a read only instance of the Logic Demo project, though we invite you to sign up for your own evaluation account and point the final line of node_modules/espressodemo/config.js to your own evaluation project API URL and username/password for the Espresso Demo project, it should always be "demo"/"Password1").

Note: after any modifications are made to module files will require a local serve restart.
> npm start espressodemo
Evaluation accounts update the "User name" value from your registration email to the project endpoints, so the updated config.js file should look similar to the sample code below:
module.exports = espressologic.connect('https://eval.espressologic.com/rest/AAAAA/demo/v1', 'demo', 'Password1');

Rules & Logic

When playing with our rather simple demo application, you may notice while adding or deleting line items, that the customer balance is changing, or that when updating a line item to refer to a different product, its "Line Total" updates automatically. Those changes are ultimately taking place within the API, and the demo merely refreshes the data. Any time Espresso identifies actions on a row, it checks the logic defined in the Rules section of Logic Designer for rules pertaining to that table or others related to it. As noted above, the Espresso Node Demo uses a custom resource for most interactions with the project API, but these changes would follow the same script when hitting any of the automatically generated endpoints, or triggered when one rule causes updates to other records.

For more about rules, visit our rules operation documentation, or visit the npm page for more getting started info.
Comments