Skip to content
Browse files

adding package.json and new README

  • Loading branch information...
1 parent 87f16d1 commit a1ca645076489c9fb943cb1fde65cf1162ddd9c4 @joshbirk committed
Showing with 74 additions and 0 deletions.
  1. 0 README
  2. +58 −0 README.md
  3. +16 −0 package.json
View
0 README
No changes.
View
58 README.md
@@ -0,0 +1,58 @@
+<H1>lazy-proxy</H1>
+lazy is meant to be a very simple proxy route for node.js, in particular to be used with express as middleware. The idea
+is to make it easy to add multiple outbound routes by adding "/abbreviation/json/and-then-my-path-here" or "/abbreviation/view/page/and-then-my-path-here" - where abbreviation could be say "fb" to mean "Facebook" and then "json" would return the raw JSON (for use with client side AJAX calls) and "view" would then also append server-side view to have the data rendered on to "page".
+
+So an express based route:
+
+```
+app.all('/:label/:mode/*',
+ ensureAuthenticated,
+ function(req, res) {
+ console.log(req.session);
+
+ //forcedotcom
+ if(req.session["forcedotcom"] && req.params.label == "fdc") {
+ var restOptions = {
+ useHTTPS : true,
+ host : req.session["forcedotcom"].instance_url.replace('https://',''),
+ headers: {
+ 'Authorization': 'OAuth '+req.session["forcedotcom"].access_token,
+ 'Accept':'application/jsonrequest',
+ 'Cache-Control':'no-cache,no-store,must-revalidate'
+ }
+ }
+
+ lazyproxy.send(restOptions,req,res);
+ }
+
+ //facebook
+ if(req.session["facebook"] && req.params.label == "fb") {
+ var restOptions = {
+ useHTTPS : true,
+ host : 'graph.facebook.com',
+ headers: {
+ 'Authorization': 'OAuth '+req.session["passport"]["user"].access_token,
+ 'Accept':'application/jsonrequest',
+ 'Cache-Control':'no-cache,no-store,must-revalidate'
+ }
+ }
+
+ lazyproxy.send(restOptions,req,res);
+ }
+
+ });
+ ```
+
+ Would allow an application to forward those routes to Force.com and Facebook. Where:
+
+ ```
+ /fdc/json/services/data/v22.0/query?q=SELECT%20ID%20FROM%20Account
+ ```
+
+ Would send the result of SOQL callout directly back as json,
+
+ ```
+/fdc/view/account/services/data/v22.0/sobjects/Account/{accountId}
+ ```
+
+Would call render("account",{accountdata}) instead.
View
16 package.json
@@ -0,0 +1,16 @@
+{
+ "name": "lazy-proxy",
+ "version": "0.0.1",
+ "description": "A simple method of adding an HTTP/HTTPS/REST proxy as middleware",
+ "author": "Joshua Birk <joshua.birk@salesforce.com>",
+ "repository": {
+ "type": "git",
+ "url": "http://github.com/joshbirk/lazy-proxy.git"
+ },
+ "main": "./lib/lazy-proxy",
+ "dependencies": {
+
+ },
+ "engines": { "node": ">= 0.4.0" },
+ "keywords": ["http","https","rest","proxy","lazy"]
+}

0 comments on commit a1ca645

Please sign in to comment.
Something went wrong with that request. Please try again.