Share
Embed
2012: ql.io and Node.js
June 2012 presentation on ql.io and working with the system inside Node.js applications.
Jonathan LeBlanc
May 30, 2012
Transcript
40 slides
-
ql.io and Node.js: Next Genera3on Open Source Web
Querying System Jonathan LeBlanc Developer Evangelist: X.commerce Email: [email protected] Twi;er: @jcleblanc Github: github.com/jcleblanc -
Overview of ql.io Language SpecificaFons Monkey Patching &
Enhancements IntegraFng Into Your Node ApplicaFons Tools and More Topics We’ll Be Covering -
Overview of ql.io Language SpecificaFons Monkey Patching &
Enhancements IntegraFng Into Your Node ApplicaFons Tools and More Topics We’ll Be Covering -
ql.io: Reducing Workload + Processing Reduced DocumentaFon
Reduced Code Length Reduced Result Syncing -
ql.io: Quering the Web Endpoint HTTP GET
h;p://ql.io/q?s=QUERY -
ql.io: Using the Standalone Server Node Host ql.io
Data (internal) Data (external) -
Overview of ql.io Language Specifica3ons Monkey Patching &
Enhancements IntegraFng Into Your Node ApplicaFons Tools and More Topics We’ll Be Covering -
Language: Defining a Data Source Include in .ql Table
Include in Request -
create table TABLE_NAME
on select get from "h;p://api.com/?val1={val1}" using defaults val1="VALUE", val2="VALUE”; Language: Create Table for Data Source -
create table github.issues
on select get from "h;ps://github.com/api/v2/json/ issues/list/{user}/{repository}/ {state}/" using defaults state="open"; Language: Sample Github Issues Table -
select * from TABLE_NAME
where val1="VALUE" and val2="VALUE" limit 10 offset 3; Language: Obtain Data From New Tables -
select * from github.issues
where user="jcleblanc" and repository="reddit-‐php-‐sdk"; Language: Sample Github Table Call { "comments": 0, "body": "h;p://www.phpdoc.org/", "Ftle": "Use standardized documentaFon", "updated_at": "2011/12/11 13:49:07 -‐0800", "html_url": "h;ps://github.com/jcleblanc/reddit-‐php-‐sdk/issues/3", "state": "open” } -
insert into bitly.shorten (longUrl)
values ('h;p://ql.io/docs'); Language: Insert Request "h;p://bit.ly/uZIvmY" -
select ItemID, ViewItemURLForNaturalSearch, LocaFon
from details where itemId in (select itemId from finditems where keywords='mini cooper'); Language: Nested Selects [ "330730216553", "h;p://www.ebay.com/itm/Clubman-‐Auto-‐Sunroof-‐Prem-‐…", "HunFngdon Valley, Pennsylvania" ], -
user = "jcleblanc"; slides = select * from slideshare
where user="{user}"; twi;er = select * from github.users where user="{user}"; return { "slides": "{slides}", "twi;er": "{twi;er}" } via route '/social' using method post; Language: Including Script Routes -
curl -‐-‐header "content-‐type: applicaFon/x-‐www-‐form-‐urlencoded" -‐d
"user=jcleblanc" h;p://localhost:3000/social Language: Using Script Routes -
Overview of ql.io Language SpecificaFons Monkey Patching &
Enhancements IntegraFng Into Your Node ApplicaFons Tools and More Topics We’ll Be Covering -
create table TABLE_NAME
on select get from "h;p://api.com/?val1={val1}" using defaults val1="VALUE" using patch "patch.js"; Patching: Including the Monkey Patch -
exports['validate param'] = funcFon(args, param, value) {
switch(param) { case 'duraFon' : return !isNaN(value -‐ 0) default: return true; } } Patching: Valida3ng Input Parameters -
exports['patch body'] = funcFon() { return
{ type: 'applicaFon/json', content: JSON.stringify({message : 'aok'}) }; } Patching: The Body Patch -
exports['patch response'] = funcFon(args){
var body = args.body; //modify response body return body; } Patching: The Response Patch -
Overview of ql.io Language SpecificaFons Monkey Patching &
Enhancements Integra3ng Into Your Node Applica3ons Tools and More Topics We’ll Be Covering -
var Engine = require('ql.io-‐engine'); var engine = new
Engine({ connecFon: 'close' }); Node.js: Including the Engine -
Overview of ql.io Language SpecificaFons Monkey Patching &
Enhancements IntegraFng Into Your Node ApplicaFons Tools and More Topics We’ll Be Covering -
Tools: API Masher Visualiza3on Engine: h;ps://github.com/jcleblanc/api-‐masher
Technology Backbone – ql.io – jQuery – Mustache Templates -
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’>{{Ftle}}</a></span></li>”; Tools: API Masher -
var query = “create table slideshare
on select get from ‘h;p://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 -
Thank You! h;p://slidesha.re/ql-‐io-‐node Jonathan LeBlanc Developer Evangelist:
X.commerce Email: [email protected] Twi;er: @jcleblanc Github: github.com/jcleblanc