Added basic proxy example, fixed circular references in helpers/client
diff --git a/examples/api-proxy/app.js b/examples/api-proxy/app.js
new file mode 100644
index 0000000..608f17f
--- /dev/null
+++ b/examples/api-proxy/app.js
@@ -0,0 +1,22 @@
+var express = require('express'),
+ app = express(),
+ Usergrid = require('usergrid'),
+ async = require('async'),
+ chance = require('chance')
+
+Usergrid.init()
+
+app.get('/:collection/:uuidOrName?', function(req, res) {
+ Usergrid.GET(req.params.collection, req.params.uuidOrName, function(error, usergridResponse, entities) {
+ res.json(entities);
+ })
+})
+
+app.listen(process.env.port || 9000)
+
+/*
+
+1. Start the server using > node app.js
+2. Call the api at http://localhost:9000/cats/test
+
+*/
\ No newline at end of file
diff --git a/examples/api-proxy/config/usergrid.json b/examples/api-proxy/config/usergrid.json
new file mode 100644
index 0000000..5d13860
--- /dev/null
+++ b/examples/api-proxy/config/usergrid.json
@@ -0,0 +1,8 @@
+{
+ "appId": "sandbox",
+ "orgId": "brandon.apigee",
+ "authFallback": "NONE",
+ "baseUrl": "https://api.usergrid.com",
+ "clientId": "YXA6GXSAACS2EeOYd20aP4G6Lw",
+ "clientSecret": "YXA66BeEvgNpJBwc4PAbvZZGTVS_SSw"
+}
\ No newline at end of file
diff --git a/examples/api-proxy/package.json b/examples/api-proxy/package.json
new file mode 100644
index 0000000..53deec5
--- /dev/null
+++ b/examples/api-proxy/package.json
@@ -0,0 +1,19 @@
+{
+ "dependencies": {
+ "async": "latest",
+ "express": "latest",
+ "usergrid": "r3mus/usergrid-nodejs",
+ "chance": "^0.8.0"
+ },
+ "description": "A sample API proxy built with Express and Usergrid",
+ "keywords": [],
+ "license": "MIT",
+ "main": "app.js",
+ "name": "usergrid-example-api-proxy",
+ "private": false,
+ "scripts": {
+ "start": "node app.js",
+ "test": "mocha tests"
+ },
+ "version": "2.0.0-rc.1"
+}
\ No newline at end of file
diff --git a/helpers/client.js b/helpers/client.js
index e506b88..4d4d311 100644
--- a/helpers/client.js
+++ b/helpers/client.js
@@ -1,14 +1,13 @@
'use strict'
-var UsergridClient = require('../lib/client'),
- UsergridAuth = require('../lib/auth'),
- Usergrid = require('../usergrid'),
+var Usergrid = require('../usergrid'),
helpers = require('../helpers'),
_ = require('lodash')
module.exports = {
validate: function(args) {
+ var UsergridClient = require('../lib/client')
var client
if (args instanceof UsergridClient) {
client = args
@@ -22,6 +21,7 @@
return client
},
configureTempAuth: function(auth) {
+ var UsergridAuth = require('../lib/auth')
if (_.isString(auth) && auth !== UsergridAuth.NO_AUTH) {
return new UsergridAuth(auth)
} else if (!auth || auth === UsergridAuth.NO_AUTH) {