Socket
Socket
Sign inDemoInstall

espressologic

Package Overview
Dependencies
2
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    espressologic

A rapid development node sdk for API's built with Espresso Logic services.


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Install size
168 kB
Created
Weekly downloads
 

Readme

Source

##Espresso Logic Espresso Logic is the fastest way to create REST APIs with your data. You can join data across multiple data sources, write declarative rules, and define granular security for an API that deploys in the time it takes to scan the schema. For more information about this SDK, please visit our doc center.

Installation

The SDK library is installed as we might expect, from a simple npm install command:

npm install espressologic

Getting Started

Connecting to an existing project is done via the espressologic.connect() method. Here we are connecting to a sample API which is available as a sandbox for exploring the basics:

var espressologic, api;
espressologic = require('espressologic');

//via a username and password
api = espressologic.connect('https://eval.espressologic.com/rest/livedemo/demo/v1', 'demo', 'Password1');

//or with an API key
api = espressologic.connect('https://eval.espressologic.com/rest/livedemo/demo/v1', 'readonly');

Espresso builds an API around the tables and relationships it finds in your database. Once connected, your project endpoints are accessible in an easy to use format:

var espressologic, api;
espressologic = require('espressologic');

//API endpoints follow a simple structure: {projectUrl}/{databasePrefix}:{tableName}
//a full endpoint might look like this "https://eval.espressologic.com/rest/livedemo/demo/v1/customer"
api = espressologic.connect('https://eval.espressologic.com/rest/livedemo/demo/v1', 'demo', 'Password1');

var customers;
customers = api.endpoint('customer');

customers.get().then(function (data) {
	console.log(data); //an array of objects from our customers table
});

The customers.get() method refers to the http request method, and PUT/POST/DELETE requests will look very similar (though, for these requests, we invite you to register for an account @ Espresso Logic).

var customers, newCustomer;
customers = api.endpoint('/customers');
alphaCustomer = {
    name: "Alpha",
    credit_limit: "1234"
};

//POST
customers.post(alphaCustomer, params).then(function (txSummary) {
	console.log(txSummary); //an array of objects updated
});

//GET
customers.get().then(function (data) {
	console.log(data); //an array which will now include customer: Alpha
	
	//objects returned include metadata specific to each record,
	//the most useful to us here is the endpoint href
    var alphaEndpoint = espressologic.endpoint(data[0]['@metadata'].href);
	
	//PUT
    	data[0].name = 'Alpha Updated';
    	alphaEndpoint.put(data[0]).then(function(txSummary) {
    	    console.log(txSummary);
	    });
	    
	//DELETE
    	alphaEndpoint.delete(data[0]).then(function(txSummary) {
    	    console.log(txSummary);
	    });
});

Keywords

FAQs

Last updated on 03 Nov 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc