2012: ql.io and Node.js

40
ql.io and Node.js: Next Generation Open Source Web Querying System Jonathan LeBlanc Developer Evangelist: X.commerce Email: [email protected] Twitter: @jcleblanc Github: github.com/jcleblanc

description

June 2012 presentation on ql.io and working with the system inside Node.js applications.

Transcript of 2012: ql.io and Node.js

Page 1: 2012: ql.io and Node.js

ql.io and Node.js: Next Generation Open Source Web Querying System

Jonathan LeBlancDeveloper Evangelist: X.commerce

Email: [email protected]: @jcleblanc

Github: github.com/jcleblanc

Page 2: 2012: ql.io and Node.js

Overview of ql.io

Language Specifications

Monkey Patching & Enhancements

Integrating Into Your Node Applications

Tools and More

Topics We’ll Be Covering

Page 3: 2012: ql.io and Node.js

Overview of ql.io

Language Specifications

Monkey Patching & Enhancements

Integrating Into Your Node Applications

Tools and More

Topics We’ll Be Covering

Page 4: 2012: ql.io and Node.js

ql.io: The Problem is API Overload

Page 5: 2012: ql.io and Node.js

ql.io: Developing for Mobile

Page 6: 2012: ql.io and Node.js

ql.io: Reducing Workload + Processing

Reduced Documentation

Reduced Code Length

Reduced Result Syncing

Page 7: 2012: ql.io and Node.js

ql.io: Increasing Performance (Requests)

Page 8: 2012: ql.io and Node.js

ql.io: Error Handling and Reporting

Page 9: 2012: ql.io and Node.js

ql.io: Open Standard Foundation

Page 10: 2012: ql.io and Node.js

ql.io: Using the System

Standalone ServerWeb Endpoint

Page 11: 2012: ql.io and Node.js

ql.io: Quering the Web Endpoint

HTTP GEThttp://ql.io/q?s=QUERY

Page 12: 2012: ql.io and Node.js

ql.io: Using the Standalone Server

Node Hostql.io

Data (internal)

Data (external)

Page 13: 2012: ql.io and Node.js

Overview of ql.io

Language Specifications

Monkey Patching & Enhancements

Integrating Into Your Node Applications

Tools and More

Topics We’ll Be Covering

Page 14: 2012: ql.io and Node.js

Language: Defining a Data Source

Include in .ql TableInclude in Request

Page 15: 2012: ql.io and Node.js

create table TABLE_NAME on select get from "http://api.com/?val1={val1}" using defaults val1="VALUE", val2="VALUE”;

Language: Create Table for Data Source

Page 16: 2012: ql.io and Node.js

create table github.issues on select get from "https://github.com/api/v2/json/ issues/list/{user}/{repository}/ {state}/" using defaults state="open";

Language: Sample Github Issues Table

Page 17: 2012: ql.io and Node.js

select * from TABLE_NAME where val1="VALUE" and val2="VALUE" limit 10 offset 3;

Language: Obtain Data From New Tables

Page 18: 2012: ql.io and Node.js

select * from github.issues where user="jcleblanc" and repository="reddit-php-sdk";

Language: Sample Github Table Call

{"comments": 0,"body": "http://www.phpdoc.org/","title": "Use standardized documentation","updated_at": "2011/12/11 13:49:07 -0800","html_url": "https://github.com/jcleblanc/reddit-php-sdk/issues/3","state": "open”}

Page 19: 2012: ql.io and Node.js

insert into bitly.shorten (longUrl) values ('http://ql.io/docs');

Language: Insert Request

"http://bit.ly/uZIvmY"

Page 20: 2012: ql.io and Node.js

select ItemID, ViewItemURLForNaturalSearch, Location from details where itemId in (select itemId from finditems where keywords='mini cooper');

Language: Nested Selects

["330730216553","http://www.ebay.com/itm/Clubman-Auto-Sunroof-Prem-…","Huntingdon Valley, Pennsylvania"],

Page 21: 2012: ql.io and Node.js

Test Console: http://ql.io/console

ql.io: The Test Console

Page 22: 2012: ql.io and Node.js

user = "jcleblanc";slides = select * from slideshare where user="{user}";twitter = select * from github.users where user="{user}"; return { "slides": "{slides}", "twitter": "{twitter}"} via route '/social' using method post;

Language: Including Script Routes

Page 23: 2012: ql.io and Node.js

curl --header "content-type: application/x-www-form-urlencoded" -d "user=jcleblanc" http://localhost:3000/social

Language: Using Script Routes

Page 24: 2012: ql.io and Node.js

Overview of ql.io

Language Specifications

Monkey Patching & Enhancements

Integrating Into Your Node Applications

Tools and More

Topics We’ll Be Covering

Page 25: 2012: ql.io and Node.js

create table TABLE_NAME on select get from "http://api.com/?val1={val1}" using defaults val1="VALUE" using patch "patch.js";

Patching: Including the Monkey Patch

Page 26: 2012: ql.io and Node.js

exports['validate param'] = function(args, param, value) { switch(param) { case 'duration' : return !isNaN(value - 0) default: return true; }}

Patching: Validating Input Parameters

Page 27: 2012: ql.io and Node.js

exports['patch body'] = function() { return { type: 'application/json', content: JSON.stringify({message : 'aok'}) };}

Patching: The Body Patch

Page 28: 2012: ql.io and Node.js

exports['patch response'] = function(args){ var body = args.body; //modify response body return body;}

Patching: The Response Patch

Page 29: 2012: ql.io and Node.js

Overview of ql.io

Language Specifications

Monkey Patching & Enhancements

Integrating Into Your Node Applications

Tools and More

Topics We’ll Be Covering

Page 30: 2012: ql.io and Node.js

npm install ql.io-engine

Node.js: Installing the Package

Page 31: 2012: ql.io and Node.js

var Engine = require('ql.io-engine');var engine = new Engine({ connection: 'close' });

Node.js: Including the Engine

Page 32: 2012: ql.io and Node.js

Node.js: Building the Script

Page 33: 2012: ql.io and Node.js

Overview of ql.io

Language Specifications

Monkey Patching & Enhancements

Integrating Into Your Node Applications

Tools and More

Topics We’ll Be Covering

Page 34: 2012: ql.io and Node.js

Tools: API Masher

Visualization Engine: https://github.com/jcleblanc/api-masher

Technology Backbone– ql.io– jQuery– Mustache Templates

Page 35: 2012: ql.io and Node.js

var format = “<li><a href=‘{{link}}’ target=‘_blank’> <img src=‘{{media:content.media:thumbnail.url}}’ width=‘{{media:content.media:thumbnail.width}}’ height=‘{{media:content.media:thumbnail.height}}’ /></a> <br /><span class=‘small’> <a href=‘{{link}}’ target=‘_blank’>{{title}}</a></span></li>”;

Tools: API Masher

Page 36: 2012: ql.io and Node.js

var query = “create table slideshare on select get from ‘http://www.slideshare.net/rss/user/{user}’ resultset ‘rss.channel’; select * from slideshare where user=‘jcleblanc’”;

var insertEl = “widgetContainer”;

parser.push(query, format, insertEl);parser.render();

Tools: API Masher

Page 37: 2012: ql.io and Node.js

Tools: API Masher Results

Showcase Website: http://jcleblanc.com

Page 38: 2012: ql.io and Node.js

Tools: External API Tables

Tables Source: https://github.com/jcleblanc/ql.io-tables

Page 39: 2012: ql.io and Node.js

ql.io: The Link

Page 40: 2012: ql.io and Node.js

Thank You!http://slidesha.re/ql-io-node

Jonathan LeBlancDeveloper Evangelist: X.commerce

Email: [email protected]: @jcleblanc

Github: github.com/jcleblanc