├── .gitignore ├── README.md ├── account ├── README.md ├── TODO.md ├── docs │ └── features.md ├── index.js └── package.json ├── admin ├── README.md ├── docs │ ├── features.md │ └── running-tests.md ├── index.js ├── package.json ├── public │ ├── admin │ │ ├── builder.html │ │ ├── css │ │ │ ├── bootstrap-responsive.css │ │ │ └── bootstrap.css │ │ ├── font.woff │ │ ├── jquery.js │ │ ├── js │ │ │ ├── html.js │ │ │ └── schema-explorer.js │ │ ├── resource-builder.js │ │ ├── resource-coder.js │ │ └── style.css │ └── img │ │ └── glyphicons-halflings.png ├── test │ └── basic-test.js └── view │ ├── controls │ ├── list.html │ └── list.js │ ├── docs.html │ ├── docs.js │ ├── hooks.html │ ├── hooks.js │ ├── index.html │ ├── layout.html │ ├── layout.js │ ├── mesh.html │ ├── mesh.js │ ├── method.html │ ├── method.js │ ├── replicator.js │ ├── resource.html │ ├── resource.js │ ├── resources.html │ ├── resources.js │ ├── schema.html │ └── schema.js ├── analytics ├── README.md ├── index.js ├── package.json └── template.js ├── api ├── README.md ├── index.js ├── package.json └── test │ └── tests.js ├── bitcoin ├── README.md ├── index.js ├── package.json └── test │ ├── test │ └── tests.js ├── calculator ├── README.md ├── index.js └── package.json ├── cli ├── README.md ├── index.js ├── lib │ └── controller.js └── package.json ├── config ├── README.md ├── index.js ├── package.json └── test │ ├── basic-test.js │ └── fixtures │ └── db │ └── config │ └── development.json ├── couchdb ├── README.md ├── index.js └── package.json ├── creature ├── README.md ├── index.js └── package.json ├── cron ├── README.md ├── index.js └── package.json ├── datasource ├── README.md ├── index.js └── package.json ├── datetime ├── README.md ├── index.js └── package.json ├── docs ├── README.md ├── index.js ├── package.json └── template.md ├── email ├── README.md ├── TODO.md ├── index.js ├── package.json ├── providers │ └── sendgrid.js ├── send.js └── templates │ ├── account-created.html │ └── password-reset.html ├── forms ├── README.md ├── index.js ├── package.json └── view │ └── form │ ├── all.html │ ├── all.js │ ├── create.html │ ├── create.js │ ├── destroy.html │ ├── destroy.js │ ├── find.html │ ├── find.js │ ├── get.html │ ├── get.js │ ├── inputs │ ├── array.js │ ├── boolean.html │ ├── boolean.js │ ├── enum.html │ ├── enum.js │ ├── index.html │ ├── index.js │ ├── key.html │ ├── key.js │ ├── object.js │ └── string │ │ ├── index.html │ │ └── index.js │ ├── layout.html │ ├── layout.js │ ├── method.html │ ├── method.js │ ├── update.html │ └── update.js ├── fs ├── README.md ├── index.js └── package.json ├── github ├── README.md ├── index.js └── package.json ├── hook ├── README.md ├── index.js ├── package.json └── test │ └── tests.js ├── html ├── README.md ├── index.js ├── package.json └── test │ └── test.js ├── http ├── README.md ├── favicon.png ├── index.js ├── lib │ └── connectr.js ├── package.json ├── public │ ├── index.html │ └── style.css └── uploads │ └── README.md ├── index.js ├── irc ├── README.md ├── index.js └── package.json ├── jugglingdb ├── index.js ├── lib │ └── crud.js └── vendor │ └── jugglingdb │ ├── .gitmodules │ ├── .npmignore │ ├── .travis.yml │ ├── Makefile │ ├── README.md │ ├── index.js │ ├── lib │ ├── abstract-class.js │ ├── adapters │ │ ├── cradle.js │ │ ├── fs.js │ │ ├── memory.js │ │ ├── mongodb.js │ │ ├── mongoose.js │ │ ├── mysql.js │ │ ├── neo4j.js │ │ ├── postgres.js │ │ ├── redis.js │ │ ├── redis2.js │ │ ├── riak.js │ │ └── sqlite3.js │ ├── hookable.js │ ├── jutil.js │ ├── list.js │ ├── nosqlite │ │ ├── README.md │ │ ├── data │ │ │ └── .gitkeep │ │ ├── lib │ │ │ └── nosqlite.js │ │ ├── package.json │ │ ├── src │ │ │ └── nosqlite.coffee │ │ ├── test │ │ │ ├── connection-test.coffee │ │ │ ├── database-test.coffee │ │ │ └── fixtures │ │ │ │ ├── .gitkeep │ │ │ │ └── test │ │ │ │ └── bob.json │ │ └── vendor │ │ │ └── rimraf │ │ │ ├── AUTHORS │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── package.json │ │ │ ├── rimraf.js │ │ │ └── test │ │ │ ├── run.sh │ │ │ ├── setup.sh │ │ │ ├── test-async.js │ │ │ ├── test-fiber.js │ │ │ └── test-sync.js │ ├── railway.js │ ├── schema.js │ ├── sql.js │ ├── utils.js │ └── validatable.js │ ├── package.json │ ├── support │ └── ci │ │ └── neo4j.sh │ ├── test.js │ └── test │ ├── common_test.js │ ├── hookable_test.coffee │ ├── migration_test.coffee │ ├── performance.coffee │ ├── spec_helper.js │ └── validations_test.coffee ├── logger ├── README.md └── index.js ├── markdown ├── README.md ├── index.js ├── package.json └── test │ └── test.js ├── memory ├── README.md ├── index.js └── package.json ├── mesh ├── README.md ├── example │ ├── client.js │ └── server.js ├── index.js ├── package.json └── test │ └── tests.js ├── node ├── README.md ├── index.js ├── package.json └── recipes │ ├── TODO │ ├── ls-test │ └── ubuntu-12.04 ├── npm ├── README.md ├── index.js ├── package.json └── test │ └── tests.js ├── oauth ├── README.md ├── index.js ├── package.json └── test │ └── tests.js ├── package.json ├── packager ├── README.md ├── index.js └── package.json ├── page ├── README.md ├── index.js └── package.json ├── persistence ├── README.md ├── index.js └── package.json ├── queue ├── README.md ├── example │ ├── basic.js │ └── repeat.js ├── index.js ├── package.json └── test │ └── tests.js ├── repl ├── README.md ├── index.js └── package.json ├── replication ├── README.md ├── index.js └── package.json ├── replicator ├── README.md ├── index.js └── package.json ├── socket ├── README.md ├── index.js ├── lib │ ├── engines │ │ ├── engineio.js │ │ ├── socketio.js │ │ └── ws.js │ └── sockets.js ├── package.json └── test │ └── tests.js ├── ssh ├── README.md ├── bin │ ├── big-help │ └── big-sh ├── index.js └── package.json ├── stdin ├── README.md ├── index.js └── package.json ├── stdout ├── README.md ├── TODO ├── index.js └── package.json ├── swig ├── README.md ├── index.js ├── package.json └── test │ └── test.js ├── system ├── README.md ├── index.js └── package.json ├── tag ├── README.md ├── index.js └── package.json ├── twitter ├── README.md ├── index.js └── package.json ├── validator ├── README.md ├── index.js ├── package.json ├── test │ └── tests.js └── vendor │ └── validator.js ├── video ├── README.md ├── index.js └── package.json ├── view ├── README.md ├── index.js ├── lib │ ├── View.js │ ├── layout.js │ ├── query.js │ └── render.js ├── middle.js ├── package.json └── test │ ├── middle-tests.js │ ├── test │ ├── tests.js │ ├── view1 │ └── index.html │ ├── view10 │ ├── index.html │ ├── index.js │ ├── layout.html │ └── layout.js │ ├── view11 │ ├── index.html │ ├── index.js │ ├── layout.html │ ├── layout.js │ ├── table.html │ └── table.js │ ├── view12 │ ├── index.html │ ├── index.js │ ├── layout.html │ └── layout.js │ ├── view13 │ ├── index.html │ ├── index.js │ ├── layout.html │ ├── layout.js │ ├── table.html │ └── table.js │ ├── view14 │ ├── index.html │ ├── index.js │ ├── layout.html │ ├── layout.js │ ├── table.html │ └── table.js │ ├── view15 │ ├── index.html │ ├── index.js │ └── test │ │ ├── table.html │ │ └── table.js │ ├── view16 │ ├── index.html │ ├── index.js │ ├── layout.html │ ├── layout.js │ └── test │ │ ├── layout.html │ │ ├── layout.js │ │ ├── table.html │ │ └── table.js │ ├── view17 │ ├── layout.html │ ├── layout.js │ ├── root.html │ └── root.js │ ├── view18 │ ├── index.html │ ├── index.js │ ├── layout.html │ ├── layout.js │ └── test │ │ ├── layout.html │ │ ├── layout.js │ │ ├── table.html │ │ └── table.js │ ├── view19 │ ├── index2.html │ ├── index2.js │ ├── layout.html │ ├── layout.js │ ├── table2.html │ ├── table2.js │ └── test2 │ │ ├── index.html │ │ ├── index.js │ │ ├── layout.html │ │ ├── layout.js │ │ ├── table.html │ │ └── table.js │ ├── view2 │ ├── index.html │ └── index.js │ ├── view3 │ ├── index.html │ ├── index.js │ └── layout.html │ ├── view4 │ ├── index.html │ ├── index.js │ └── layout.js │ ├── view5 │ ├── index.html │ ├── index.js │ ├── layout.html │ └── layout.js │ ├── view6 │ ├── index.html │ ├── index.js │ ├── layout.html │ └── layout.js │ ├── view7 │ ├── index.html │ ├── index.js │ ├── layout.html │ └── layout.js │ ├── view8 │ ├── index.html │ ├── index.js │ ├── layout.html │ └── layout.js │ └── view9 │ ├── index.html │ ├── index.js │ ├── layout.html │ └── layout.js └── virtualhost ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ -------------------------------------------------------------------------------- /account/TODO.md: -------------------------------------------------------------------------------- 1 | - Add one-way hashes for passwords -------------------------------------------------------------------------------- /account/docs/features.md: -------------------------------------------------------------------------------- 1 | ## Features 2 | 3 | - Signups 4 | - Confirmations 5 | - Password Resets -------------------------------------------------------------------------------- /account/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-account", 3 | "version": "0.4.2", 4 | "description": "for managing accounts", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /admin/README.md: -------------------------------------------------------------------------------- 1 | # admin 2 | 3 | 4 | a web based admin panel 5 | 6 | 7 | ## Features 8 | 9 | - Web administration interface for [resources](http://github.com/bigcompany/resources) 10 | - Forms 11 | - Suite of browser integration tests 12 | 13 | 14 | ## Running the tests 15 | 16 | - Install `wd` package from npm 17 | - Install [Selenium Stand-alone Server](http://docs.seleniumhq.org/download/) [Download](http://selenium.googlecode.com/files/selenium-server-standalone-2.33.0.jar) 18 | - Start Selenium server ( open the `.jar` file ) 19 | - `node test/basic-test.js` 20 | 21 | Note: The basic tests use the `firefox` browser, so you will need to have that installed. 22 | 23 | 24 | 25 | ## API 26 | 27 | #### [properties](#admin-properties) 28 | 29 | - [id](#admin-properties-id) 30 | 31 | 32 | #### [methods](#admin-methods) 33 | 34 | - [listen](#admin-methods-listen) (options, callback) 35 | 36 | - [start](#admin-methods-start) (options, callback) 37 | 38 | 39 | 40 | a web based admin panel 41 | 42 | - **id** 43 | 44 | - **type** : any 45 | 46 | 47 | 48 | 49 | 50 | ## methods 51 | 52 | 53 | 54 | ### admin.listen(options, callback) 55 | 56 | start a listening admin web server 57 | 58 | - **options** 59 | 60 | - **type** : object 61 | 62 | - **properties** 63 | 64 | - **port** 65 | 66 | - **type** : number 67 | 68 | - **default** : 8888 69 | 70 | - **description** : the port to listen on 71 | 72 | - **host** 73 | 74 | - **type** : string 75 | 76 | - **default** : 0.0.0.0 77 | 78 | - **description** : the host interface to listen on 79 | 80 | - **callback** 81 | 82 | - **type** : function 83 | 84 | 85 | 86 | ### admin.start(options, callback) 87 | 88 | start a listening admin web server 89 | 90 | - **options** 91 | 92 | - **type** : object 93 | 94 | - **properties** 95 | 96 | - **port** 97 | 98 | - **type** : number 99 | 100 | - **default** : 8888 101 | 102 | - **description** : the port to listen on 103 | 104 | - **host** 105 | 106 | - **type** : string 107 | 108 | - **default** : 0.0.0.0 109 | 110 | - **description** : the host interface to listen on 111 | 112 | - **callback** 113 | 114 | - **type** : function 115 | 116 | 117 | 118 | ## dependencies 119 | - [connect](http://npmjs.org/package/connect) v2.7.1 120 | - [highlight](http://npmjs.org/package/highlight) v0.2.3 121 | 122 | 123 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /admin/docs/features.md: -------------------------------------------------------------------------------- 1 | ## Features 2 | 3 | - Web administration interface for [resources](http://github.com/bigcompany/resources) 4 | - Forms 5 | - Suite of browser integration tests -------------------------------------------------------------------------------- /admin/docs/running-tests.md: -------------------------------------------------------------------------------- 1 | ## Running the tests 2 | 3 | - Install `wd` package from npm 4 | - Install [Selenium Stand-alone Server](http://docs.seleniumhq.org/download/) [Download](http://selenium.googlecode.com/files/selenium-server-standalone-2.33.0.jar) 5 | - Start Selenium server ( open the `.jar` file ) 6 | - `node test/basic-test.js` 7 | 8 | Note: The basic tests use the `firefox` browser, so you will need to have that installed. -------------------------------------------------------------------------------- /admin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-admin", 3 | "version": "0.4.2", 4 | "description": "a web based admin panel", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "connect": "2.7.1", 13 | "highlight": "0.2.3", 14 | "resource": "0.4.x" 15 | } 16 | } -------------------------------------------------------------------------------- /admin/public/admin/font.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcompany/resources/9cfcf61b01fb7af0a0d383348528a03226f24b2b/admin/public/admin/font.woff -------------------------------------------------------------------------------- /admin/public/admin/js/html.js: -------------------------------------------------------------------------------- 1 | /*! HTML5 Shiv vpre3.6 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 2 | Uncompressed source: https://github.com/aFarkas/html5shiv */ 3 | (function(a,b){function h(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function i(){var a=l.elements;return typeof a=="string"?a.split(" "):a}function j(a){var b={},c=a.createElement,f=a.createDocumentFragment,g=f();a.createElement=function(a){if(!l.shivMethods)return c(a);var f;return b[a]?f=b[a].cloneNode():e.test(a)?f=(b[a]=c(a)).cloneNode():f=c(a),f.canHaveChildren&&!d.test(a)?g.appendChild(f):f},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+i().join().replace(/\w+/g,function(a){return c(a),g.createElement(a),'c("'+a+'")'})+");return n}")(l,g)}function k(a){var b;return a.documentShived?a:(l.shivCSS&&!f&&(b=!!h(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),g||(b=!j(a)),b&&(a.documentShived=b),a)}var c=a.html5||{},d=/^<|^(?:button|form|map|select|textarea|object|iframe|option|optgroup)$/i,e=/^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i,f,g;(function(){var c=b.createElement("a");c.innerHTML="",f="hidden"in c,f&&typeof injectElementWithStyles=="function"&&injectElementWithStyles("#modernizr{}",function(b){b.hidden=!0,f=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle).display=="none"}),g=c.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var l={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:k};a.html5=l,k(b)})(this,document) -------------------------------------------------------------------------------- /admin/public/admin/js/schema-explorer.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcompany/resources/9cfcf61b01fb7af0a0d383348528a03226f24b2b/admin/public/admin/js/schema-explorer.js -------------------------------------------------------------------------------- /admin/public/admin/resource-coder.js: -------------------------------------------------------------------------------- 1 | var exports = {}; 2 | var coder = exports; 3 | // 4 | // Remark: Code comments show code that gets generated 5 | // 6 | exports.code = function (resource) { 7 | var str = ''; 8 | // 9 | // var Creature = resource.define('creature'); 10 | // 11 | str += 'var ' + resource.name + " = resource.define('" + resource.name + "');\n\n"; 12 | 13 | var schema = resource.schema.properties; 14 | Object.keys(schema).forEach(function(p){ 15 | var type = schema[p].type.split(''); 16 | type[0] = type[0].toUpperCase(); 17 | type = type.join(''); 18 | if (p !== 'id') { 19 | // 20 | // Creature.property('awesome', { 21 | // 22 | str += resource.name + '.property("' + p + '", {\n'; 23 | 24 | // 25 | // "type": "boolean" 26 | // 27 | str += ' "type": "' + type.toLowerCase() + '"\n'; 28 | 29 | Object.keys(schema[p]).forEach(function(o, i){ 30 | var comma = ","; 31 | if(i === Object.keys(schema[p]).length - 1) { // TODO: < 4 is a magic number, thats not right 32 | comma = ""; 33 | } 34 | if(o !== "type" && o !== "messages" && o !== 'conditions') { 35 | var value = schema[p][o]; 36 | if(Array.isArray(value)) { 37 | value = "['" + value.join("', '") + "']"; 38 | } else if (type === "Number"){ 39 | // do nothing 40 | } else if (type === "Boolean"){ 41 | // do nothing 42 | } else { 43 | value = '"' + value + '"'; 44 | } 45 | // 46 | // "default": false, 47 | // 48 | str += ' "' + o + '": ' + value + '' + comma + '\n'; 49 | } 50 | }); 51 | // 52 | // }); 53 | // 54 | str += '});\n\n' 55 | 56 | } 57 | }); 58 | 59 | // 60 | // For every method on the resource 61 | // 62 | for (var m in resource.methods) { 63 | if(typeof resource.methods[m] === "function") { 64 | // 65 | // Creature.method('feed', fn, {}); 66 | // 67 | str += resource.name + '.method("' + m + '", ' + resource.methods[m].toString() + ', ' + JSON.stringify(resource.methods[m].schema, true, 2) +');\n'; 68 | } 69 | } 70 | return str; 71 | }; 72 | -------------------------------------------------------------------------------- /admin/public/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcompany/resources/9cfcf61b01fb7af0a0d383348528a03226f24b2b/admin/public/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /admin/view/controls/list.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /admin/view/controls/list.js: -------------------------------------------------------------------------------- 1 | module['exports'] = function (options, callback) { 2 | 3 | var items = options.items, 4 | $ = this.$, 5 | desc = ''; 6 | 7 | $('.items').children().remove(); 8 | Object.keys(items).sort().forEach(function(item){ 9 | if(typeof items[item].schema !== 'undefined') { 10 | desc = items[item].schema.description; 11 | } 12 | $('.items').append('
  • ' + item + ' ' + desc +'
  • '); 13 | }); 14 | 15 | return $.html(); 16 | 17 | } -------------------------------------------------------------------------------- /admin/view/docs.html: -------------------------------------------------------------------------------- 1 |
    2 |

    docs

    3 | 4 |
    5 |
    6 |
    7 |

    Contents

    8 |
    9 | 13 |
    14 |
    15 |
    16 |
    17 | 18 |
    19 | -------------------------------------------------------------------------------- /admin/view/docs.js: -------------------------------------------------------------------------------- 1 | module['exports'] = function (options, callback) { 2 | 3 | var resources = options.resources, 4 | $ = this.$; 5 | return callback(null, $.html()); 6 | 7 | } -------------------------------------------------------------------------------- /admin/view/hooks.html: -------------------------------------------------------------------------------- 1 |
    2 |

    Hooks

    3 | 4 |
    5 |
    6 |
    7 |
    8 | What are hooks? 9 |
    10 |
    11 |
    12 |
    13 | 14 |
    15 |
    16 |
    17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
    ifthen
    28 |
    29 | 30 | 31 | 32 | 33 | 34 | 35 |
    ifthenedit
    36 | 37 |
    38 |
    39 | 40 |
    41 | -------------------------------------------------------------------------------- /admin/view/hooks.js: -------------------------------------------------------------------------------- 1 | var layout = require('./layout'), 2 | resource = require('resource'); 3 | 4 | module['exports'] = function (options, callback) { 5 | 6 | var $ = this.$; 7 | 8 | var methods = {}, 9 | events = []; 10 | for (var r in resource.resources) { 11 | for (var m in resource.resources[r].methods) { 12 | events.push(r + '::' + m); 13 | } 14 | } 15 | 16 | events.sort(); 17 | 18 | events.forEach(function(ev){ 19 | var option = ''; 20 | $('#if').append(option); 21 | $('#then').append(option); 22 | }); 23 | 24 | resource.resources.hook.all(function(err, results){ 25 | results.sort(function(a,b){ 26 | return a.if > b.if; 27 | }); 28 | results.forEach(function(item){ 29 | $('.hooks').append('' + eventLink(item.if) + '' + eventLink(item.then) + '' + '' + '') 30 | }); 31 | callback(null, $.html()); 32 | }); 33 | 34 | } 35 | 36 | function eventLink (event) { 37 | var arr = event.split('::'), 38 | _resource = arr[0], 39 | _method = arr[1]; 40 | return '' + event + '' 41 | } 42 | -------------------------------------------------------------------------------- /admin/view/index.html: -------------------------------------------------------------------------------- 1 |
    2 | 3 |
    4 |
    5 |
    6 |

    Help / FAQ

    7 |
    8 | TODO: What exactly is big and what am I looking at? 9 |
    10 |
    11 |
    12 |
    13 |

    Admin

    14 | 15 |

    Resources

    16 |

    Hooks

    17 |

    Mesh

    18 | 19 |
    20 | 21 | -------------------------------------------------------------------------------- /admin/view/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Admin 4 | 5 | 9 | 10 | 11 | 46 |
    47 |
    48 | 49 | -------------------------------------------------------------------------------- /admin/view/layout.js: -------------------------------------------------------------------------------- 1 | module['exports'] = function (options, callback) { 2 | var $ = this.$; 3 | // 4 | // Set active class on navbar button 5 | // 6 | //$('.navbar').remove(); 7 | return callback(null, $.html()); 8 | } -------------------------------------------------------------------------------- /admin/view/mesh.html: -------------------------------------------------------------------------------- 1 |
    2 | 3 |

    Mesh

    4 | 5 |
    6 |
    7 |
    8 |
    9 | What is the big mesh? 10 |
    11 |
    12 |
    13 |
    14 | 15 |

    servers

    16 |
    17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
    idstatuslast seen
    1disconnectedyesterday
    34 |
    35 | 36 |
    37 |

    clients

    38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
    idstatuslast seen
    1disconnectedyesterday
    55 |
    56 | 57 |
    -------------------------------------------------------------------------------- /admin/view/mesh.js: -------------------------------------------------------------------------------- 1 | var layout = require('./layout'), 2 | resource = require('resource'); 3 | 4 | module['exports'] = function (options, callback) { 5 | var $ = this.$; 6 | resource.node.all(function(err, results){ 7 | $('.nodes').html(''); 8 | results.forEach(function(record){ 9 | var output; 10 | if(record.role === "server") { 11 | output = ('' 12 | + '' + record.id + '' 13 | + '' + record.status + '' 14 | + '' + record.lastSeen + '' 15 | + ''); 16 | $('.servers .nodes').append(output); 17 | } else if(record.status === "connected") { 18 | output = ('' 19 | + '' + record.id + '' 20 | + '' + record.status + '' 21 | + '' + record.lastSeen + '' 22 | + ''); 23 | 24 | $('.clients .nodes').append(output); 25 | } 26 | }); 27 | if($('.clients .nodes').length === 1) { 28 | $('.clients').remove() 29 | } 30 | callback(null, $.html()) 31 | }); 32 | } -------------------------------------------------------------------------------- /admin/view/method.html: -------------------------------------------------------------------------------- 1 |
    2 | back to resource 3 |

    resource - method

    4 | 5 |
    6 |
    7 |
    8 |
    9 |
    10 | 11 |
    12 |
    13 |
    14 |
    resource schema
    15 |
    16 |
    17 |
    18 | 19 |
    20 |
    21 |
    22 |

    code

    23 |
    24 |
    25 |
    26 |
    27 | 28 |
    29 | -------------------------------------------------------------------------------- /admin/view/method.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | hl = require("highlight").Highlight; 3 | 4 | module['exports'] = function (options, callback) { 5 | 6 | var r = resource.resources[options.resource], 7 | method = r.methods[options.method], 8 | $ = this.$, 9 | view = this; 10 | 11 | if (typeof method === "undefined") { 12 | $('.codeHolder').remove(); 13 | $('.schemaHolder').remove(); 14 | $('h1').html('invalid method: ' + options.method); 15 | return callback(null, $.html()); 16 | } 17 | 18 | $('.back').attr('href', '/admin/resources/' + options.resource); 19 | $('.schema').html(view.parent.schema.present({ schema: method.schema })); 20 | 21 | $('h1').html(options.resource + ' ' + method.name); 22 | $('.description').html(method.schema.description); 23 | // $('.methods').html(view.parent.layout.controls.list.present({ items: r.methods, root: '/admin/resources/foo/' })); 24 | $('.method').html(hl(method.unwrapped.toString())); 25 | 26 | var form = resource.forms.generate(options, function(err, str) { 27 | if(options.data) { 28 | $('.schemaHolder').remove(); 29 | $('.codeHolder').remove(); 30 | } 31 | $('.form').html(str); 32 | callback(null, $.html()) 33 | }); 34 | 35 | 36 | } -------------------------------------------------------------------------------- /admin/view/replicator.js: -------------------------------------------------------------------------------- 1 | var layout = require('./layout'), 2 | resource = require('resource'); 3 | 4 | module['exports'] = function (options, callback) { 5 | var $ = this.$; 6 | resource.replication.all(function(err, results){ 7 | if(results.length === 0) { 8 | $('.history').remove(); 9 | } 10 | results.forEach(function(result){ 11 | var str = ''; 12 | str +=''; 13 | str +=''; 14 | str += '
    '+result.time+'
    http://'+result.source+'/'+result.repo+'http://'+result.target+'/'+result.repo+'
    '; 15 | $('.replications').append(str); 16 | }); 17 | callback(null, $.html()); 18 | }); 19 | } -------------------------------------------------------------------------------- /admin/view/resource.html: -------------------------------------------------------------------------------- 1 |
    2 | back to resources 3 |

    resource name

    4 | 5 |
    6 | 7 |
    8 |
    9 |
    10 | the description goes here 11 |
    12 |
    13 |
    14 | 15 |
    16 |
    17 |
    18 |
    19 |
    20 |
    21 |
    22 |
    23 |
    24 | 25 |

    methods

    26 |
    27 |
    28 | 29 | 30 | 31 | 32 | 33 |
    methoddescription
    34 |
    35 |
    36 | 37 |
    38 |

    dependencies

    39 |
    40 |
    41 | 42 | 43 | 44 | 45 | 46 |
    packageversion
    47 |
    48 |
    49 |
    50 | 51 |
    52 |

    schema

    53 |
    resource schema
    54 |
    55 | 56 | 70 | 71 |
    72 | 73 | 74 |
    75 | -------------------------------------------------------------------------------- /admin/view/resource.js: -------------------------------------------------------------------------------- 1 | var layout = require('./layout'), 2 | resource = require('resource'); 3 | 4 | module['exports'] = function (options, callback) { 5 | 6 | var $ = this.$, 7 | view = this; 8 | 9 | var _resource = resource.resources[options.resource], 10 | methods; 11 | 12 | if(typeof _resource === 'undefined') { 13 | $('.name').html(options.resource + ' is not a valid resource!'); 14 | $('.resource').remove(); 15 | return callback(null, $.html()); 16 | } 17 | 18 | methods = resource.resources[options.resource].methods; 19 | $('.name').html(_resource.name); 20 | $('.description').html(_resource.schema.description); 21 | 22 | if (methods) { 23 | var _methods = Object.keys(methods).sort(); 24 | _methods.forEach(function(method){ 25 | $('.methods').append('' + _resource.name + '.' + method + '' + (methods[method].schema.description || " ") + '') 26 | }); 27 | } 28 | 29 | if(typeof _resource.dependencies !== "undefined" && Object.keys(_resource.dependencies).length > 0) { 30 | for(var dep in _resource.dependencies) { 31 | $('.dependencies').append('' + dep + '' + _resource.dependencies[dep] + ''); 32 | } 33 | } else { 34 | $('.deps').remove(); 35 | } 36 | 37 | if (Object.keys(_resource.schema.properties).length === 0) { 38 | $('.schema').remove(); 39 | } else { 40 | $('.properties').html(view.parent.schema.present({ schema: _resource.schema })); 41 | } 42 | 43 | var ds = _resource.config.datasource || 'none'; 44 | if(ds !== 'none') { 45 | ds = 'This resource is currently persisting it\'s data to the ' + ds +' datasource'; 46 | $('.datasource').html(ds); 47 | } else { 48 | $('.datasources').remove(); 49 | } 50 | 51 | //$('.schema').html(resource.docs.schemaToHTML(options.resource.schema)); 52 | callback(null, $.html()); 53 | 54 | } -------------------------------------------------------------------------------- /admin/view/resources.html: -------------------------------------------------------------------------------- 1 |
    2 |

    Resources

    3 | 4 |
    5 |
    6 |
    7 |
    8 | What are resources? 9 |
    10 |
    11 |
    12 |
    13 | 14 |
    15 |
    16 | 17 | 18 | 19 | 20 | 21 |
    namedescription
    22 |
    23 |
    24 |
    25 | -------------------------------------------------------------------------------- /admin/view/resources.js: -------------------------------------------------------------------------------- 1 | var layout = require('./layout'), 2 | resource = require('resource'); 3 | 4 | module['exports'] = function (options, callback) { 5 | 6 | var resources = resource.resources, 7 | $ = this.$; 8 | 9 | var keys = Object.keys(resource.resources).sort(); 10 | 11 | keys.forEach(function(r){ 12 | var _resource = resource.resources[r]; 13 | $('.resources').append('' + _resource.name + '' + _resource.schema.description + '') 14 | }); 15 | 16 | return callback(null, $.html()); 17 | 18 | } -------------------------------------------------------------------------------- /admin/view/schema.html: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |
    4 |
    -------------------------------------------------------------------------------- /admin/view/schema.js: -------------------------------------------------------------------------------- 1 | var layout = require('./layout'); 2 | 3 | module['exports'] = function (options) { 4 | 5 | options = options || {}; 6 | 7 | var $ = this.$.load(this.template), 8 | schema = options.schema || {}; 9 | 10 | //$('.description').html(schema.description); 11 | 12 | function render (props, level) { 13 | var str = ''; 14 | if(typeof props !== "object") { 15 | return props; 16 | } 17 | level++; 18 | if(level === 5) { 19 | level = 4; 20 | } 21 | str += ''; 22 | Object.keys(props).forEach(function(prop){ 23 | if(typeof props[prop] === "object") { 24 | str += (''); 25 | } else { 26 | var val = props[prop]; 27 | if(typeof props[prop] === 'undefined' || props[prop].length === 0 || props[prop] === null) { 28 | val = " "; 29 | } 30 | str += (''); 31 | } 32 | }); 33 | str += "
    ' + prop + '' + render(props[prop], level) + '
    ' + prop + '' + val + '
    " 34 | return str; 35 | } 36 | 37 | if(typeof schema.properties === 'object') { 38 | $('.props').append(render(schema.properties, 1)); 39 | } 40 | 41 | return $.html(); 42 | 43 | } -------------------------------------------------------------------------------- /analytics/README.md: -------------------------------------------------------------------------------- 1 | # analytics 2 | 3 | 4 | real-time analytics by google 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#analytics-properties) 11 | 12 | - [id](#analytics-properties-id) 13 | 14 | 15 | #### [methods](#analytics-methods) 16 | 17 | - [inject](#analytics-methods-inject) (accountID) 18 | 19 | 20 | 21 | real-time analytics by google 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### analytics.inject(accountID) 36 | 37 | returns templatizaed google adsense javascript embed based on account id 38 | 39 | - **accountID** 40 | 41 | - **type** : string 42 | 43 | - **required** : true 44 | 45 | - **default** : UA-XXXXX-Y 46 | 47 | 48 | 49 | 50 | 51 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /analytics/index.js: -------------------------------------------------------------------------------- 1 | var resource = require("resource"), 2 | analytics = resource.define("analytics"), 3 | fs = require('fs'); 4 | 5 | analytics.schema.description = "real-time analytics by google"; 6 | 7 | var inject = function (gid, callback) { 8 | var template = fs.readFileSync(__dirname + '/template.js').toString(); 9 | template = template.replace('{{GID}}', gid); 10 | if (callback) { 11 | return callback(null, template); 12 | } else { 13 | return template; 14 | } 15 | } 16 | 17 | analytics.method('inject', inject, { 18 | "description": "returns templatizaed google adsense javascript embed based on account id", 19 | "properties": { 20 | "accountID" : { 21 | "type": "string", 22 | "required": true, 23 | "default": "UA-XXXXX-Y" 24 | } 25 | } 26 | }); 27 | 28 | exports.analytics = analytics; 29 | -------------------------------------------------------------------------------- /analytics/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-analytics", 3 | "version": "0.4.2", 4 | "description": "real-time analytics by google", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /analytics/template.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /api/README.md: -------------------------------------------------------------------------------- 1 | # api 2 | 3 | 4 | provides a web API for interacting with resources 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#api-properties) 11 | 12 | - [id](#api-properties-id) 13 | 14 | - [version](#api-properties-version) 15 | 16 | 17 | #### [methods](#api-methods) 18 | 19 | 20 | 21 | 22 | 23 | ## properties 24 | provides a web API for interacting with resources 25 | 26 | - **id** 27 | 28 | - **type** : any 29 | 30 | - **version** 31 | 32 | - **description** : the semantic version of the API 33 | 34 | - **type** : string 35 | 36 | - **default** : v0.0.1 37 | 38 | 39 | 40 | 41 | 42 | ## methods 43 | 44 | 45 | 46 | 47 | 48 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-api", 3 | "version": "0.4.2", 4 | "description": "provides a web API for interacting with resources", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /bitcoin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-bitcoin", 3 | "version": "0.4.2", 4 | "description": "for managing bitcoins", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "bitcoin": "1.7.0", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /bitcoin/test/test: -------------------------------------------------------------------------------- 1 | cd "$(dirname "$0")" 2 | rm -rf ../../resources/ && node tests.js 3 | -------------------------------------------------------------------------------- /calculator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-calculator", 3 | "version": "0.4.2", 4 | "description": "a basic calculator", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /cli/README.md: -------------------------------------------------------------------------------- 1 | # cli 2 | 3 | 4 | provides a command line interface 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#cli-properties) 11 | 12 | - [id](#cli-properties-id) 13 | 14 | 15 | #### [methods](#cli-methods) 16 | 17 | - [start](#cli-methods-start) () 18 | 19 | - [createRouter](#cli-methods-createRouter) () 20 | 21 | 22 | 23 | provides a command line interface 24 | 25 | - **id** 26 | 27 | - **type** : any 28 | 29 | 30 | 31 | 32 | 33 | ## methods 34 | 35 | 36 | 37 | ### cli.start() 38 | 39 | starts the big command line interface 40 | 41 | 42 | 43 | ### cli.createRouter() 44 | 45 | 46 | 47 | 48 | 49 | ## dependencies 50 | - [prompt-lite](http://npmjs.org/package/prompt-lite) v0.1.x 51 | - [optimist](http://npmjs.org/package/optimist) v0.3.5 52 | - [colors](http://npmjs.org/package/colors) 53 | 54 | 55 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-cli", 3 | "version": "0.4.2", 4 | "description": "provides a command line interface", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "prompt-lite": "0.1.x", 13 | "optimist": "0.3.5", 14 | "colors": "*", 15 | "resource": "0.4.x" 16 | } 17 | } -------------------------------------------------------------------------------- /config/README.md: -------------------------------------------------------------------------------- 1 | # config 2 | 3 | 4 | configuration management for resources 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#config-properties) 11 | 12 | - [id](#config-properties-id) 13 | 14 | 15 | #### [methods](#config-methods) 16 | 17 | - [start](#config-methods-start) (id, callback) 18 | 19 | - [attach](#config-methods-attach) (options, callback) 20 | 21 | 22 | 23 | configuration management for resources 24 | 25 | - **id** 26 | 27 | - **type** : any 28 | 29 | 30 | 31 | 32 | 33 | ## methods 34 | 35 | 36 | 37 | ### config.start(id, callback) 38 | 39 | load configuration options 40 | 41 | - **id** 42 | 43 | - **type** : any 44 | 45 | - **callback** 46 | 47 | - **type** : function 48 | 49 | 50 | 51 | ### config.attach(options, callback) 52 | 53 | Attach configuration options to the config resource 54 | 55 | - **options** 56 | 57 | - **type** : object 58 | 59 | - **callback** 60 | 61 | - **type** : function 62 | 63 | 64 | 65 | 66 | 67 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | config = resource.define('config'); 3 | 4 | var _persist = config.persist, 5 | engine; 6 | 7 | config.schema.description = "configuration management for resources"; 8 | 9 | config.property('data', { type: 'object' }); 10 | 11 | config.persist = function (opts) { 12 | if (typeof opts === 'string') { 13 | engine = opts; 14 | } 15 | else if (opts.type) { 16 | engine = opts.type; 17 | } 18 | return _persist(opts); 19 | }; 20 | 21 | config.persist('fs'); 22 | 23 | config.method('start', start, { 24 | "description": "load configuration options", 25 | "properties": { 26 | "id": { 27 | "type": "any" 28 | }, 29 | "callback": { 30 | "type": "function" 31 | } 32 | } 33 | }); 34 | function start(id, callback) { 35 | if (!callback && typeof id === 'function') { 36 | callback = id; 37 | id = resource.env; 38 | } 39 | config.get(id, function (err, conf) { 40 | if (err) { 41 | return callback(err); 42 | } 43 | config.attach(conf, callback); 44 | }); 45 | } 46 | 47 | config.method('attach', attach); 48 | 49 | function attach(conf, callback) { 50 | Object.keys(conf.data).forEach(function (k) { 51 | // 52 | // Attach config.data properties to config resource scope 53 | // 54 | config[k] = conf.data[k]; 55 | // 56 | // If an object value is detected, check to see if the key is a resource exists with that property name, 57 | // If so, assign that value to resource.config.value 58 | // 59 | if (typeof conf.data[k] === 'object') { 60 | if (typeof resource.resources[k] === 'object') { 61 | for (var v in conf.data[k]) { 62 | resource.resources[k].config = resource.resources[k].config || {}; 63 | resource.resources[k].config[v] = conf.data[k][v]; 64 | } 65 | } 66 | } 67 | }); 68 | callback(null, conf); 69 | } 70 | 71 | exports.config = config; -------------------------------------------------------------------------------- /config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-config", 3 | "version": "0.4.2", 4 | "description": "configuration management for resources", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /config/test/basic-test.js: -------------------------------------------------------------------------------- 1 | var tap = require("tap"), 2 | resource = require('resource'); 3 | 4 | tap.test('use and start the config resource', function (t) { 5 | resource.use('config', { datasource : { type: 'fs', path: __dirname + "/fixtures/db/" }}); 6 | resource.use('creature'); 7 | resource.config.start(function(err, res){ 8 | t.error(err, 'config started'); 9 | t.end(); 10 | }) 11 | }); 12 | 13 | tap.test('check that configuration values were attached to resource.config', function (t) { 14 | t.equal(resource.config.foo, 'bar', 'foo property was attached'); 15 | t.type(resource.config.creature, Object, 'creature config was attached'); 16 | t.equal(resource.config.creature.style, 'scary', 'foo property was attached'); 17 | t.end(); 18 | }); 19 | 20 | tap.test('check that indivdual resource configuration values were attached to their specific resources', function (t) { 21 | t.equal(resource.creature.config.style, 'scary', 'style property was attached'); 22 | t.end(); 23 | }); -------------------------------------------------------------------------------- /config/test/fixtures/db/config/development.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "development", 3 | "data": { 4 | "foo": "bar", 5 | "creature": { 6 | "style": "scary" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /couchdb/README.md: -------------------------------------------------------------------------------- 1 | # couchdb 2 | 3 | 4 | adds couchdb persistence 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#couchdb-properties) 11 | 12 | - [id](#couchdb-properties-id) 13 | 14 | 15 | #### [methods](#couchdb-methods) 16 | 17 | - [start](#couchdb-methods-start) () 18 | 19 | 20 | 21 | adds couchdb persistence 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### couchdb.start() 36 | 37 | 38 | 39 | 40 | 41 | ## dependencies 42 | - [cradle](http://npmjs.org/package/cradle) v0.6.4 43 | 44 | 45 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /couchdb/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | couchdb = resource.define('couchdb'); 3 | 4 | couchdb.schema.description = "adds couchdb persistence"; 5 | 6 | couchdb.method('init', function (cb) { 7 | cb(null, true); 8 | }); 9 | 10 | couchdb.dependencies = { 11 | "cradle": "0.6.4" 12 | }; 13 | 14 | exports.couchdb = couchdb; 15 | -------------------------------------------------------------------------------- /couchdb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-couchdb", 3 | "version": "0.4.2", 4 | "description": "adds couchdb persistence", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "cradle": "0.6.4", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /creature/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | creature = resource.define('creature'); 3 | 4 | creature.schema.description = "example resource for creatures like dragons, unicorns, and ponies"; 5 | 6 | creature.persist('memory'); 7 | 8 | creature.property('type', { type: "string", enum: ['dragon', 'unicorn', 'pony'], default: "dragon"}); 9 | creature.property('life', { type: "number", default: 10 }); 10 | creature.property('isAwesome', { type: "boolean", default: true }); 11 | 12 | 13 | function poke (callback) { 14 | if (callback) { 15 | return callback(null, 'poked!'); 16 | } 17 | return 'poked!'; 18 | } 19 | function talk (text, callback) { 20 | var result = { 21 | text: text, 22 | status: 200 23 | } 24 | if (callback) { 25 | return callback(null, result); 26 | } 27 | return result; 28 | } 29 | function fire (options, callback) { 30 | var result = { 31 | status: "fired", 32 | direction: options.direction, 33 | power: options.power 34 | }; 35 | if(callback) { 36 | return callback(null, result); 37 | } 38 | return result; 39 | } 40 | 41 | creature.method('poke', poke); 42 | 43 | creature.method('fire', fire, { 44 | "description": "fires a lazer at a certain power and direction", 45 | "properties": { 46 | "options": { 47 | "type": "object", 48 | "properties": { 49 | "power": { 50 | "type": "number", 51 | "default": 1, 52 | "required": true 53 | }, 54 | "direction": { 55 | "type": "string", 56 | "enum": ["up", "down", "left", "right"], 57 | "required": true, 58 | "default": "up" 59 | } 60 | }, 61 | "callback": { 62 | "type": "function", 63 | "required": false 64 | } 65 | } 66 | }}); 67 | 68 | creature.method('talk', talk, { 69 | "description": "echos back a string", 70 | "properties": { 71 | "text": { 72 | "type": "string", 73 | "default": "hello!", 74 | "required": true 75 | } 76 | } 77 | }); 78 | 79 | exports.creature = creature; 80 | -------------------------------------------------------------------------------- /creature/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-creature", 3 | "version": "0.4.2", 4 | "description": "example resource for creatures like dragons, unicorns, and ponies", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /cron/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | cron = resource.define('cron'); 3 | 4 | cron.schema.description = "for managing cron jobs"; 5 | 6 | cron.persist('memory'); 7 | 8 | cron.property("pattern", { 9 | "type":"string", 10 | "default": "*/5 * * * * *", 11 | "description": "the pattern of the cron job" 12 | }); 13 | 14 | cron.property("event", { 15 | "type": "string", 16 | "default": "logger::log", 17 | "description": "the event to be emitted each time the cron runs" 18 | }); 19 | 20 | cron.property("with", { 21 | "type": "object", 22 | "description": "metadata to execute the cron with" 23 | }); 24 | 25 | function run (_cron) { 26 | resource.emit(_cron.event, _cron.with); 27 | }; 28 | 29 | cron.method('run', run, { 30 | "description": "runs / starts a cron job" 31 | }); 32 | 33 | cron.after('create', function(result){ 34 | var cronJob = require('cron').CronJob; 35 | new cronJob(result.pattern, function() { 36 | cron.run(result); 37 | }, null, true); 38 | }); 39 | 40 | function start () { 41 | // 42 | // Load all previously saved crons, 43 | // and start running them 44 | // 45 | cron.all(function(err, results){ 46 | results.forEach(function(result){ 47 | var cronJob = require('cron').CronJob; 48 | new cronJob(result.pattern, function() { 49 | cron.run(result); 50 | }, null, true); 51 | }); 52 | }); 53 | }; 54 | 55 | cron.method('start', start, { 56 | "description": "starts the cron resource ( which will run all cron jobs )" 57 | }); 58 | 59 | cron.dependencies = { 60 | "cron": "1.0.1" 61 | }; 62 | 63 | exports.cron = cron; -------------------------------------------------------------------------------- /cron/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-cron", 3 | "version": "0.4.2", 4 | "description": "for managing cron jobs", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "cron": "1.0.1", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /datasource/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-datasource", 3 | "version": "0.4.2", 4 | "description": "perists resources to data storage engines", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /datetime/README.md: -------------------------------------------------------------------------------- 1 | # datetime 2 | 3 | 4 | date and time helper 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#datetime-properties) 11 | 12 | - [id](#datetime-properties-id) 13 | 14 | 15 | #### [methods](#datetime-methods) 16 | 17 | - [format](#datetime-methods-format) (date, mask) 18 | 19 | 20 | 21 | date and time helper 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### datetime.format(date, mask) 36 | 37 | formats a date by mask 38 | 39 | - **date** 40 | 41 | - **type** : object 42 | 43 | - **required** : true 44 | 45 | - **mask** 46 | 47 | - **type** : string 48 | 49 | - **default** : mm dd, yyyy 50 | 51 | - **required** : true 52 | 53 | 54 | 55 | ## dependencies 56 | - [dateformat](http://npmjs.org/package/dateformat) 57 | 58 | 59 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /datetime/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | datetime = resource.define('datetime'); 3 | 4 | datetime.schema.description = "date and time helper"; 5 | 6 | function format (date, mask) { 7 | var dateFormat = require('dateformat'); 8 | return dateFormat(date, mask); 9 | } 10 | 11 | datetime.method('format', format, { 12 | "description": "formats a date by mask", 13 | "properties": { 14 | "date": { 15 | "type": "object", 16 | "required": true 17 | }, 18 | "mask": { 19 | "type": "string", 20 | "default": "mm dd, yyyy", 21 | "required": true 22 | } 23 | } 24 | }); 25 | 26 | datetime.dependencies = { 27 | "dateformat": "*" 28 | }; 29 | 30 | exports.datetime = datetime; -------------------------------------------------------------------------------- /datetime/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-datetime", 3 | "version": "0.4.2", 4 | "description": "date and time helper", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "dateformat": "*", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # docs 2 | 3 | 4 | for generating documentation 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#docs-properties) 11 | 12 | - [id](#docs-properties-id) 13 | 14 | 15 | #### [methods](#docs-methods) 16 | 17 | - [generate](#docs-methods-generate) (resource, template) 18 | 19 | - [build](#docs-methods-build) () 20 | 21 | 22 | 23 | for generating documentation 24 | 25 | - **id** 26 | 27 | - **type** : any 28 | 29 | 30 | 31 | 32 | 33 | ## methods 34 | 35 | 36 | 37 | ### docs.generate(resource, template) 38 | 39 | generates markdown documentation for a single resource 40 | 41 | - **resource** 42 | 43 | - **description** : the resource to generate documentation for 44 | 45 | - **type** : any 46 | 47 | - **template** 48 | 49 | - **type** : string 50 | 51 | - **default** : /Users/macbookpro/dev/big/resources/docs/template.md 52 | 53 | 54 | 55 | ### docs.build() 56 | 57 | builds README.md files for all resources 58 | 59 | 60 | 61 | 62 | 63 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-docs", 3 | "version": "0.4.2", 4 | "description": "for generating documentation", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /docs/template.md: -------------------------------------------------------------------------------- 1 | # {{name}} 2 | 3 | {{desc}} 4 | 5 | {{parts}} 6 | 7 | {{toc}} 8 | 9 | {{properties}} 10 | 11 | {{methods}} 12 | 13 | {{dependencies}} 14 | 15 | {{footer}} -------------------------------------------------------------------------------- /email/README.md: -------------------------------------------------------------------------------- 1 | # email 2 | 3 | 4 | for sending emails 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#email-properties) 11 | 12 | - [id](#email-properties-id) 13 | 14 | - [to](#email-properties-to) 15 | 16 | - [from](#email-properties-from) 17 | 18 | - [subject](#email-properties-subject) 19 | 20 | - [cc](#email-properties-cc) 21 | 22 | - [bcc](#email-properties-bcc) 23 | 24 | - [body](#email-properties-body) 25 | 26 | 27 | #### [methods](#email-methods) 28 | 29 | - [send](#email-methods-send) (options, callback) 30 | 31 | 32 | 33 | 34 | 35 | ## properties 36 | for sending emails 37 | 38 | - **id** 39 | 40 | - **type** : any 41 | 42 | - **to** 43 | 44 | - **type** : string 45 | 46 | - **description** : where the email will be sent to 47 | 48 | - **from** 49 | 50 | - **type** : string 51 | 52 | - **description** : where the email will be sent from 53 | 54 | - **subject** 55 | 56 | - **type** : string 57 | 58 | - **description** : the subject of the email 59 | 60 | - **cc** 61 | 62 | - **type** : string 63 | 64 | - **description** : where to send carbon copies 65 | 66 | - **bcc** 67 | 68 | - **type** : string 69 | 70 | - **description** : where to send blind carbon copies 71 | 72 | - **body** 73 | 74 | - **type** : string 75 | 76 | - **description** : the content of the email 77 | 78 | 79 | 80 | 81 | 82 | ## methods 83 | 84 | 85 | 86 | ### email.send(options, callback) 87 | 88 | sends an email 89 | 90 | - **options** 91 | 92 | - **type** : object 93 | 94 | - **properties** 95 | 96 | - **id** 97 | 98 | - **type** : any 99 | 100 | - **to** 101 | 102 | - **type** : string 103 | 104 | - **description** : where the email will be sent to 105 | 106 | - **from** 107 | 108 | - **type** : string 109 | 110 | - **description** : where the email will be sent from 111 | 112 | - **subject** 113 | 114 | - **type** : string 115 | 116 | - **description** : the subject of the email 117 | 118 | - **cc** 119 | 120 | - **type** : string 121 | 122 | - **description** : where to send carbon copies 123 | 124 | - **bcc** 125 | 126 | - **type** : string 127 | 128 | - **description** : where to send blind carbon copies 129 | 130 | - **body** 131 | 132 | - **type** : string 133 | 134 | - **description** : the content of the email 135 | 136 | - **callback** 137 | 138 | - **type** : function 139 | 140 | 141 | 142 | 143 | 144 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /email/TODO.md: -------------------------------------------------------------------------------- 1 | - add sendgrid module 2 | - add template support -------------------------------------------------------------------------------- /email/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | email = resource.define('email'); 3 | 4 | email.schema.description = "for sending emails" 5 | 6 | email.method('send', require('./send'), { 7 | "description": "sends an email", 8 | "properties": { 9 | "options": { 10 | "type": "object", 11 | "properties": email.schema.properties 12 | }, 13 | "callback": { 14 | "type": "function" 15 | } 16 | } 17 | }); 18 | 19 | email.property('to', { 20 | "type": "string", 21 | "description": "where the email will be sent to" 22 | }); 23 | 24 | email.property('from', { 25 | "type": "string", 26 | "description": "where the email will be sent from" 27 | }); 28 | 29 | email.property('subject', { 30 | "type": "string", 31 | "description": "the subject of the email" 32 | }); 33 | 34 | email.property('cc', { 35 | "type": "string", 36 | "description": "where to send carbon copies" 37 | }); 38 | 39 | email.property('bcc', { 40 | "type": "string", 41 | "description": "where to send blind carbon copies" 42 | }); 43 | 44 | email.property('body', { 45 | "type": "string", 46 | "description": "the content of the email" 47 | }); 48 | 49 | exports.email = email; -------------------------------------------------------------------------------- /email/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-email", 3 | "version": "0.4.2", 4 | "description": "for sending emails", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /email/providers/sendgrid.js: -------------------------------------------------------------------------------- 1 | // 2 | // TODO: sendgrid.js - simple wrapper to sendgrid api or sendgrind npm module 3 | // 4 | var sendgrid = exports; 5 | 6 | sendgrid.send = function (options, callback) { 7 | console.log('sending email through sendgrid provider'); 8 | callback(null, true) 9 | }; -------------------------------------------------------------------------------- /email/send.js: -------------------------------------------------------------------------------- 1 | // 2 | // send.js - exports a single send method for sending an email 3 | // 4 | module['exports'] = function (options, callback) { 5 | console.log('send email stub', arguments); 6 | // 7 | // TODO: If new email providers are required, make providers pluggable 8 | // 9 | var sendgrid = require('./providers/sendgrid'); 10 | sendgrid.send(options, callback); 11 | } -------------------------------------------------------------------------------- /email/templates/account-created.html: -------------------------------------------------------------------------------- 1 |

    A new account has been created

    -------------------------------------------------------------------------------- /email/templates/password-reset.html: -------------------------------------------------------------------------------- 1 |

    A password reset was requested for this account

    -------------------------------------------------------------------------------- /forms/README.md: -------------------------------------------------------------------------------- 1 | # forms 2 | 3 | 4 | for generating HTML forms 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#forms-properties) 11 | 12 | - [id](#forms-properties-id) 13 | 14 | 15 | #### [methods](#forms-methods) 16 | 17 | - [generate](#forms-methods-generate) (options) 18 | 19 | 20 | 21 | for generating HTML forms 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### forms.generate(options) 36 | 37 | generates a new form based on a resource schema 38 | 39 | - **options** 40 | 41 | - **properties** 42 | 43 | - **resource** 44 | 45 | - **type** : string 46 | 47 | - **required** : true 48 | 49 | - **method** 50 | 51 | - **type** : string 52 | 53 | - **required** : true 54 | 55 | - **data** 56 | 57 | - **type** : object 58 | 59 | - **required** : false 60 | 61 | - **callback** 62 | 63 | - type : *function* 64 | 65 | 66 | 67 | 68 | 69 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /forms/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | forms = resource.define('forms'); 3 | 4 | resource.use('view'); 5 | resource.use('html'); 6 | 7 | forms.schema.description = "for generating HTML forms"; 8 | 9 | forms.method("generate", generate, { 10 | "description": "generates a new form based on a resource schema", 11 | "properties": { 12 | "options": { 13 | "properties": { 14 | "resource": { 15 | "type": "string", 16 | "required": true 17 | }, 18 | "method": { 19 | "type": "string", 20 | "required": true 21 | }, 22 | "data": { 23 | "type": "object", 24 | "required": false 25 | } 26 | }, 27 | "callback": { 28 | "type": "function" 29 | } 30 | } 31 | } 32 | }); 33 | 34 | function generate (options, callback) { 35 | resource.view.create({ path: __dirname + '/view', input: "html"}, function (err, view) { 36 | var str = '', form; 37 | form = view.form[options.method] || view.form['method']; 38 | form.present(options, function(err, res){ 39 | if(err) { 40 | throw err; 41 | } 42 | return callback(err, res); 43 | }); 44 | }); 45 | }; 46 | 47 | exports.forms = forms; -------------------------------------------------------------------------------- /forms/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-forms", 3 | "version": "0.4.2", 4 | "description": "for generating HTML forms", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /forms/view/form/all.html: -------------------------------------------------------------------------------- 1 |
    2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
    idupdatedestroy
    1updatedestroy
    18 | -------------------------------------------------------------------------------- /forms/view/form/all.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function(options, callback) { 4 | 5 | var r = resource.resources[options.resource], 6 | data = options.data; 7 | 8 | if(typeof r === "undefined") { 9 | return callback(new Error('No resource specified')); 10 | } 11 | var $ = this.$, 12 | output = '', 13 | entity = options.resource; 14 | 15 | r.all(function(err, data){ 16 | 17 | if (err) { 18 | $('table').remove(); 19 | $('.message').html(JSON.stringify(err, true, 2)); 20 | $('.message').addClass('error'); 21 | return callback(null, $.html()); 22 | } 23 | 24 | if(data.length > 0) { 25 | $('.message').remove(); 26 | 27 | data.forEach(function(record){ 28 | 29 | var label = record.title || record.name || record.id; 30 | 31 | var leading; 32 | if (options.id) { 33 | leading = '../'; 34 | } 35 | else { 36 | leading = './'; 37 | } 38 | 39 | output += ('' 40 | + '' + label + '' 41 | + '' + 'update' + '' 42 | + '' + 'destroy' + '' 43 | + ''); 44 | }); 45 | $('h1').html(entity); 46 | $('.records').html(output); 47 | $('.schema').html(JSON.stringify(r.schema.properties, true, 2)); 48 | $('.create').html('Create new ' + entity); 49 | $('.create').attr('href', '/' + entity + '/new'); 50 | 51 | if(data.length === 0) { 52 | $('table').remove(); 53 | } 54 | } else { 55 | $('table').remove(); 56 | $('.message').html('no records found'); 57 | } 58 | 59 | output = $.html(); 60 | return callback(null, output); 61 | 62 | }); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /forms/view/form/create.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /forms/view/form/create.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | options = options || {}; 6 | var r = resource.resources[options.resource]; 7 | 8 | var $ = this.$, 9 | self = this, 10 | output = '', 11 | entity = options.resource || 'unknown'; 12 | 13 | if (options.data) { 14 | r.create(options.data, function(err, result){ 15 | if (err) { 16 | showForm(options.data, err.errors); 17 | } else { 18 | $('.message').html('Created!'); 19 | $('form').remove(); 20 | self.parent.get.present({ unscoped: true, resource: options.resource, id: result.id }, function(err, re){ 21 | return callback(null, re); 22 | }); 23 | } 24 | }); 25 | } else { 26 | showForm(); 27 | } 28 | 29 | function showForm (data, errors) { 30 | 31 | $('h1').html(entity + ' - create'); 32 | $('.back').html('back to ' + entity); 33 | $('.back').attr('href', '/' + entity); 34 | $('legend').html(r.methods.create.schema.description); 35 | $('input[type="submit"]').attr('value', 'Create'); 36 | 37 | cont = function(err, result) { 38 | if (result) { 39 | output += result; 40 | } 41 | if(arr.length === 0) { 42 | $('.inputs').html(output); 43 | return callback(null, $.html()) 44 | } 45 | var property = arr.pop(); 46 | var input = {}; 47 | for(var p in r.schema.properties[property]) { 48 | input[p] = r.schema.properties[property][p]; 49 | } 50 | input.name = property; 51 | for(var e in errors) { 52 | if (errors[e].property === input.name) { 53 | input.error = errors[e]; 54 | } 55 | } 56 | input.value = input.default || ''; 57 | if(data && typeof data[property] !== "undefined") { 58 | input.value = data[property]; 59 | } 60 | 61 | options.control = input; 62 | self.parent.inputs.index.present(options, cont); 63 | }; 64 | 65 | var arr = Object.keys(r.schema.properties); 66 | arr.reverse(); 67 | cont(); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /forms/view/form/destroy.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /forms/view/form/destroy.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var r = resource.resources[options.resource], 6 | $ = this.$, 7 | output = '', 8 | record = options.data; 9 | 10 | // 11 | // Todo: perform check if record exists 12 | // 13 | if(options.action === "post") { 14 | r.destroy(options.id, function(err, result){ 15 | $('.message').html('Destroyed!'); 16 | $('form').remove(); 17 | output = $.html(); 18 | return callback(null, output); 19 | }); 20 | } else { 21 | if (typeof record === "object") { 22 | Object.keys(record).forEach(function(key){ 23 | var html = "
    "; 24 | output += html; 25 | }); 26 | } else if (typeof options.id !== 'undefined') { 27 | $('.confirm').html('Destroy ' + options.id + '?'); 28 | } 29 | //$('h1').html('Could not find ' + record); 30 | output = $.html(); 31 | return callback(null, output); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /forms/view/form/find.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
    id
    1UpdateDestroy
    29 | -------------------------------------------------------------------------------- /forms/view/form/find.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | 4 | module['exports'] = function(options, callback) { 5 | 6 | var r = resource.resources[options.resource]; 7 | 8 | if(typeof r === "undefined") { 9 | return callback(new Error('No resource specified')); 10 | } 11 | 12 | var $ = this.$, 13 | self = this, 14 | output = '', 15 | entity = options.resource || 'unknown'; 16 | 17 | if (options.data) { 18 | // 19 | // Remove all blank values 20 | // 21 | var query = {}; 22 | Object.keys(options.data).forEach(function(prop){ 23 | if(typeof options.data[prop] !== 'undefined' && options.data[prop].length > 0) { 24 | query[prop] = options.data[prop]; 25 | } 26 | }); 27 | 28 | r.find(query, function(err, results){ 29 | if(results.length > 0) { 30 | $('.message').remove(); 31 | $('form').remove(); 32 | $('table th').html(entity); 33 | results.forEach(function(record){ 34 | output += ('' 35 | + '' + record.id + '' 36 | + '' + 'Update' + '' 37 | + '' + 'Destroy' + '' 38 | + ''); 39 | }); 40 | $('.records').html(output); 41 | } else { 42 | $('table').remove(); 43 | $('.message').html('no records found'); 44 | } 45 | output = $.html(); 46 | return callback(null, output); 47 | }); 48 | } else { 49 | $('table').remove(); 50 | var _props = r.methods.find.schema.properties.options.properties; 51 | 52 | 53 | $('.back').html('back to ' + entity); 54 | $('.back').attr('href', '/' + entity); 55 | 56 | cont = function(err, result) { 57 | if (result) { 58 | output += result; 59 | } 60 | if(arr.length === 0) { 61 | $('.inputs').html(output); 62 | return callback(null, $.html()) 63 | } 64 | var property = arr.pop(); 65 | var input = _props[property]; 66 | input.name = property; 67 | input.value = ''; 68 | options.control = input; 69 | self.parent.inputs.index.present(options, cont); 70 | 71 | }; 72 | var arr = Object.keys(_props); 73 | arr.reverse(); 74 | cont(); 75 | 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /forms/view/form/get.html: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |
    4 | Resource Form 5 |
    6 | 7 |
    8 |
    9 |
    10 | 11 |
    12 |

    13 |
    14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
      
    propname
    29 | -------------------------------------------------------------------------------- /forms/view/form/inputs/array.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | 4 | A single level of an array can have three distinct states: 5 | 6 | 7 | an array of non-object values 8 | an array of object values 9 | an array of mixed object and non-object values 10 | 11 | This is how the Array.js Presenter deals with them 12 | 13 | */ 14 | 15 | 16 | // an array of non-object values 17 | // print out a list control with all values 18 | // sort, shift, pop, unshift, etc 19 | // bonus: stats / tallies graphs 20 | 21 | // an array of object values 22 | // for each object, create a sub control ..^ 23 | // clone 24 | // delete 25 | // edit 26 | // for each Array.isArray, create a sub control ..^ 27 | 28 | // an array of mixed object and non-object values 29 | // for each object, create a sub control ..^ 30 | // clone 31 | // delete 32 | // edit 33 | // for each object, create a sub control ..^ 34 | -------------------------------------------------------------------------------- /forms/view/form/inputs/boolean.html: -------------------------------------------------------------------------------- 1 |
    2 | 3 |
    4 | 5 | 6 |
    7 |
    -------------------------------------------------------------------------------- /forms/view/form/inputs/boolean.js: -------------------------------------------------------------------------------- 1 | // 2 | // boolean.js - input fields for boolean types 3 | // 4 | 5 | module['exports'] = function (options, callback) { 6 | // 7 | // Todo: This load statement should be moved to Viewful 8 | // 9 | var input = options.control; 10 | var $ = this.$.load(this.template); 11 | if(typeof input.error !== 'undefined') { 12 | $('.control-group').addClass('error'); 13 | $('.help-inline').html(input.error.message); 14 | } 15 | var label = $('.control-label'); 16 | label.attr('for', input.name); 17 | label.html(input.name); 18 | 19 | var checkbox = $('input[type=checkbox]'); 20 | 21 | checkbox.attr('name', input.name); 22 | 23 | if(input.value.toString() === "true") { 24 | checkbox.attr('checked', 'CHECKED'); 25 | } 26 | else { 27 | checkbox.removeAttr('checked'); 28 | } 29 | 30 | return callback(null, $.html()); 31 | }; 32 | -------------------------------------------------------------------------------- /forms/view/form/inputs/enum.html: -------------------------------------------------------------------------------- 1 |
    2 | 3 |
    4 | 7 | 8 |
    9 |
    -------------------------------------------------------------------------------- /forms/view/form/inputs/enum.js: -------------------------------------------------------------------------------- 1 | // 2 | // enum.js - input fields for String types, bound by enum constraint 3 | // 4 | 5 | module['exports'] = function (options, callback) { 6 | 7 | // 8 | // Todo: This load statement should be moved to Viewful 9 | // 10 | var $ = this.$.load(this.template), 11 | input = options.control; 12 | 13 | if(input.error) { 14 | $('.control-group').addClass('error'); 15 | $('.help-inline').html(input.error.message); 16 | } 17 | 18 | $('.control-label').attr('for', input.name); 19 | $('.control-label').html(input.name); 20 | $('select').attr('id', input.name); 21 | $('select').attr('name', input.name); 22 | $('select').attr('placeholder', input.description || ''); 23 | $('select option').html('Please select ' + input.name + '...'); 24 | 25 | var _options = input.enum; 26 | _options.forEach(function(option){ 27 | var selected = ""; 28 | if(option === input.value) { 29 | selected = ' SELECTED '; 30 | } 31 | $('select').append(''); // Bad string concat! 32 | }); 33 | 34 | return callback(null, $.html()); 35 | }; 36 | -------------------------------------------------------------------------------- /forms/view/form/inputs/index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcompany/resources/9cfcf61b01fb7af0a0d383348528a03226f24b2b/forms/view/form/inputs/index.html -------------------------------------------------------------------------------- /forms/view/form/inputs/index.js: -------------------------------------------------------------------------------- 1 | module['exports'] = function (options, callback) { 2 | 3 | var output = "", _control, v, 4 | self = this, 5 | control = options.control; 6 | // 7 | // determine the type of control to render 8 | // 9 | _control = "string"; // forcing everything to string input as default for now 10 | 11 | if (control.private === true) { 12 | // do not render 13 | return callback(null, ''); 14 | } 15 | 16 | if(control.type === "boolean") { 17 | _control = "boolean"; 18 | } 19 | 20 | if(Array.isArray(control.enum)){ 21 | _control = "enum"; 22 | } 23 | 24 | if (typeof control.key !== 'undefined') { 25 | _control = "key"; 26 | } 27 | 28 | // 29 | // determine if there is a View available for that type of control 30 | // 31 | if(typeof self.parent.parent.inputs[_control] === 'undefined') { 32 | throw new Error('invalid control ' + _control); 33 | } 34 | 35 | // 36 | // If there is an index.js available, use that as the presenter, 37 | // if not, use the control itself 38 | // 39 | v = self.parent.parent.inputs[_control].index || self.parent.parent.inputs[_control]; 40 | 41 | // Present the View template 42 | v.present(options, callback); 43 | } 44 | -------------------------------------------------------------------------------- /forms/view/form/inputs/key.html: -------------------------------------------------------------------------------- 1 |
    2 | 3 |
    4 | 7 |
    8 |
    -------------------------------------------------------------------------------- /forms/view/form/inputs/key.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | // 4 | // key.js - input fields key lookups 5 | // 6 | module['exports'] = function (input, options, callback) { 7 | 8 | var $ = this.$.load(this.template); 9 | 10 | $('.control-label').attr('for', input.name); 11 | $('.control-label').html(input.name); 12 | $('select').attr('id', input.name); 13 | $('select').attr('name', input.name); 14 | $('select').attr('placeholder', input.description || ''); 15 | 16 | resource[input.key].all(function(err, results){ 17 | results.forEach(function(option){ 18 | var selected = ""; 19 | if(option.id === input.value) { 20 | selected = ' SELECTED '; 21 | } 22 | $('select').append(''); // Bad string concat! 23 | }); 24 | callback(null, $.html()); 25 | }); 26 | 27 | }; 28 | -------------------------------------------------------------------------------- /forms/view/form/inputs/object.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcompany/resources/9cfcf61b01fb7af0a0d383348528a03226f24b2b/forms/view/form/inputs/object.js -------------------------------------------------------------------------------- /forms/view/form/inputs/string/index.html: -------------------------------------------------------------------------------- 1 |
    2 | 3 |
    4 | 9 | 10 | 11 |
    12 |
    13 | -------------------------------------------------------------------------------- /forms/view/form/inputs/string/index.js: -------------------------------------------------------------------------------- 1 | // 2 | // string.js - input fields for String types 3 | // 4 | module['exports'] = function (options, callback) { 5 | 6 | // 7 | // Todo: This load statement should be moved to Viewful 8 | // 9 | var input = options.control; 10 | var $ = this.$.load(this.template); 11 | if(typeof input.error !== 'undefined') { 12 | $('.control-group').addClass('error'); 13 | $('.help-inline').html(input.error.message); 14 | } 15 | 16 | $('.control-label').attr('for', input.name); 17 | $('.control-label').html(input.name); 18 | $('input').attr('id', input.name); 19 | $('input').attr('name', input.name); 20 | $('input').attr('value', input.value.toString()); 21 | $('input').attr('placeholder', input.description || ''); 22 | 23 | if(input.format === "password") { 24 | $('input').attr('type', "password"); 25 | } 26 | 27 | if(input.format === "email") { 28 | // Bad string concat! 29 | $('.add-on').html(''); 30 | } 31 | 32 | return callback(null, $.html()); 33 | }; 34 | -------------------------------------------------------------------------------- /forms/view/form/layout.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcompany/resources/9cfcf61b01fb7af0a0d383348528a03226f24b2b/forms/view/form/layout.html -------------------------------------------------------------------------------- /forms/view/form/layout.js: -------------------------------------------------------------------------------- 1 | module['exports'] = function (data, callback) { 2 | callback(null, '
    '); 3 | } -------------------------------------------------------------------------------- /forms/view/form/method.html: -------------------------------------------------------------------------------- 1 |
    2 |
    3 |
    4 | 5 | -------------------------------------------------------------------------------- /forms/view/form/update.html: -------------------------------------------------------------------------------- 1 | 2 |
    3 |
    4 |
    5 | Resource form 6 |
    7 |
    8 |
    9 |
    10 | 11 |
    12 |
    -------------------------------------------------------------------------------- /fs/README.md: -------------------------------------------------------------------------------- 1 | # fs 2 | 3 | 4 | adds file-system persistence 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#fs-properties) 11 | 12 | - [id](#fs-properties-id) 13 | 14 | 15 | #### [methods](#fs-methods) 16 | 17 | - [start](#fs-methods-start) () 18 | 19 | 20 | 21 | adds file-system persistence 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### fs.start() 36 | 37 | 38 | 39 | 40 | 41 | ## dependencies 42 | - [mkdirp](http://npmjs.org/package/mkdirp) 43 | 44 | 45 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /fs/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | fs = resource.define('fs'); 3 | 4 | fs.schema.description = "adds file-system persistence"; 5 | 6 | fs.method('init', function (cb) { 7 | cb(null, true); 8 | }); 9 | 10 | fs.dependencies = { 11 | "mkdirp": "*", 12 | "async": "*" 13 | }; 14 | 15 | exports.fs = fs; -------------------------------------------------------------------------------- /fs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-fs", 3 | "version": "0.4.2", 4 | "description": "adds file-system persistence", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "mkdirp": "*", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /github/README.md: -------------------------------------------------------------------------------- 1 | # github 2 | 3 | 4 | for interacting with the Github.com API 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#github-properties) 11 | 12 | - [id](#github-properties-id) 13 | 14 | 15 | #### [methods](#github-methods) 16 | 17 | - [activity](#github-methods-activity) (options, callback) 18 | 19 | 20 | 21 | for interacting with the Github.com API 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### github.activity(options, callback) 36 | 37 | gets event activity for a user or organization 38 | 39 | - **options** 40 | 41 | - **properties** 42 | 43 | - **user** 44 | 45 | - **type** : string 46 | 47 | - **org** 48 | 49 | - **type** : string 50 | 51 | - **callback** 52 | 53 | - **type** : function 54 | 55 | 56 | 57 | ## dependencies 58 | - [github](http://npmjs.org/package/github) 59 | 60 | 61 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /github/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | github = resource.define('github'); 3 | 4 | github.schema.description = "for interacting with the Github.com API"; 5 | 6 | github.method('activity', activity, { 7 | "description": "gets event activity for a user or organization", 8 | "properties": { 9 | "options": { 10 | "properties": { 11 | "user": { 12 | "type": "string" 13 | }, 14 | "org": { 15 | "type": "string" 16 | } 17 | } 18 | }, 19 | "callback": { 20 | "type": "function" 21 | } 22 | } 23 | }); 24 | 25 | function activity (options, callback) { 26 | var gh = require('github'); 27 | var conn = new gh({ 28 | version: "3.0.0" 29 | }); 30 | 31 | if (options.authenticate) { 32 | conn.authenticate(options.authenticate); 33 | } 34 | 35 | // 36 | // TODO: better conditional logic for determing user / org / project / etc 37 | // 38 | if (typeof options.user !== "undefined" && options.user.length > 0) { 39 | return conn.events.getFromUser({ 40 | user: options.user 41 | }, function(err, result) { 42 | callback(err, result); 43 | }); 44 | } 45 | 46 | if (typeof options.org !== "undefined" && options.org.length > 0) { 47 | return conn.events.getFromOrg({ 48 | org: options.org 49 | }, function(err, result) { 50 | callback(err, result); 51 | }); 52 | } 53 | 54 | callback(new Error('nothing to get')); 55 | } 56 | 57 | github.dependencies = { 58 | "github": "*" 59 | }; 60 | 61 | exports.github = github; -------------------------------------------------------------------------------- /github/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-github", 3 | "version": "0.4.2", 4 | "description": "for interacting with the Github.com API", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "github": "*", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /hook/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-hook", 3 | "version": "0.4.2", 4 | "description": "for managing event hooks ( IF this THEN that )", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /hook/test/tests.js: -------------------------------------------------------------------------------- 1 | var tap = require('tap'), 2 | test = tap.test, 3 | resource = require('resource'), 4 | hook = resource.use('hook'); 5 | 6 | // 7 | // Mock account resource 8 | // 9 | var account = resource.account = resource.define('account'); 10 | account.property('email', { 11 | type: 'string', format: 'email' 12 | }); 13 | account.persist('memory'); 14 | 15 | // 16 | // Mock email resource 17 | // 18 | var email = resource.email = resource.define('email'); 19 | email.method('send', send, { 20 | properties: { 21 | options: { 22 | properties: { 23 | email: { type: 'string', format: 'email' }, 24 | from: { type: 'string', format: 'email' }, 25 | subject: { type: 'string' }, 26 | body: { type: 'string' } 27 | }, 28 | }, 29 | callback:{ type: 'function' } 30 | } 31 | }); 32 | 33 | var emails = []; 34 | function send(options, callback) { 35 | emails.push(options); 36 | callback(null, options); 37 | }; 38 | 39 | test("create hooks",function (t) { 40 | hook.create({ 41 | if: 'account::create', 42 | then: 'email::send', 43 | with: { 44 | from: 'noreply@big.vc', 45 | subject: 'Your account has been created', 46 | body: 'Your account has been created. Visit http://big.vc and log in.' 47 | } 48 | }, function (err, _h) { 49 | t.error(err, 'created hook ' + _h.id); 50 | t.end(); 51 | }); 52 | }); 53 | 54 | test("start hooks", function (t) { 55 | hook.start(function (err) { 56 | t.error(err, 'hooks started'); 57 | t.end(); 58 | }); 59 | }); 60 | 61 | test("create account", function (t) { 62 | account.create({ id: 'josh', email: 'josh.holbrook@gmail.com' }, function (err, a) { 63 | t.error(err, 'created account ' + a.id); 64 | t.end(); 65 | }); 66 | }); 67 | 68 | test("hook fired", function (t) { 69 | t.equal(emails.length, 1, 'sent an email'); 70 | t.equal(emails[0].email, 'josh.holbrook@gmail.com', 'email is same as account'); 71 | t.equal(emails[0].from, 'noreply@big.vc', 'reply email is as in "with"'); 72 | t.equal(emails[0].subject, 'Your account has been created', 'subject is as in "with"'); 73 | t.end(); 74 | }); 75 | -------------------------------------------------------------------------------- /html/README.md: -------------------------------------------------------------------------------- 1 | # html 2 | 3 | 4 | for rendering html 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#html-properties) 11 | 12 | - [id](#html-properties-id) 13 | 14 | 15 | #### [methods](#html-methods) 16 | 17 | - [render](#html-methods-render) () 18 | 19 | 20 | 21 | for rendering html 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### html.render() 36 | 37 | 38 | 39 | 40 | 41 | ## dependencies 42 | - [html-lang](http://npmjs.org/package/html-lang) 43 | 44 | 45 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /html/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | html = resource.define('html'); 3 | 4 | html.schema.description = "for rendering html"; 5 | 6 | html.dependencies = { 7 | "html-lang": "*" 8 | }; 9 | 10 | html.method('render', render); 11 | 12 | function render (selector, str, data) { 13 | var _html = require('html-lang'); 14 | return _html.render(selector, str, data); 15 | }; 16 | 17 | exports.html = html; 18 | -------------------------------------------------------------------------------- /html/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-html", 3 | "version": "0.4.2", 4 | "description": "for rendering html", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "html-lang": "*", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /html/test/test.js: -------------------------------------------------------------------------------- 1 | var tap = require("tap"), 2 | resource = require('resource'); 3 | 4 | tap.test('can render data onto html', function (t) { 5 | 6 | var html = resource.use('html'); 7 | 8 | var tpl = '

    name placeholder

    '; 9 | 10 | var res = html.render({ name: "Bob" }, tpl); 11 | t.equal(res, '

    Bob

    ') 12 | t.end(); 13 | 14 | }); 15 | -------------------------------------------------------------------------------- /http/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcompany/resources/9cfcf61b01fb7af0a0d383348528a03226f24b2b/http/favicon.png -------------------------------------------------------------------------------- /http/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-http", 3 | "version": "0.4.2", 4 | "description": "provides an HTTP API", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "connect": "2.7.1", 13 | "express": "3.0.4", 14 | "request": "2.12.0", 15 | "resource": "0.4.x" 16 | } 17 | } -------------------------------------------------------------------------------- /http/public/index.html: -------------------------------------------------------------------------------- 1 |

    This is the default HTTP root for Big.

    2 |

    Next time, try setting `root`

    -------------------------------------------------------------------------------- /http/uploads/README.md: -------------------------------------------------------------------------------- 1 | Files uploaded through the http resource are temporarily stored here -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // 2 | // A collection of useful resources 3 | // 4 | var resources = exports; 5 | 6 | var resource = require('resource'), 7 | fs = require('fs'), 8 | path = require('path'); 9 | 10 | // 11 | // Read "/resources/" directory 12 | // 13 | var resourcesPath = __dirname + '/'; 14 | 15 | var _resources = fs.readdirSync(resourcesPath); 16 | 17 | // 18 | // Filter out any potential non-resource files / folders 19 | // 20 | _resources = _resources.filter(function (val) { 21 | var isResource = false; 22 | val = resourcesPath + val; 23 | isResource = resource.isResource(val); 24 | return isResource; 25 | }); 26 | 27 | // 28 | // Export `resources` on the module scope to store all currently loaded resources 29 | // 30 | exports.resources = {}; 31 | 32 | // 33 | // For every resource, use it and export it 34 | // 35 | _resources.forEach(function (r) { 36 | exports.resources[r] = resource.use(r); 37 | }); -------------------------------------------------------------------------------- /irc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-irc", 3 | "version": "0.4.2", 4 | "description": "for managing communication with irc", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "irc": "0.3.4", 13 | "optimist": "0.3.5", 14 | "resource": "0.4.x" 15 | } 16 | } -------------------------------------------------------------------------------- /jugglingdb/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | crud = require('./lib/crud'), 3 | jugglingdb = resource.define('jugglingdb'); 4 | 5 | jugglingdb.schema.description = "enables jugglingdb for resources"; 6 | 7 | // 8 | // Enables a resource to persistence by 9 | // creating a JugglingDB model to back the resource, 10 | // allowing the resource to be instantiable and backed by a datasource 11 | // 12 | function enable (r, options) { 13 | 14 | if(typeof options === "string") { 15 | options = { 16 | type: options 17 | }; 18 | } 19 | 20 | // 21 | // Require JugglingDB.Schema 22 | // 23 | var Schema = require('./vendor/jugglingdb').Schema, 24 | path = require('path'); 25 | 26 | // 27 | // Create new JugglingDB schema, based on incoming datasource type 28 | // 29 | var _type = mappings[options.type] || options.type || 'fs'; 30 | resource.use(options.type); 31 | crud(r); 32 | var schema = new Schema(_type, { 33 | database: options.name || "big", 34 | host: options.host, 35 | port: options.port, 36 | path: options.path || path.join(resource.helper.appDir, 'db'), 37 | username: options.username, 38 | password: options.password, 39 | options: options.options, 40 | https: true // TODO: check that HTTPS actually does something 41 | }); 42 | 43 | // 44 | // Create empty schema object for mapping between resource and JugglingDB 45 | // 46 | var _schema = {}; 47 | 48 | // 49 | // For every property in the resource schema, map the property to JugglingDB 50 | // 51 | Object.keys(r.schema.properties).forEach(function(p){ 52 | var prop = r.schema.properties[p]; 53 | _schema[p] = { type: jugglingType(prop) }; 54 | }); 55 | function jugglingType(prop) { 56 | var typeMap = { 57 | 'string': String, 58 | 'number': Number, 59 | 'integer': Number, 60 | 'array': JSON, 61 | 'boolean': Boolean, 62 | 'object': JSON, 63 | 'null': null, 64 | 'any': String 65 | }; 66 | 67 | return typeMap[prop.type] || String; 68 | } 69 | 70 | // 71 | // Create a new JugglingDB schema based on temp schema 72 | // 73 | var Model = schema.define(r.name, _schema); 74 | 75 | // assign model to resource 76 | r.model = Model; 77 | } 78 | 79 | var mappings = { 80 | "couchdb": "cradle", 81 | "couch": "cradle" 82 | }; 83 | 84 | // 85 | // enable is not a resource method ( as we don't want to defer binding of CRUD methods while waiting for node-uuid dep ) 86 | // 87 | jugglingdb.enable = enable; 88 | 89 | jugglingdb.dependencies = {}; 90 | 91 | exports.jugglingdb = jugglingdb; -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "support/nodeunit"] 2 | path = support/nodeunit 3 | url = https://github.com/caolan/nodeunit.git 4 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | doc 3 | coverage.html 4 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.4.12 4 | - 0.6 5 | before_install: 6 | - git submodule init && git submodule --quiet update 7 | - ./support/ci/neo4j.sh 8 | before_script: 9 | - "mysql -e 'create database myapp_test;'" 10 | - "psql -c 'create database myapp_test;' -U postgres" 11 | - mongo mydb_test --eval 'db.addUser("travis", "test");' 12 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/Makefile: -------------------------------------------------------------------------------- 1 | doc: 2 | makedoc lib/abstract-class.js lib/schema.js lib/validatable.js -t "JugglingDB API docs" 3 | 4 | test: 5 | @ONLY=memory ./support/nodeunit/bin/nodeunit test/*_test.* 6 | 7 | .PHONY: test 8 | .PHONY: doc 9 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/index.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var path = require('path'); 3 | 4 | exports.Schema = require('./lib/schema').Schema; 5 | exports.AbstractClass = require('./lib/abstract-class').AbstractClass; 6 | exports.Validatable = require('./lib/validatable').Validatable; 7 | 8 | exports.init = function (root) { 9 | if (!global.railway) return; 10 | railway.orm = exports; 11 | require('./lib/railway')(root); 12 | }; 13 | 14 | try { 15 | if (process.versions.node < '0.6') { 16 | exports.version = JSON.parse(fs.readFileSync(__dirname + '/package.json')).version; 17 | } else { 18 | exports.version = require('../package').version; 19 | } 20 | } catch (e) {} 21 | 22 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/hookable.js: -------------------------------------------------------------------------------- 1 | exports.Hookable = Hookable; 2 | 3 | function Hookable() { 4 | // hookable class 5 | }; 6 | 7 | Hookable.afterInitialize = null; 8 | Hookable.beforeValidation = null; 9 | Hookable.afterValidation = null; 10 | Hookable.beforeSave = null; 11 | Hookable.afterSave = null; 12 | Hookable.beforeCreate = null; 13 | Hookable.afterCreate = null; 14 | Hookable.beforeUpdate = null; 15 | Hookable.afterUpdate = null; 16 | Hookable.beforeDestroy = null; 17 | Hookable.afterDestroy = null; 18 | 19 | Hookable.prototype.trigger = function trigger(actionName, work, data) { 20 | var capitalizedName = capitalize(actionName); 21 | var afterHook = this.constructor["after" + capitalizedName]; 22 | var beforeHook = this.constructor["before" + capitalizedName]; 23 | var inst = this; 24 | 25 | // we only call "before" hook when we have actual action (work) to perform 26 | if (work) { 27 | if (beforeHook) { 28 | // before hook should be called on instance with one param: callback 29 | beforeHook.call(inst, function () { 30 | // actual action also have one param: callback 31 | work.call(inst, next); 32 | }, data); 33 | } else { 34 | work.call(inst, next); 35 | } 36 | } else { 37 | next(); 38 | } 39 | 40 | function next(done) { 41 | if (afterHook) { 42 | afterHook.call(inst, done); 43 | } else if (done) { 44 | done.call(this); 45 | } 46 | } 47 | }; 48 | 49 | function capitalize(string) { 50 | return string.charAt(0).toUpperCase() + string.slice(1); 51 | } 52 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/jutil.js: -------------------------------------------------------------------------------- 1 | exports.inherits = function (newClass, baseClass) { 2 | Object.keys(baseClass).forEach(function (classMethod) { 3 | newClass[classMethod] = baseClass[classMethod]; 4 | }); 5 | Object.keys(baseClass.prototype).forEach(function (instanceMethod) { 6 | newClass.prototype[instanceMethod] = baseClass.prototype[instanceMethod]; 7 | }); 8 | }; 9 | 10 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcompany/resources/9cfcf61b01fb7af0a0d383348528a03226f24b2b/jugglingdb/vendor/jugglingdb/lib/nosqlite/data/.gitkeep -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nosqlite", 3 | "version": "0.1.1", 4 | "author": "Pavan Kumar Sunkara ", 5 | "description": "human readable nosql type filesystem json store", 6 | "main": "./lib/nosqlite", 7 | "repository": { 8 | "type": "git", 9 | "url": "git://github.com/pksunkara/nosqlite.git" 10 | }, 11 | "keywords": [ 12 | "nosql", 13 | "json", 14 | "file", 15 | "couch", 16 | "filesystem", 17 | "store" 18 | ], 19 | "homepage": "http://pksunkara.github.com/nosqlite", 20 | "scripts": { 21 | "test": "./node_modules/.bin/vows --spec $(find test -name '*-test.coffee')" 22 | }, 23 | "contributors": [ 24 | { 25 | "name": "Pavan Kumar Sunkara", 26 | "email": "pavan.sss1991@gmail.com" 27 | } 28 | ], 29 | "devDependencies": { 30 | "coffee-script": "1.3.x", 31 | "vows": "0.6.x" 32 | }, 33 | "engines": { 34 | "node": ">= 0.6" 35 | }, 36 | "bugs": { 37 | "url": "https://github.com/pksunkara/nosqlite/issues" 38 | }, 39 | "licenses": [ 40 | { 41 | "type": "MIT", 42 | "url": "https://github.com/pksunkara/nosqlite/raw/master/LICENSE" 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/test/connection-test.coffee: -------------------------------------------------------------------------------- 1 | vows = require 'vows' 2 | assert = require 'assert' 3 | path = require 'path' 4 | 5 | vows 6 | .describe('connection') 7 | .addBatch 8 | 'Connection': 9 | topic: require '../src/nosqlite' 10 | 11 | 'should have default path': (nosqlite) -> 12 | assert.equal nosqlite.path, path.resolve(__dirname, '..', 'data') 13 | 14 | 'without options': 15 | topic: (nosqlite) -> 16 | return new(nosqlite.Connection)() 17 | 18 | 'should be successful': (topic) -> 19 | assert.equal topic.path, path.resolve(__dirname, '..', 'data') 20 | 21 | 'with options': 22 | topic: (nosqlite) -> 23 | return new(nosqlite.Connection) path.resolve(__dirname, 'fixtures') 24 | 25 | 'should be successful': (topic) -> 26 | assert.equal topic.path, path.resolve(__dirname, 'fixtures') 27 | 28 | .export(module) 29 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/test/fixtures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcompany/resources/9cfcf61b01fb7af0a0d383348528a03226f24b2b/jugglingdb/vendor/jugglingdb/lib/nosqlite/test/fixtures/.gitkeep -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/test/fixtures/test/bob.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "bob", 3 | "name": "bob", 4 | "age": 35 5 | } -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/vendor/rimraf/AUTHORS: -------------------------------------------------------------------------------- 1 | # Authors sorted by whether or not they're me. 2 | Isaac Z. Schlueter (http://blog.izs.me) 3 | Wayne Larsen (http://github.com/wvl) 4 | ritch 5 | Marcel Laverdet 6 | Yosef Dinerstein 7 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/vendor/rimraf/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009, 2010, 2011 Isaac Z. Schlueter. 2 | All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/vendor/rimraf/README.md: -------------------------------------------------------------------------------- 1 | A `rm -rf` for node. 2 | 3 | Install with `npm install rimraf`, or just drop rimraf.js somewhere. 4 | 5 | ## API 6 | 7 | `rimraf(f, callback)` 8 | 9 | The callback will be called with an error if there is one. Certain 10 | errors are handled for you: 11 | 12 | * `EBUSY` - rimraf will back off a maximum of opts.maxBusyTries times 13 | before giving up. 14 | * `EMFILE` - If too many file descriptors get opened, rimraf will 15 | patiently wait until more become available. 16 | 17 | 18 | ## rimraf.sync 19 | 20 | It can remove stuff synchronously, too. But that's not so good. Use 21 | the async API. It's better. 22 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/vendor/rimraf/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rimraf", 3 | "version": "2.1.1", 4 | "main": "rimraf.js", 5 | "description": "A deep deletion module for node (like `rm -rf`)", 6 | "author": { 7 | "name": "Isaac Z. Schlueter", 8 | "email": "i@izs.me", 9 | "url": "http://blog.izs.me/" 10 | }, 11 | "license": { 12 | "type": "MIT", 13 | "url": "https://github.com/isaacs/rimraf/raw/master/LICENSE" 14 | }, 15 | "optionalDependencies": { 16 | "graceful-fs": "~1.1" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git://github.com/isaacs/rimraf.git" 21 | }, 22 | "scripts": { 23 | "test": "cd test && bash run.sh" 24 | }, 25 | "contributors": [ 26 | { 27 | "name": "Isaac Z. Schlueter", 28 | "email": "i@izs.me", 29 | "url": "http://blog.izs.me" 30 | }, 31 | { 32 | "name": "Wayne Larsen", 33 | "email": "wayne@larsen.st", 34 | "url": "http://github.com/wvl" 35 | }, 36 | { 37 | "name": "ritch", 38 | "email": "skawful@gmail.com" 39 | }, 40 | { 41 | "name": "Marcel Laverdet" 42 | }, 43 | { 44 | "name": "Yosef Dinerstein", 45 | "email": "yosefd@microsoft.com" 46 | } 47 | ], 48 | "readme": "A `rm -rf` for node.\n\nInstall with `npm install rimraf`, or just drop rimraf.js somewhere.\n\n## API\n\n`rimraf(f, callback)`\n\nThe callback will be called with an error if there is one. Certain\nerrors are handled for you:\n\n* `EBUSY` - rimraf will back off a maximum of opts.maxBusyTries times\n before giving up.\n* `EMFILE` - If too many file descriptors get opened, rimraf will\n patiently wait until more become available.\n\n\n## rimraf.sync\n\nIt can remove stuff synchronously, too. But that's not so good. Use\nthe async API. It's better.\n", 49 | "readmeFilename": "README.md", 50 | "_id": "rimraf@2.1.1", 51 | "dependencies": { 52 | "graceful-fs": "~1.1" 53 | }, 54 | "_from": "rimraf" 55 | } 56 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/vendor/rimraf/test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | for i in test-*.js; do 4 | echo -n $i ... 5 | bash setup.sh 6 | node $i 7 | ! [ -d target ] 8 | echo "pass" 9 | done 10 | rm -rf target 11 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/vendor/rimraf/test/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | files=10 6 | folders=2 7 | depth=4 8 | target="$PWD/target" 9 | 10 | rm -rf target 11 | 12 | fill () { 13 | local depth=$1 14 | local files=$2 15 | local folders=$3 16 | local target=$4 17 | 18 | if ! [ -d $target ]; then 19 | mkdir -p $target 20 | fi 21 | 22 | local f 23 | 24 | f=$files 25 | while [ $f -gt 0 ]; do 26 | touch "$target/f-$depth-$f" 27 | let f-- 28 | done 29 | 30 | let depth-- 31 | 32 | if [ $depth -le 0 ]; then 33 | return 0 34 | fi 35 | 36 | f=$folders 37 | while [ $f -gt 0 ]; do 38 | mkdir "$target/folder-$depth-$f" 39 | fill $depth $files $folders "$target/d-$depth-$f" 40 | let f-- 41 | done 42 | } 43 | 44 | fill $depth $files $folders $target 45 | 46 | # sanity assert 47 | [ -d $target ] 48 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/vendor/rimraf/test/test-async.js: -------------------------------------------------------------------------------- 1 | var rimraf = require("../rimraf") 2 | , path = require("path") 3 | rimraf(path.join(__dirname, "target"), function (er) { 4 | if (er) throw er 5 | }) 6 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/vendor/rimraf/test/test-fiber.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigcompany/resources/9cfcf61b01fb7af0a0d383348528a03226f24b2b/jugglingdb/vendor/jugglingdb/lib/nosqlite/vendor/rimraf/test/test-fiber.js -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/nosqlite/vendor/rimraf/test/test-sync.js: -------------------------------------------------------------------------------- 1 | var rimraf = require("../rimraf") 2 | , path = require("path") 3 | rimraf.sync(path.join(__dirname, "target")) 4 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/lib/utils.js: -------------------------------------------------------------------------------- 1 | exports.safeRequire = safeRequire; 2 | 3 | function safeRequire(module) { 4 | try { 5 | return require(module); 6 | } catch (e) { 7 | console.log('Run "npm install ' + module + '" command to use jugglingdb using this database engine'); 8 | process.exit(1); 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/support/ci/neo4j.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # travis-ci.org now provides neo4j server but it is not started on boot 4 | which neo4j && sudo neo4j start 5 | sleep 5 6 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/test.js: -------------------------------------------------------------------------------- 1 | var j = require('jugglingdb'); 2 | 3 | var s = new j.Schema('redis', {}); 4 | var User = s.define('User', {email: String}); 5 | 6 | j.Validatable.haha = function () { 7 | console.log(this._validations); 8 | }; 9 | 10 | User.validatesUniquenessOf('email'); 11 | User.validateAsync('email', function(err, done) { 12 | done(); 13 | }); 14 | 15 | var u = new User({ 16 | email: "rob@foo.com" 17 | }); 18 | 19 | User.haha(); 20 | 21 | u.isValid(function (valid) { 22 | console.log('boooom'); 23 | console.log(valid); 24 | }); 25 | 26 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/test/hookable_test.coffee: -------------------------------------------------------------------------------- 1 | juggling = require('../index') 2 | Schema = juggling.Schema 3 | AbstractClass = juggling.AbstractClass 4 | Hookable = juggling.Hookable 5 | 6 | require('./spec_helper').init module.exports 7 | 8 | schema = new Schema 'memory' 9 | User = schema.define 'User', 10 | email: String 11 | name: String 12 | password: String 13 | state: String 14 | age: Number 15 | gender: String 16 | domain: String 17 | pendingPeriod: Number 18 | createdByAdmin: Boolean 19 | 20 | it "should trigger after initialize", (test) -> 21 | User.afterInitialize = -> 22 | User.afterInitialize = null 23 | test.done() 24 | user = new User 25 | 26 | 27 | it "should trigger before create", (test) -> 28 | User.beforeCreate = () -> 29 | User.beforeCreate = null 30 | test.done() 31 | User.create -> test.ok "saved" 32 | 33 | it "should trigger after create", (test) -> 34 | User.afterCreate = (next) -> 35 | User.afterCreate = null 36 | next() 37 | 38 | User.create -> 39 | test.ok "saved" 40 | test.done() 41 | 42 | it 'should trigger before save', (test) -> 43 | test.expect(3) 44 | User.beforeSave = (next) -> 45 | User.beforeSave = null 46 | @name = 'mr. ' + @name 47 | next() 48 | user = new User name: 'Jonathan' 49 | 50 | user.save -> 51 | test.equals User.schema.adapter.cache.User[user.id].name, user.name 52 | test.equals user.name, 'mr. Jonathan' 53 | test.ok 'saved' 54 | test.done() 55 | 56 | it 'should trigger after save', (test) -> 57 | User.afterSave = (next) -> 58 | User.afterSave = null 59 | next() 60 | 61 | user = new User 62 | user.save -> 63 | test.ok "saved" 64 | test.done() 65 | 66 | it "should trigger before update", (test) -> 67 | User.beforeUpdate = () -> 68 | User.beforeUpdate = null 69 | test.done() 70 | User.create {}, (err, user) -> 71 | user.updateAttributes email:"1@1.com", -> test.ok "updated" 72 | 73 | it "should trigger after update", (test) -> 74 | User.afterUpdate = () -> 75 | User.afterUpdate = null 76 | test.done() 77 | User.create (err, user) -> 78 | user.updateAttributes email: "1@1.com", -> test.ok "updated" 79 | 80 | it "should trigger before destroy", (test)-> 81 | User.beforeDestroy = () -> 82 | User.beforeDestroy = null 83 | test.done() 84 | User.create {}, (err, user) -> 85 | user.destroy() 86 | 87 | it "should trigger after destroy", (test) -> 88 | User.afterDestroy = () -> 89 | User.afterDestroy = null 90 | test.done() 91 | User.create (err, user) -> 92 | user.destroy() 93 | 94 | it 'allows me to modify attributes before saving', (test) -> 95 | test.done() 96 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/test/performance.coffee: -------------------------------------------------------------------------------- 1 | Schema = require('../index').Schema 2 | Text = Schema.Text 3 | 4 | require('./spec_helper').init exports 5 | 6 | schemas = 7 | neo4j: 8 | url: 'http://localhost:7474/' 9 | mongoose: 10 | url: 'mongodb://localhost/test' 11 | redis: {} 12 | memory: {} 13 | 14 | testOrm = (schema) -> 15 | 16 | User = Post = 'unknown' 17 | maxUsers = 100 18 | maxPosts = 50000 19 | users = [] 20 | 21 | it 'should define simple', (test) -> 22 | 23 | User = schema.define 'User', { 24 | name: String, 25 | bio: Text, 26 | approved: Boolean, 27 | joinedAt: Date, 28 | age: Number 29 | } 30 | 31 | Post = schema.define 'Post', 32 | title: { type: String, length: 255, index: true } 33 | content: { type: Text } 34 | date: { type: Date, detault: Date.now } 35 | published: { type: Boolean, default: false } 36 | 37 | User.hasMany(Post, {as: 'posts', foreignKey: 'userId'}) 38 | Post.belongsTo(User, {as: 'author', foreignKey: 'userId'}) 39 | 40 | test.done() 41 | 42 | it 'should create users', (test) -> 43 | wait = maxUsers 44 | done = (e, u) -> 45 | users.push(u) 46 | test.done() if --wait == 0 47 | User.create(done) for i in [1..maxUsers] 48 | 49 | it 'should create bunch of data', (test) -> 50 | wait = maxPosts 51 | done = -> test.done() if --wait == 0 52 | rnd = (title) -> 53 | { 54 | userId: users[Math.floor(Math.random() * maxUsers)].id 55 | title: 'Post number ' + (title % 5) 56 | } 57 | Post.create(rnd(num), done) for num in [1..maxPosts] 58 | 59 | it 'do some queries using foreign keys', (test) -> 60 | wait = 4 61 | done = -> test.done() if --wait == 0 62 | ts = Date.now() 63 | query = (num) -> 64 | users[num].posts { title: 'Post number 3' }, (err, collection) -> 65 | console.log('User ' + num + ':', collection.length, 'posts in', Date.now() - ts,'ms') 66 | done() 67 | query num for num in [0..4] 68 | 69 | return 70 | 71 | it 'should destroy all data', (test) -> 72 | Post.destroyAll -> 73 | User.destroyAll(test.done) 74 | 75 | Object.keys(schemas).forEach (schemaName) -> 76 | return if process.env.ONLY && process.env.ONLY != schemaName 77 | context schemaName, -> 78 | schema = new Schema schemaName, schemas[schemaName] 79 | testOrm(schema) 80 | 81 | -------------------------------------------------------------------------------- /jugglingdb/vendor/jugglingdb/test/spec_helper.js: -------------------------------------------------------------------------------- 1 | var semicov = require('semicov'); 2 | semicov.init('lib'); 3 | process.on('exit', semicov.report); 4 | 5 | try { 6 | global.sinon = require('sinon'); 7 | } catch (e) { 8 | // ignore 9 | } 10 | 11 | var group_name = false, EXT_EXP; 12 | function it (should, test_case) { 13 | check_external_exports(); 14 | if (group_name) { 15 | EXT_EXP[group_name][should] = test_case; 16 | } else { 17 | EXT_EXP[should] = test_case; 18 | } 19 | } 20 | 21 | global.it = it; 22 | 23 | function context(name, tests) { 24 | check_external_exports(); 25 | EXT_EXP[name] = {}; 26 | group_name = name; 27 | tests({ 28 | before: function (f) { 29 | it('setUp', f); 30 | }, 31 | after: function (f) { 32 | it('tearDown', f); 33 | } 34 | }); 35 | group_name = false; 36 | } 37 | 38 | global.context = context; 39 | 40 | exports.init = function (external_exports) { 41 | EXT_EXP = external_exports; 42 | if (external_exports.done) { 43 | external_exports.done(); 44 | } 45 | }; 46 | 47 | function check_external_exports() { 48 | if (!EXT_EXP) throw new Error( 49 | 'Before run this, please ensure that ' + 50 | 'require("spec_helper").init(exports); called'); 51 | } 52 | 53 | -------------------------------------------------------------------------------- /logger/README.md: -------------------------------------------------------------------------------- 1 | # logger 2 | 3 | 4 | a simple STDOUT based logger 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#logger-properties) 11 | 12 | - [id](#logger-properties-id) 13 | 14 | 15 | #### [methods](#logger-methods) 16 | 17 | - [log](#logger-methods-log) (level, message) 18 | 19 | - [put](#logger-methods-put) () 20 | 21 | 22 | 23 | a simple STDOUT based logger 24 | 25 | - **id** 26 | 27 | - **type** : any 28 | 29 | 30 | 31 | 32 | 33 | ## methods 34 | 35 | 36 | 37 | ### logger.log(level, message) 38 | 39 | logs data to STDOUT 40 | 41 | - **level** 42 | 43 | - **type** : string 44 | 45 | - **default** : info 46 | 47 | - **message** 48 | 49 | - **type** : any 50 | 51 | 52 | 53 | ### logger.put() 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /logger/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | util = require('util'), 3 | logger = resource.define('logger'); 4 | 5 | var levels = logger.levels = { 6 | info: 'green', 7 | data: 'grey', 8 | warn: 'yellow', 9 | error: 'red', 10 | event: 'grey', 11 | exec: 'grey', 12 | help: 'cyan', 13 | hook: 'magenta' 14 | }; 15 | 16 | // 17 | // logger may be set to silent at anytime by setting logger.silent=true 18 | // 19 | logger.silent = false; 20 | 21 | function log (/* level, a, b, c, ... */) { 22 | var args = [].slice.call(arguments), 23 | level = args.shift(), 24 | callback, 25 | message; 26 | 27 | if (typeof args[args.length - 1] === 'function') { 28 | callback = args.pop(); 29 | } 30 | 31 | message = util.format.apply(null, args); 32 | 33 | if(!logger.silent) { 34 | process.stdout.write(level[levels[level]] + ': ' + message + '\n'); 35 | } 36 | 37 | if (callback) { 38 | callback(null, level + ': ' + message); 39 | } 40 | else { 41 | return message; 42 | } 43 | } 44 | 45 | function hoistLevels (levels) { 46 | Object.keys(levels).forEach(function(level){ 47 | logger[level] = function (/* a, b, c, ... */) { 48 | var args = [].slice.call(arguments); 49 | logger.log.apply(null, [ level ].concat(args)); 50 | } 51 | }); 52 | }; 53 | 54 | function pad (str, count) { 55 | for (var i = 0; i < count; i++) { 56 | str += " "; 57 | } 58 | return str; 59 | }; 60 | 61 | function put (input, callback) { 62 | if(typeof callback !== "function") { 63 | callback = function () {}; 64 | } 65 | // 66 | // TODO: Print arrays of homogeneous objects in tabular form 67 | // 68 | if (Array.isArray(input)) { 69 | var keys = Object.keys(input[0]); 70 | input.forEach(function(item){ 71 | logger.data(JSON.stringify(item)) 72 | }); 73 | return callback(null, input); 74 | } 75 | logger.data(JSON.stringify(input)) 76 | return callback(null, input); 77 | }; 78 | 79 | hoistLevels(levels); 80 | 81 | // 82 | // Create logger resource 83 | // 84 | 85 | logger.schema.description = "a simple STDOUT based logger"; 86 | logger.method("log", log, { 87 | "description": "logs data to STDOUT", 88 | "properties": { 89 | "level": { 90 | "type": "string", 91 | "default": "info" 92 | }, 93 | "message": { 94 | "type": "any" 95 | } 96 | } 97 | }); 98 | 99 | logger.method('put', put); 100 | 101 | exports.logger = logger; -------------------------------------------------------------------------------- /markdown/README.md: -------------------------------------------------------------------------------- 1 | # markdown 2 | 3 | 4 | for parsing markdown 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#markdown-properties) 11 | 12 | - [id](#markdown-properties-id) 13 | 14 | 15 | #### [methods](#markdown-methods) 16 | 17 | - [render](#markdown-methods-render) () 18 | 19 | 20 | 21 | for parsing markdown 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### markdown.render() 36 | 37 | 38 | 39 | 40 | 41 | ## dependencies 42 | - [marked](http://npmjs.org/package/marked) 43 | 44 | 45 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /markdown/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | markdown = resource.define('markdown'); 3 | 4 | markdown.schema.description = "for parsing markdown"; 5 | 6 | markdown.dependencies = { 7 | "marked": "*" 8 | }; 9 | 10 | markdown.method('render', render); 11 | 12 | function render (str) { 13 | var marked = require('marked'); 14 | return marked(str); 15 | }; 16 | 17 | exports.markdown = markdown; 18 | -------------------------------------------------------------------------------- /markdown/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-markdown", 3 | "version": "0.4.2", 4 | "description": "for parsing markdown", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "marked": "*", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /markdown/test/test.js: -------------------------------------------------------------------------------- 1 | var tap = require("tap"), 2 | resource = require('resource'); 3 | 4 | tap.test('can render markdown into html', function (t) { 5 | var md = resource.use('markdown'); 6 | var str = "# hello"; 7 | var res = md.render(str); 8 | t.equal(res, '

    hello

    \n') 9 | t.end(); 10 | }); 11 | -------------------------------------------------------------------------------- /memory/README.md: -------------------------------------------------------------------------------- 1 | # memory 2 | 3 | 4 | adds memory persistence 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#memory-properties) 11 | 12 | - [id](#memory-properties-id) 13 | 14 | 15 | #### [methods](#memory-methods) 16 | 17 | - [start](#memory-methods-start) () 18 | 19 | 20 | 21 | adds memory persistence 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### memory.start() 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /memory/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | memory = resource.define('memory'); 3 | 4 | memory.schema.description = "enables memory persistence"; 5 | 6 | exports.memory = memory; -------------------------------------------------------------------------------- /memory/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-memory", 3 | "version": "0.4.2", 4 | "description": "adds memory persistence", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /mesh/example/client.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | var mesh = resource.use('mesh'); 4 | 5 | mesh.connect({ port: 8888 }, function(err){ 6 | if (err) { throw err; } 7 | setInterval(function(){ 8 | mesh.emit('client-foo', { bar: "foo" }); 9 | }, 2000); 10 | 11 | mesh.onAny(function(data){ 12 | console.log(this.event, data); 13 | }) 14 | 15 | }); 16 | -------------------------------------------------------------------------------- /mesh/example/server.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | var http = resource.use('http'); 3 | var mesh = resource.use('mesh'); 4 | 5 | http.listen(function (err) { 6 | if (err) { 7 | throw err; 8 | } 9 | mesh.listen(function(err){ 10 | if (err) { 11 | throw err; 12 | } 13 | 14 | mesh.onAny(function(data){ 15 | mesh.emit('server-echo::' + this.event, data); 16 | }); 17 | 18 | setInterval(function(){ 19 | mesh.emit('server-foo', { bar: "foo" }); 20 | }, 2000); 21 | 22 | mesh.onAny(function(data){ 23 | console.log(this.event, data) 24 | }) 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /mesh/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-mesh", 3 | "version": "0.4.2", 4 | "description": "provides a distributed p2p event emitter mesh", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "engine.io": "0.3.9", 13 | "engine.io-client": "0.3.9", 14 | "eventemitter2": "*", 15 | "resource": "0.4.x" 16 | } 17 | } -------------------------------------------------------------------------------- /node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-node", 3 | "version": "0.4.2", 4 | "description": "for managing nodes", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /node/recipes/TODO: -------------------------------------------------------------------------------- 1 | - Add conditional checks for existence of system deps and node before attempting installs 2 | - Add support for more OS and OS versions -------------------------------------------------------------------------------- /node/recipes/ls-test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # noc - ls-test 5 | # 6 | # simple ls test 7 | # 8 | # 9 | 10 | # run ls 11 | ls -a -------------------------------------------------------------------------------- /node/recipes/ubuntu-12.04: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # ubuntu-12.04 5 | # 6 | # bootstraps a fresh ubuntu-12.04 image with stable node.js and big 7 | # 8 | # 9 | 10 | # update apt-get 11 | apt-get -y update 12 | 13 | # install git 14 | apt-get -y install git-core 15 | 16 | # get latest stable node as tar 17 | wget https://github.com/joyent/node/tarball/v0.8.11 18 | 19 | # extract latest node 20 | tar xf v0.8.11 21 | 22 | # change directory into node 23 | cd joyent-node-0984ce9 24 | 25 | # install some missing deps 26 | apt-get -y install g++ curl libssl-dev apache2-utils 27 | 28 | # install some useful tools 29 | apt-get -y install members 30 | 31 | # configure 32 | ./configure 33 | 34 | # install make 35 | apt-get -y install make 36 | 37 | # make 38 | sudo make 39 | 40 | # install 41 | sudo make install 42 | 43 | # back to home 44 | cd .. 45 | 46 | # remove the update-motd 47 | # rm -rf /etc/update-motd.d/*.* 48 | 49 | # clone big from github 50 | git clone git://github.com/bigcompany/big.git 51 | 52 | # clone resource from github 53 | git clone git://github.com/bigcompany/resource.git 54 | 55 | # clone resources from github 56 | git clone git://github.com/bigcompany/resources.git 57 | 58 | 59 | # mon 60 | git clone https://github.com/visionmedia/mon.git 61 | cd mon 62 | make install 63 | 64 | cd .. 65 | 66 | # change directory into resource 67 | cd resource 68 | 69 | # install npm deps 70 | npm install 71 | 72 | # link locally with npm 73 | npm link 74 | 75 | # 76 | # TODO: CLEANUP FOLLOWING BLOCK / FIX DEPS 77 | # 78 | cd .. 79 | cd resources 80 | npm link resource 81 | npm link 82 | npm install -g 83 | 84 | cd .. 85 | cd resource 86 | npm link resources 87 | npm install -g 88 | 89 | # 90 | # TODO: remove the following manual npm installs 91 | # 92 | cd /root/resource/node_modules/jugglingdb/ 93 | npm install nosqlite 94 | npm install -g 95 | 96 | cd /root/resources/ssh/ 97 | npm install -g 98 | 99 | cd /root/big 100 | npm link resource 101 | npm install -g 102 | 103 | cd /root/big 104 | 105 | # needed for couchdb jugglingdb adapter 106 | npm install cradle -g 107 | 108 | # run once to install deps 109 | # node bin/big 110 | # big 111 | 112 | # start big replicator 113 | # node bin/big system groupadd --name big-users 114 | # node bin/big system useradd --user marak --group big-users 115 | # node bin/big system passwd --user marak --password b1gPPuol1 116 | 117 | # start the web admin 118 | node apps/admin -------------------------------------------------------------------------------- /npm/README.md: -------------------------------------------------------------------------------- 1 | # npm 2 | 3 | 4 | for interacting with the Node Package Manager api 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#npm-properties) 11 | 12 | - [id](#npm-properties-id) 13 | 14 | 15 | #### [methods](#npm-methods) 16 | 17 | - [publish](#npm-methods-publish) (path, callback) 18 | 19 | 20 | 21 | for interacting with the Node Package Manager api 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### npm.publish(path, callback) 36 | 37 | publishes a package to npm based on path 38 | 39 | - **path** 40 | 41 | - **type** : string 42 | 43 | - **required** : true 44 | 45 | - **callback** 46 | 47 | - **type** : function 48 | 49 | - **required** : true 50 | 51 | 52 | 53 | ## dependencies 54 | - [npm](http://npmjs.org/package/npm) 55 | 56 | 57 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /npm/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | npm = resource.define('npm'); 3 | 4 | npm.schema.description = "for interacting with the Node Package Manager"; 5 | 6 | function publish (options, callback) { 7 | var _npm = require('npm'), 8 | path = options.path; 9 | // remove path from options so it doesn't affect load 10 | delete options.path; 11 | // load npm config 12 | _npm.load(options, function (err) { 13 | if (err) { return callback(err); } 14 | // run npm publish of path 15 | _npm.commands.publish([path], callback); 16 | }); 17 | } 18 | npm.method('publish', publish, { 19 | description: "publishes a package to npm based on path", 20 | properties: { 21 | options: { 22 | path: { 23 | type: "string", 24 | required: true 25 | }, 26 | force: { 27 | description: "clobber previously published versions", 28 | type: "boolean" 29 | } 30 | }, 31 | callback: { 32 | type: "function", 33 | required: true 34 | } 35 | } 36 | }); 37 | 38 | function install (options, callback) { 39 | var _npm = require('npm'), 40 | packages = options.packages; 41 | // remove packages from options so it doesn't affect load 42 | delete options.packages; 43 | // load npm config 44 | _npm.load(options, function (err) { 45 | if (err) { return callback(err); } 46 | // run npm publish of path 47 | _npm.commands.install(packages, callback); 48 | }); 49 | } 50 | npm.method('install', install, { 51 | description: "installs a package", 52 | properties: { 53 | options: { 54 | packages: { 55 | type: "array", 56 | items: { 57 | type: "string" 58 | }, 59 | required: true 60 | }, 61 | prefix: { 62 | description: "the location to install global items. forces non-global commands to run in the specified folder.", 63 | type: "string" 64 | } 65 | }, 66 | callback: { 67 | type: "function", 68 | required: true 69 | } 70 | } 71 | }); 72 | 73 | /* 74 | 75 | TODO: 76 | 77 | npm.link = function (hook, callback) { 78 | _npm.load({exit:false}, function (err) { 79 | _npm.link(hook, function (err, result) { 80 | callback(err, result); 81 | }); 82 | }); 83 | } 84 | 85 | npm.search = function (keywords, callback) { 86 | _npm.load({exit:false}, function (err) { 87 | _npm.commands.search(keywords, function (err, result) { 88 | callback(err, result); 89 | }); 90 | }); 91 | } 92 | 93 | */ 94 | 95 | npm.dependencies = { 96 | "npm": "*" 97 | }; 98 | 99 | exports.npm = npm; 100 | -------------------------------------------------------------------------------- /npm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-npm", 3 | "version": "0.4.2", 4 | "description": "for interacting with the Node Package Manager api", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "npm": "*", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /npm/test/tests.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | tap = require('tap'), 3 | npm = resource.use('npm'); 4 | 5 | tap.test("install npm package", function (t) { 6 | npm.install({packages: ["Faker"]}, function (err, result) { 7 | t.ok(!err, "npm.install did not error"); 8 | t.ok(result, "npm.install returned result"); 9 | t.ok(require('Faker'), "Faker is installed"); 10 | t.end(); 11 | }); 12 | }); -------------------------------------------------------------------------------- /oauth/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-oauth", 3 | "version": "0.4.2", 4 | "description": "for managing oauth providers and sessions", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "oauth": "~0.9.8", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resources", 3 | "description": "resources for any occasion", 4 | "version": "0.4.3", 5 | "repository" : { 6 | "type" : "git", 7 | "url" : "http://github.com/bigcompany/resources.git" 8 | }, 9 | "dependencies": { 10 | "resource": "0.4.x" 11 | }, 12 | "devDependencies": { 13 | "tap": "*", 14 | "supertest": "*", 15 | "nock": "*" 16 | }, 17 | "main": "./index", 18 | "engine": [ 19 | "node 0.6.x" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /packager/README.md: -------------------------------------------------------------------------------- 1 | # packager 2 | 3 | 4 | for generating packager files 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#packager-properties) 11 | 12 | - [id](#packager-properties-id) 13 | 14 | 15 | #### [methods](#packager-methods) 16 | 17 | - [npm](#packager-methods-npm) (resource, callback) 18 | 19 | - [build](#packager-methods-build) () 20 | 21 | 22 | 23 | for generating packager files 24 | 25 | - **id** 26 | 27 | - **type** : any 28 | 29 | 30 | 31 | 32 | 33 | ## methods 34 | 35 | 36 | 37 | ### packager.npm(resource, callback) 38 | 39 | generates packager.json for a single resource 40 | 41 | - **resource** 42 | 43 | - **description** : the resource to generate packager.json for 44 | 45 | - **type** : any 46 | 47 | - **callback** 48 | 49 | - **type** : function 50 | 51 | 52 | 53 | ### packager.build() 54 | 55 | builds packager.json files for all resources 56 | 57 | 58 | 59 | 60 | 61 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /packager/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-packager", 3 | "version": "0.4.2", 4 | "description": "for generating packager files", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /page/README.md: -------------------------------------------------------------------------------- 1 | # page 2 | 3 | 4 | for representing HTML pages 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#page-properties) 11 | 12 | - [id](#page-properties-id) 13 | 14 | - [name](#page-properties-name) 15 | 16 | - [title](#page-properties-title) 17 | 18 | - [content](#page-properties-content) 19 | 20 | - [author](#page-properties-author) 21 | 22 | - [viewCount](#page-properties-viewCount) 23 | 24 | - [totalEdits](#page-properties-totalEdits) 25 | 26 | - [mtime](#page-properties-mtime) 27 | 28 | 29 | #### [methods](#page-methods) 30 | 31 | 32 | 33 | 34 | 35 | ## properties 36 | for representing HTML pages 37 | 38 | - **id** 39 | 40 | - **type** : any 41 | 42 | - **name** 43 | 44 | - **type** : string 45 | 46 | - **title** 47 | 48 | - **type** : string 49 | 50 | - **content** 51 | 52 | - **type** : string 53 | 54 | - **default** : 55 | 56 | - **author** 57 | 58 | - **type** : string 59 | 60 | - **viewCount** 61 | 62 | - **type** : number 63 | 64 | - **default** : 0 65 | 66 | - **totalEdits** 67 | 68 | - **type** : number 69 | 70 | - **default** : 0 71 | 72 | - **mtime** 73 | 74 | - **type** : number 75 | 76 | 77 | 78 | 79 | 80 | ## methods 81 | 82 | 83 | 84 | 85 | 86 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /page/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | page = resource.define('page'); 3 | 4 | page.schema.description = "for representing HTML pages"; 5 | 6 | page.property('name'); 7 | page.property('title'); 8 | page.property('content', { 9 | "type": "string", 10 | "default": "" 11 | }); 12 | page.property('author'); 13 | page.property('viewCount', { 14 | "type": "number", 15 | "default": 0 16 | }); 17 | page.property('totalEdits', { 18 | "type": "number", 19 | "default": 0 20 | }); 21 | 22 | page.property('mtime', { 23 | "type": "number" 24 | }); 25 | 26 | exports.page = page; -------------------------------------------------------------------------------- /page/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-page", 3 | "version": "0.4.2", 4 | "description": "for representing HTML pages", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /persistence/README.md: -------------------------------------------------------------------------------- 1 | # persistence 2 | 3 | 4 | enables persistence for resources 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#persistence-properties) 11 | 12 | - [id](#persistence-properties-id) 13 | 14 | 15 | #### [methods](#persistence-methods) 16 | 17 | - [enable](#persistence-methods-enable) () 18 | 19 | 20 | 21 | enables persistence for resources 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### persistence.enable() 36 | 37 | 38 | 39 | 40 | 41 | ## dependencies 42 | - [node-uuid](http://npmjs.org/package/node-uuid) 43 | - [async](http://npmjs.org/package/async) 44 | 45 | 46 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /persistence/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | persistence = resource.define('persistence'); 3 | 4 | persistence.schema.description = "enables persistence for resources"; 5 | 6 | var init = function (callback) { 7 | // 8 | // map uuid library to persistence resource 9 | // 10 | persistence.uuid = require('node-uuid'); 11 | return callback(null, true); 12 | }; 13 | 14 | persistence.method('init', init); 15 | 16 | var enable = function (r, options) { 17 | if(typeof options === "string") { 18 | options = { 19 | type: options 20 | }; 21 | } 22 | var engine = options.engine || "jugglingdb"; 23 | resource.use(engine).enable(r, options); 24 | }; 25 | 26 | // 27 | // enable is not a resource method ( as we don't want to defer binding of CRUD methods while waiting for node-uuid dep ) 28 | // 29 | persistence.enable = enable; 30 | 31 | persistence.dependencies = { 32 | "node-uuid": "*" 33 | }; 34 | 35 | exports.persistence = persistence; 36 | -------------------------------------------------------------------------------- /persistence/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-persistence", 3 | "version": "0.4.2", 4 | "description": "enables persistence for resources", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "node-uuid": "*", 13 | "async": "*", 14 | "resource": "0.4.x" 15 | } 16 | } -------------------------------------------------------------------------------- /queue/example/basic.js: -------------------------------------------------------------------------------- 1 | // 2 | // The queue can call resource methods with call signature (options, callback). 3 | // 4 | 5 | // 6 | // Example uses `queue` and `creature` resources 7 | // 8 | var resource = require('resource'), 9 | queue = resource.use('queue'), 10 | creature = resource.use('creature'); 11 | 12 | // 13 | // Observe when methods on creature are called 14 | // 15 | creature.onAny(function (data) { 16 | resource.logger.info(this.event.magenta + ': ', data); 17 | }); 18 | 19 | // 20 | // Create a new queue, with a processing delay of 500 milliseconds ( and default concurency of 1 ) 21 | // This means that items in the queue are processed every 1/2 second 22 | // 23 | queue.create({ 24 | interval: 5000, 25 | concurrency: 2 26 | }, function (err, _queue) { 27 | 28 | // 29 | // Once the queue is created, push five jobs onto it 30 | // 31 | for (var j = 0; j < 5; j++) { 32 | // 33 | // Push the resource method "creature.fire" 34 | // 35 | _queue.push({ 36 | method: 'creature::fire', 37 | // 38 | // Jobs on the queue support `with` metadata 39 | // 40 | with: { 41 | power: (10 * (j + 1)), 42 | direction: ['down', 'left', 'up', 'down', 'right'][j] 43 | } 44 | }); 45 | } 46 | 47 | // 48 | // Now that the queue has been created and populated with jobs, start it 49 | // 50 | _queue.start(); 51 | }); 52 | -------------------------------------------------------------------------------- /queue/example/repeat.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | var queue = resource.use('queue'); 4 | 5 | var creature = resource.use('creature'); 6 | 7 | creature.onAny(function (data) { 8 | resource.logger.info(this.event.magenta + ': ', data); 9 | }); 10 | 11 | // 12 | // Create an instance of queue with repeat turned ON 13 | // 14 | queue.create({ 15 | interval: 1200, 16 | concurrency: 2, 17 | repeat: true 18 | }, function (err, _queue) { 19 | 20 | // 21 | // Because repeat is set to true, we only have to push these jobs once. 22 | // 23 | _queue.push({ 24 | method: 'creature::talk', 25 | with: 'Fire!' 26 | }); 27 | _queue.push({ 28 | method: 'creature::fire', 29 | with: { 30 | power: 9001, 31 | direction: 'left' 32 | } 33 | }); 34 | 35 | _queue.start(); 36 | }); 37 | -------------------------------------------------------------------------------- /queue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-queue", 3 | "version": "0.4.2", 4 | "description": "a queue for resource events", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /repl/README.md: -------------------------------------------------------------------------------- 1 | # repl 2 | 3 | 4 | enables an interactive Read-Eval-Print-Loop ( REPL ) 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#repl-properties) 11 | 12 | - [id](#repl-properties-id) 13 | 14 | 15 | #### [methods](#repl-methods) 16 | 17 | - [start](#repl-methods-start) () 18 | 19 | 20 | 21 | enables an interactive Read-Eval-Print-Loop ( REPL ) 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### repl.start() 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /repl/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | repl = resource.define('repl'); 3 | 4 | repl.schema.description = "enables an interactive Read-Eval-Print-Loop ( REPL )"; 5 | 6 | repl.method('start', function(callback) { 7 | resource.logger.warn('STDIN will now be processed in a Read-Eval-Print-Loop'); 8 | resource.logger.help('try console logging the "resource" object'); 9 | require('repl').start("> ").context.resource = resource; 10 | if (callback) { 11 | callback(null, 'started'); 12 | } 13 | }); 14 | 15 | exports.repl = repl; -------------------------------------------------------------------------------- /repl/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-repl", 3 | "version": "0.4.2", 4 | "description": "enables an interactive Read-Eval-Print-Loop ( REPL )", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /replication/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | replication = resource.define('replication'); 3 | 4 | replication.schema.description = "for managing and keeping track of replication events"; 5 | 6 | replication.persist('memory'); 7 | 8 | replication.property('time', { 9 | "description": "the date and time of the replication", 10 | "type": "string", 11 | "default": new Date().toString() 12 | }); 13 | 14 | replication.property('source', { 15 | "description": "the source of the replication ( where the code is coming from )", 16 | "type": "string" 17 | }); 18 | 19 | replication.property('target', { 20 | "description": "the target of the replication ( where the code is going )", 21 | "type": "string" 22 | }); 23 | 24 | replication.property('repo', { 25 | "type": "string" 26 | }); 27 | 28 | replication.property('branch', { 29 | "type": "string" 30 | }); 31 | 32 | exports.replication = replication; 33 | -------------------------------------------------------------------------------- /replication/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-replication", 3 | "version": "0.4.2", 4 | "description": "for managing and keeping track of replication events", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /replicator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-replicator", 3 | "version": "0.4.2", 4 | "description": "provides an application replication API for resource based apps", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "pushover": "1.1.0", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /socket/README.md: -------------------------------------------------------------------------------- 1 | # socket 2 | 3 | 4 | websockets resource 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#socket-properties) 11 | 12 | - [id](#socket-properties-id) 13 | 14 | 15 | #### [methods](#socket-methods) 16 | 17 | - [start](#socket-methods-start) (callback) 18 | 19 | 20 | 21 | websockets resource 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### socket.start(callback) 36 | 37 | starts a websocket server 38 | 39 | - **callback** 40 | 41 | - **description** : the callback executed after server listen 42 | 43 | - **type** : function 44 | 45 | - **required** : false 46 | 47 | 48 | 49 | ## dependencies 50 | - [socket.io](http://npmjs.org/package/socket.io) v0.9.x 51 | 52 | 53 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /socket/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | socket = resource.define('socket'); 3 | 4 | socket.schema.description = "websockets resource"; 5 | 6 | socket.method('start', start, { 7 | "description": "starts a websocket server", 8 | "properties": { 9 | "callback": { 10 | "description": "the callback executed after server listen", 11 | "type": "function", 12 | "required": false 13 | } 14 | } 15 | }); 16 | 17 | // 18 | // Available websocket engines 19 | // see: /lib/engines/ for more 20 | exports.engines = { 21 | "socket.io": require('./lib/engines/socketio') 22 | }; 23 | 24 | function start (options, callback) { 25 | 26 | if (!callback && typeof options == 'function') { 27 | callback = options; 28 | options = {}; 29 | } 30 | 31 | var sockets = require('./lib/sockets'); 32 | socket.server = sockets.createServer( 33 | resource.resources, 34 | { server: resource.http.server }, 35 | function (err, io) { 36 | if (err) { 37 | return callback(err); 38 | } 39 | socket.io = io; 40 | callback(err, io); 41 | } 42 | ); 43 | } 44 | 45 | socket.dependencies = { 46 | "socket.io": "0.9.x" 47 | }; 48 | 49 | exports.socket = socket; -------------------------------------------------------------------------------- /socket/lib/engines/engineio.js: -------------------------------------------------------------------------------- 1 | // TODO: engine.io engine ( without socket.io ) 2 | var engine = require('engine.io'); -------------------------------------------------------------------------------- /socket/lib/engines/socketio.js: -------------------------------------------------------------------------------- 1 | var engine = exports; 2 | 3 | engine.createServer = function (resources, options, callback) { 4 | 5 | var io = require('socket.io').listen(options.server); 6 | callback(null, io); 7 | 8 | io.sockets.on('connection', function (socket) { 9 | Object.keys(resources).forEach(function(name) { 10 | var resource = resources[name]; 11 | 12 | // 13 | // For every resource, create a new socket.io handler 14 | // 15 | // 16 | // Remark: Delegate the resource action to the appropiate engine method 17 | // 18 | socket.on(resource.name, function (action, payload, callback) { 19 | // 20 | // Resource methods 21 | // 22 | if(typeof resource[action] === 'function') { 23 | return engine.request(resource, action, payload, callback); 24 | } 25 | 26 | return callback(new Error(action + ' is not a valid action.')); 27 | }); 28 | }); 29 | socket.on('disconnect', function () { 30 | // console.log('got a disconnect'); 31 | }); 32 | }); 33 | return io; 34 | }; 35 | 36 | engine.request = function(resource, action, payload, callback) { 37 | if (!callback && typeof payload == 'function') { 38 | callback = payload; 39 | payload = null; 40 | } 41 | 42 | if (payload) { 43 | resource[action](payload, callback); 44 | } 45 | else { 46 | resource[action](callback); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /socket/lib/engines/ws.js: -------------------------------------------------------------------------------- 1 | // TODO: `ws` package engine 2 | var ws = require('ws'); -------------------------------------------------------------------------------- /socket/lib/sockets.js: -------------------------------------------------------------------------------- 1 | var sockets = exports; 2 | 3 | exports.engines = { 4 | "socket.io": require('../lib/engines/socketio') 5 | }; 6 | 7 | exports.createServer = function (resources, options, callback) { 8 | options = options || {}; 9 | options.engine = options.engine || 'socket.io'; 10 | return sockets.engines[options.engine].createServer(resources, options, callback); 11 | }; 12 | -------------------------------------------------------------------------------- /socket/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-socket", 3 | "version": "0.4.2", 4 | "description": "websockets resource", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "socket.io": "0.9.x", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /ssh/README.md: -------------------------------------------------------------------------------- 1 | # ssh 2 | 3 | 4 | ssh interface resource 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#ssh-properties) 11 | 12 | - [id](#ssh-properties-id) 13 | 14 | 15 | #### [methods](#ssh-methods) 16 | 17 | 18 | 19 | ssh interface resource 20 | 21 | - **id** 22 | 23 | - **type** : any 24 | 25 | 26 | 27 | 28 | 29 | ## methods 30 | 31 | 32 | 33 | 34 | 35 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /ssh/bin/big-help: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | console.log('welcome to big ssh access'); -------------------------------------------------------------------------------- /ssh/bin/big-sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | test -z "$BIG_ROOT" && BIG_ROOT=$HOME 4 | 5 | export PATH="/usr/local/bin:/usr/bin:/bin:$HOME/bin" 6 | 7 | ## the root definition allows multiple users to use the same bin/big 8 | root=$BIG_ROOT 9 | while test -e $root; do 10 | root=$BIG_ROOT/big-session-$$ 11 | done 12 | 13 | args="--bigconf $root/bigconf" 14 | 15 | mkdir $root 16 | mkdir $root/tmp 17 | 18 | ln -s /usr/local/lib/node_modules $HOME/node_modules 19 | ln -s /root/big/resources $HOME/resources 20 | 21 | echo "{ 22 | \"protocol\": \"http\", 23 | }" > $root/bigconf 24 | 25 | atexit() { 26 | big $args logout > /dev/null 2>&1 27 | rm -rf $root 28 | exit 0 29 | } 30 | 31 | big-help() { 32 | local h=$(which big-help 2>/dev/null) 33 | test -n "$h" && "$h" || big $args help 34 | } 35 | 36 | trap "atexit" TERM 37 | trap "atexit" INT 38 | trap "atexit" HUP 39 | 40 | big $args login 41 | 42 | if test $? -eq 0; then 43 | echo "" 44 | big-help 45 | echo "" 46 | 47 | read -p "big > " -e command 48 | 49 | while test "$command" != "q" \ 50 | -a "$command" != "exit" \ 51 | -a "$command" != "quit"; do 52 | big $args ${command:0} 53 | read -p "big> " -e command 54 | done 55 | fi 56 | 57 | atexit 58 | -------------------------------------------------------------------------------- /ssh/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | ssh = resource.define('ssh'); 3 | 4 | ssh.schema.description = "ssh interface resource"; 5 | 6 | exports.ssh = ssh; 7 | -------------------------------------------------------------------------------- /ssh/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-ssh", 3 | "version": "0.4.2", 4 | "description": "ssh interface resource", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /stdin/README.md: -------------------------------------------------------------------------------- 1 | # stdin 2 | 3 | 4 | allows application to listen for input from STDIN 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#stdin-properties) 11 | 12 | - [id](#stdin-properties-id) 13 | 14 | 15 | #### [methods](#stdin-methods) 16 | 17 | - [start](#stdin-methods-start) () 18 | 19 | 20 | 21 | allows application to listen for input from STDIN 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### stdin.start() 36 | 37 | listens for STDIN on the process and attempts to eval it as JavaScript 38 | 39 | 40 | 41 | 42 | 43 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /stdin/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | stdin = resource.define('stdin'); 3 | 4 | stdin.schema.description = "allows application to listen for input from STDIN"; 5 | 6 | stdin.method('start', start, { 7 | "description": "listens for STDIN on the process and attempts to eval it as JavaScript" 8 | }); 9 | 10 | function start () { 11 | process.listening = true; 12 | process.stdin.resume(); 13 | process.stdin.setEncoding('utf8'); 14 | process.stdin.on('data', function (chunk) { 15 | var lines = chunk.split('\n'); 16 | lines.forEach(function(line){ 17 | if (line) { 18 | // 19 | // Evaluate all STDIN in current context 20 | // WARNING: This will not attempt to parse STDIN at all 21 | // If you don't control the STDIN for this process, don't big.use('stdin'). 22 | // 23 | try { 24 | eval(line); 25 | } catch (err) { 26 | throw err; 27 | } 28 | } 29 | }); 30 | }); 31 | process.stdin.on('end', function () {}); 32 | }; 33 | 34 | exports.stdin = stdin; 35 | -------------------------------------------------------------------------------- /stdin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-stdin", 3 | "version": "0.4.2", 4 | "description": "allows application to listen for input from STDIN", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /stdout/README.md: -------------------------------------------------------------------------------- 1 | # stdout 2 | 3 | 4 | outputs all events as new-line delimited JSON fragments to STDOUT 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#stdout-properties) 11 | 12 | - [id](#stdout-properties-id) 13 | 14 | 15 | #### [methods](#stdout-methods) 16 | 17 | 18 | 19 | outputs all events as new-line delimited JSON fragments to STDOUT 20 | 21 | - **id** 22 | 23 | - **type** : any 24 | 25 | 26 | 27 | 28 | 29 | ## methods 30 | 31 | 32 | 33 | 34 | 35 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /stdout/TODO: -------------------------------------------------------------------------------- 1 | - possibly remove this resource , or merge its functionality with the built in resource logger... 2 | - its nice to have .use('stdout'), but it might be overkill, better to use logger setting... -------------------------------------------------------------------------------- /stdout/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | stdout = resource.define('stdout'); 3 | 4 | stdout.schema.description = "outputs all events as new-line delimited JSON fragments to STDOUT"; 5 | 6 | resource.onAny(function(data){ 7 | data = data || {}; 8 | var obj = { 9 | "event": this.event, 10 | "data": data 11 | }; 12 | //console.log(JSON.stringify(obj)); 13 | }); 14 | 15 | exports.stdout = stdout; 16 | -------------------------------------------------------------------------------- /stdout/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-stdout", 3 | "version": "0.4.2", 4 | "description": "outputs all events as new-line delimited JSON fragments to STDOUT", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /swig/README.md: -------------------------------------------------------------------------------- 1 | # swig 2 | 3 | 4 | for parsing swig 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#swig-properties) 11 | 12 | - [id](#swig-properties-id) 13 | 14 | 15 | #### [methods](#swig-methods) 16 | 17 | - [render](#swig-methods-render) () 18 | 19 | - [configure](#swig-methods-configure) () 20 | 21 | 22 | 23 | for parsing swig 24 | 25 | - **id** 26 | 27 | - **type** : any 28 | 29 | 30 | 31 | 32 | 33 | ## methods 34 | 35 | 36 | 37 | ### swig.render() 38 | 39 | 40 | 41 | 42 | 43 | ### swig.configure() 44 | 45 | 46 | 47 | 48 | 49 | ## dependencies 50 | - [swig](http://npmjs.org/package/swig) 51 | 52 | 53 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /swig/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | swig = resource.define('swig'); 3 | 4 | swig.schema.description = "for parsing swig"; 5 | 6 | swig.method('render', render); 7 | 8 | function render (str, data) { 9 | var _swig = require('swig'), 10 | html = _swig.compile(str)(data); 11 | return html; 12 | }; 13 | 14 | swig.method('configure', function (options){ 15 | var _swig = require('swig'); 16 | _swig.init(options); 17 | }); 18 | 19 | swig.dependencies = { 20 | "swig": "*" 21 | }; 22 | 23 | exports.swig = swig; 24 | -------------------------------------------------------------------------------- /swig/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-swig", 3 | "version": "0.4.2", 4 | "description": "for parsing swig", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "swig": "*", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /swig/test/test.js: -------------------------------------------------------------------------------- 1 | var tap = require("tap"), 2 | resource = require('resource'); 3 | 4 | tap.test('can render swig into html', function (t) { 5 | var swig = resource.use('swig'); 6 | var str = "what is {{direction}}"; 7 | var res = swig.render(str, { direction: 'up' }); 8 | t.equal(res, "what is up") 9 | t.end(); 10 | }); 11 | -------------------------------------------------------------------------------- /system/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-system", 3 | "version": "0.4.2", 4 | "description": "for interacting with the operating system", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /tag/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | tag = resource.define('tag'); 3 | 4 | tag.schema.description = "a simple hierarchical tagging system"; 5 | 6 | tag.persist('memory'); 7 | 8 | tag.property("name", { 9 | "type":"string", 10 | "description": "the name of the tag", 11 | "required": true 12 | }); 13 | 14 | tag.property("parentID", { 15 | "type":"string", 16 | "description": "the parent ID of the tag", 17 | "key": "tag", 18 | "default": "" 19 | }); 20 | 21 | tag.method('createTag', createTag, { 22 | "description": "", 23 | "properties": { 24 | "options": { 25 | "type": "object", 26 | "properties": { 27 | "name": tag.schema.properties.name, 28 | "parentID": tag.schema.properties.parentID 29 | } 30 | } 31 | } 32 | }); 33 | 34 | // TODO: remove createTag function, move FK lookup to resource.js 35 | function createTag (options, callback) { 36 | console.log('createTag'); 37 | 38 | // 39 | // Check if the parent id exists 40 | // 41 | tag.get(options.parentID, function(err, result){ 42 | // 43 | // If there is any error getting parent ( not found, or other), 44 | // do not create the tag 45 | // 46 | if (err) { 47 | console.log(err) 48 | return callback(err); 49 | } 50 | 51 | return tag.create(options, callback); 52 | }); 53 | } 54 | 55 | 56 | tag.method('getTag', getTag, { 57 | "description": "", 58 | "properties": { 59 | "options": { 60 | "type": "object", 61 | "properties": { 62 | "id": tag.schema.properties.name 63 | } 64 | } 65 | } 66 | }); 67 | 68 | function getTag (options, callback) { 69 | var arr = []; 70 | 71 | 72 | function _fetch (id) { 73 | // 74 | // Get tag by id 75 | // 76 | tag.get(id, function(err, result){ 77 | // 78 | // If there is any error getting parent ( not found, or other), 79 | // do not go any further 80 | // 81 | if (err) { 82 | return callback(err); 83 | } 84 | arr.unshift(result); 85 | if(result.parentID === "null") { // TODO: 0 might better than stringy null value 86 | return callback(err, arr); 87 | } 88 | _fetch(result.parentID); 89 | }); 90 | } 91 | _fetch(options.id); 92 | } 93 | 94 | exports.tag = tag; -------------------------------------------------------------------------------- /tag/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-tag", 3 | "version": "0.4.2", 4 | "description": "a simple hierarchical tagging system", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /twitter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-twitter", 3 | "version": "0.4.2", 4 | "description": "for interacting with the Twitter API", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "ntwitter": "0.5.0", 13 | "twitter-text": "1.5.2", 14 | "resource": "0.4.x" 15 | } 16 | } -------------------------------------------------------------------------------- /validator/README.md: -------------------------------------------------------------------------------- 1 | # validator 2 | 3 | 4 | adds JSON-validator to resources 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#validator-properties) 11 | 12 | - [id](#validator-properties-id) 13 | 14 | 15 | #### [methods](#validator-methods) 16 | 17 | - [validate](#validator-methods-validate) (data, schema) 18 | 19 | 20 | 21 | adds JSON-validator to resources 22 | 23 | - **id** 24 | 25 | - **type** : any 26 | 27 | 28 | 29 | 30 | 31 | ## methods 32 | 33 | 34 | 35 | ### validator.validate(data, schema) 36 | 37 | hi 38 | 39 | - **data** 40 | 41 | - **type** : object 42 | 43 | - **schema** 44 | 45 | - **type** : object 46 | 47 | 48 | 49 | 50 | 51 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /validator/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | validator = resource.define('validator'); 3 | 4 | validator.schema.description = "adds JSON-validator to resources"; 5 | 6 | validator.method('validate', validate, { 7 | "description": "hi", 8 | "properties": { 9 | "data": { 10 | type: "object" 11 | }, 12 | "schema": { 13 | type: "object" 14 | } 15 | } 16 | }); 17 | 18 | function validate (data, schema) { 19 | var _validator = require('./vendor/validator'); 20 | return _validator.validate(data, schema); 21 | } 22 | 23 | exports.validator = validator; 24 | -------------------------------------------------------------------------------- /validator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-validator", 3 | "version": "0.4.2", 4 | "description": "adds JSON-validator to resources", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /validator/test/tests.js: -------------------------------------------------------------------------------- 1 | var wd = require('wd') 2 | , resource = require('resource') 3 | , validator = resource.use('validator') 4 | , tap = require('tap') 5 | , creature 6 | , creatures = {}; 7 | 8 | 9 | tap.test("create test creature resource", function(t) { 10 | creature = resource.define('creature'); 11 | t.ok(creature, "creature is defined"); 12 | 13 | creature.schema.description = "example resource for creatures"; 14 | 15 | creature.property('life', { type: "number", required: true }); 16 | 17 | t.end(); 18 | }); 19 | 20 | tap.test("validate empty life", function(t) { 21 | var validate = validator.validate({ 22 | life: "" 23 | }, creature.schema); 24 | t.notOk(validate.valid, "empty string is not valid life property"); 25 | t.end(); 26 | }); -------------------------------------------------------------------------------- /video/README.md: -------------------------------------------------------------------------------- 1 | # video 2 | 3 | 4 | for managing online digital videos 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#video-properties) 11 | 12 | - [id](#video-properties-id) 13 | 14 | - [title](#video-properties-title) 15 | 16 | - [link](#video-properties-link) 17 | 18 | - [description](#video-properties-description) 19 | 20 | - [tag](#video-properties-tag) 21 | 22 | 23 | #### [methods](#video-methods) 24 | 25 | - [play](#video-methods-play) () 26 | 27 | - [stop](#video-methods-stop) () 28 | 29 | 30 | 31 | 32 | 33 | ## properties 34 | for managing online digital videos 35 | 36 | - **id** 37 | 38 | - **type** : any 39 | 40 | - **title** 41 | 42 | - **type** : string 43 | 44 | - **default** : my title 45 | 46 | - **description** : the title of the video 47 | 48 | - **link** 49 | 50 | - **type** : string 51 | 52 | - **description** : the link to the video on a third party site 53 | 54 | - **format** : video 55 | 56 | - **description** 57 | 58 | - **type** : string 59 | 60 | - **description** : a brief description of the video 61 | 62 | - **tag** 63 | 64 | - **type** : string 65 | 66 | - **key** : tag 67 | 68 | - **description** : the tag id of the video 69 | 70 | 71 | 72 | 73 | 74 | ## methods 75 | 76 | 77 | 78 | ### video.play() 79 | 80 | 81 | 82 | 83 | 84 | ### video.stop() 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /video/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | video = resource.define('video'); 3 | 4 | video.schema.description = "for managing online digital videos"; 5 | 6 | video.property("title", { 7 | "type":"string", 8 | "default": "my title", 9 | "description": "the title of the video" 10 | }); 11 | 12 | video.property("link", { 13 | "type":"string", 14 | "description": "the link to the video on a third party site", 15 | "format": "video" 16 | }); 17 | 18 | video.property("description", { 19 | "type":"string", 20 | "description": "a brief description of the video" 21 | }); 22 | 23 | video.property("tag", { 24 | "type": "string", 25 | "key": "tag", 26 | "description": "the tag id of the video" 27 | }); 28 | 29 | video.method("play", function () { 30 | // 31 | // TODO 32 | // 33 | }); 34 | 35 | video.method("stop", function () { 36 | // 37 | // TODO 38 | // 39 | }); 40 | 41 | 42 | exports.video = video; -------------------------------------------------------------------------------- /video/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-video", 3 | "version": "0.4.2", 4 | "description": "for managing online digital videos", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "resource": "0.4.x" 13 | } 14 | } -------------------------------------------------------------------------------- /view/README.md: -------------------------------------------------------------------------------- 1 | # view 2 | 3 | 4 | for managing views 5 | 6 | 7 | 8 | ## API 9 | 10 | #### [properties](#view-properties) 11 | 12 | - [id](#view-properties-id) 13 | 14 | - [path](#view-properties-path) 15 | 16 | - [template](#view-properties-template) 17 | 18 | - [presenter](#view-properties-presenter) 19 | 20 | 21 | #### [methods](#view-methods) 22 | 23 | - [create](#view-methods-create) (options, callback) 24 | 25 | 26 | 27 | 28 | 29 | ## properties 30 | for managing views 31 | 32 | - **id** 33 | 34 | - **type** : any 35 | 36 | - **path** 37 | 38 | - **type** : string 39 | 40 | - **default** : . 41 | 42 | - **description** : the path to the view 43 | 44 | - **format** : uri 45 | 46 | - **template** 47 | 48 | - **type** : string 49 | 50 | - **description** : the string template of the view 51 | 52 | - **presenter** 53 | 54 | - **type** : function 55 | 56 | - **description:** : the presenter function of the view 57 | 58 | 59 | 60 | 61 | 62 | ## methods 63 | 64 | 65 | 66 | ### view.create(options, callback) 67 | 68 | creates a new view 69 | 70 | - **options** 71 | 72 | - **type** : object 73 | 74 | - **callback** 75 | 76 | - **type** : function 77 | 78 | - **required** : true 79 | 80 | 81 | 82 | ## dependencies 83 | - [cheerio](http://npmjs.org/package/cheerio) v0.9.x 84 | 85 | 86 | *README auto-generated with [docs](https://github.com/bigcompany/resources/tree/master/docs)* -------------------------------------------------------------------------------- /view/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | view = resource.define('view'), 3 | View = require('./lib/View'); 4 | 5 | // 6 | // Export the View class for convenience 7 | // 8 | exports.View = View; 9 | view.View = View; 10 | 11 | view.schema.description = "for managing views"; 12 | 13 | view.property("path", { 14 | "type": "string", 15 | "default": ".", 16 | "description": "the path to the view", 17 | "format": "uri" 18 | }); 19 | 20 | view.property("template", { 21 | "type": "string", 22 | "description": "the string template of the view" 23 | }); 24 | 25 | view.property("presenter", { 26 | "type": "function", 27 | "description:": "the presenter function of the view" 28 | }); 29 | 30 | view.method('create', create, { 31 | "description": "creates a new view", 32 | "properties": { 33 | "options": { 34 | "type": "object" 35 | }, 36 | "callback": { 37 | "type": "function", 38 | "required": true 39 | } 40 | } 41 | }); 42 | 43 | function create (options, callback) { 44 | options = options || {}; 45 | 46 | var view; 47 | 48 | // given template and presenter 49 | if (typeof options.template !== 'undefined' && 50 | typeof options.presenter !== 'undefined') { 51 | view = new View({ 52 | template: options.template, 53 | presenter: options.presenter 54 | }); 55 | 56 | // given just template 57 | } else if(typeof options.template !== 'undefined') { 58 | view = new View({ 59 | template: options.template 60 | }); 61 | 62 | // given just presenter 63 | } else if(typeof options.presenter !== 'undefined') { 64 | view = new View({ 65 | presenter: options.presenter 66 | }); 67 | 68 | // given neither template nor presenter 69 | } else { 70 | view = new View({ 71 | path: options.path 72 | }); 73 | } 74 | 75 | // 76 | // Remark: View should not attempt to load if no path was entered 77 | // 78 | if (typeof options.path === 'string') { 79 | return view.load(callback); 80 | } 81 | 82 | return callback(null, view); 83 | 84 | } 85 | 86 | // 87 | // View middleware 88 | // Creates a view from a folder and automatically route all urls to paths in that folder 89 | // 90 | view.middle = require('./middle'); 91 | 92 | view.dependencies = { 93 | "cheerio": "0.9.x" 94 | }; 95 | 96 | exports.view = view; -------------------------------------------------------------------------------- /view/lib/layout.js: -------------------------------------------------------------------------------- 1 | var query = require('./query'); 2 | 3 | module['exports'] = function (view, data, cb) { 4 | var $; 5 | 6 | if(typeof view.parent !== "undefined" && typeof view.parent.layout !== "undefined" && typeof view.parent.layout.present === 'function') { 7 | if (cb) { 8 | return view.parent.layout.present(data, function(err, content) { 9 | $ = query(content); 10 | $('#main').html(view.template); 11 | return cb(null, $.html()); 12 | }); 13 | } else { 14 | $ = query(view.parent.layout.present(data)); 15 | $('#main').html(view.template); 16 | } 17 | } else { 18 | $ = query(view.template); 19 | } 20 | 21 | if (cb) { 22 | return cb(null, $.html()); 23 | } else { 24 | return $.html(); 25 | } 26 | }; -------------------------------------------------------------------------------- /view/lib/query.js: -------------------------------------------------------------------------------- 1 | var query = function (content) { 2 | // 3 | // TODO: Add better feature detection here for $ 4 | // 5 | var $, 6 | cheerio; 7 | 8 | try { 9 | cheerio = require('cheerio'); 10 | } catch (err) { 11 | // Do nothing 12 | } 13 | 14 | // 15 | // Detected server-side node.js, use cheerio 16 | // 17 | if(typeof cheerio !== 'undefined') { 18 | $ = cheerio; 19 | } 20 | else 21 | { 22 | $ = function(){}; 23 | } 24 | 25 | if(typeof $.load === 'function') { 26 | $ = $.load(content); 27 | } 28 | return $; 29 | 30 | // 31 | // Detected client-side jQuery, use jQuery 32 | // 33 | // TODO 34 | 35 | // 36 | // Detected client-side querySelectorAll, using querySelectorAll 37 | // 38 | // TODO 39 | 40 | // 41 | // Client-side, but no $ found. Using Zepto fallback 42 | // 43 | // TODO 44 | }; 45 | 46 | module['exports'] = query; -------------------------------------------------------------------------------- /view/lib/render.js: -------------------------------------------------------------------------------- 1 | var render = function (options, callback) { 2 | var $ = this.$; 3 | 4 | if (typeof callback === "function") { 5 | callback(null, $.html()); 6 | } else { 7 | return $.html(); 8 | } 9 | }; 10 | 11 | module['exports'] = render; -------------------------------------------------------------------------------- /view/middle.js: -------------------------------------------------------------------------------- 1 | // view connect middleware 2 | 3 | module['exports'] = function (options) { 4 | 5 | options.prefix = options.prefix || ''; 6 | 7 | return function (req, res, next) { 8 | if (options.view) { 9 | // 10 | // If the view was mounted with a prefix and that prefix was not found in the incoming url, 11 | // do not attempt to use that view 12 | // 13 | if (options.prefix.length > 0 && req.url.search(options.prefix) === -1) { 14 | return next(); 15 | } 16 | var _view = options.view; 17 | var parts = require('url').parse(req.url).pathname.replace(options.prefix, '').split('/'); 18 | parts.shift(); 19 | 20 | // Remark: special case for root with no index, should be refactored 21 | if (parts.length === 1 && parts[0] === "" && !_view['index']) { 22 | return next(); 23 | } 24 | 25 | parts.forEach(function(part) { 26 | if(part.length > 0 && typeof _view !== 'undefined') { 27 | _view = _view[part]; 28 | } 29 | }); 30 | if (_view && _view['index']) { 31 | _view = _view['index']; 32 | } 33 | if(typeof _view === "undefined") { 34 | return next(); 35 | } 36 | if (typeof _view.present !== 'function') { 37 | return next(); 38 | } 39 | _view.present({ 40 | request: req, 41 | response: res, 42 | data: req.resource.params 43 | }, function (err, rendered) { 44 | res.end(rendered); 45 | }); 46 | } else { 47 | // 48 | // No view was found, do not use middleware 49 | // 50 | next(); 51 | } 52 | }; 53 | 54 | }; -------------------------------------------------------------------------------- /view/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-view", 3 | "version": "0.4.2", 4 | "description": "for managing views", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "cheerio": "0.9.x", 13 | "resource": "0.4.x" 14 | } 15 | } -------------------------------------------------------------------------------- /view/test/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # find where script is located, cd to the directory above 4 | DIR=$(cd $(dirname "$0") && pwd) 5 | 6 | rm -rf $DIR/../../resources/ 7 | #node tests.js 8 | node middle-tests.js 9 | 10 | -------------------------------------------------------------------------------- /view/test/view1/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view10/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view10/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | $('h1').html('big'); 11 | 12 | callback(null, $.html()); 13 | }; 14 | -------------------------------------------------------------------------------- /view/test/view10/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |
    3 |
    -------------------------------------------------------------------------------- /view/test/view10/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | callback(null, $.html()); 8 | }; 9 | -------------------------------------------------------------------------------- /view/test/view11/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view11/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view11/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |
    3 |
    4 | -------------------------------------------------------------------------------- /view/test/view11/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h1').html('big'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view11/table.html: -------------------------------------------------------------------------------- 1 |
    nothing
    2 | -------------------------------------------------------------------------------- /view/test/view11/table.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.table').html('steve'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /view/test/view12/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view12/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html(options.name); 8 | $('.user > .email').html(options.email); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view12/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |
    3 |
    -------------------------------------------------------------------------------- /view/test/view12/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h1').html(options.company); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view13/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view13/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html(options.name); 8 | $('.user > .email').html(options.email); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view13/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |
    3 |
    -------------------------------------------------------------------------------- /view/test/view13/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h1').html(options.company); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view13/table.html: -------------------------------------------------------------------------------- 1 |
    nothing
    2 | -------------------------------------------------------------------------------- /view/test/view13/table.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.table').html('steve'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /view/test/view14/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view14/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html(options.name); 8 | $('.user > .email').html(options.email); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view14/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |
    3 |
    -------------------------------------------------------------------------------- /view/test/view14/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h1').html(options.company); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view14/table.html: -------------------------------------------------------------------------------- 1 |
    nothing
    2 | -------------------------------------------------------------------------------- /view/test/view14/table.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.table').html(options.table); 8 | 9 | callback(null, $.html()); 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /view/test/view15/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view15/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view15/test/table.html: -------------------------------------------------------------------------------- 1 |
    nothing
    2 | -------------------------------------------------------------------------------- /view/test/view15/test/table.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.table').html('steve'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /view/test/view16/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view16/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view16/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |

    nothing

    3 |
    4 |
    -------------------------------------------------------------------------------- /view/test/view16/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h1').html('big'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view16/test/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |

    nothing

    3 |
    4 |
    -------------------------------------------------------------------------------- /view/test/view16/test/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h2').html('big'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view16/test/table.html: -------------------------------------------------------------------------------- 1 |
    nothing
    2 | -------------------------------------------------------------------------------- /view/test/view16/test/table.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.table').html('steve'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /view/test/view17/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |
    3 |
    -------------------------------------------------------------------------------- /view/test/view17/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h1').html('big'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view17/root.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view17/root.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view18/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view18/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view18/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |

    nothing

    3 |
    4 |
    -------------------------------------------------------------------------------- /view/test/view18/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h1').html('big'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view18/test/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |

    nothing

    3 |
    4 |
    -------------------------------------------------------------------------------- /view/test/view18/test/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h2').html('big'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view18/test/table.html: -------------------------------------------------------------------------------- 1 |
    nothing
    2 | -------------------------------------------------------------------------------- /view/test/view18/test/table.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.table').html('steve'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /view/test/view19/index2.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view19/index2.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view19/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |

    nothing

    3 |
    4 |
    -------------------------------------------------------------------------------- /view/test/view19/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h1').html('big'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view19/table2.html: -------------------------------------------------------------------------------- 1 |
    nothing
    2 | -------------------------------------------------------------------------------- /view/test/view19/table2.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.table').html('steve'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /view/test/view19/test2/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view19/test2/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view19/test2/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |

    nothing

    3 |
    4 |
    -------------------------------------------------------------------------------- /view/test/view19/test2/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h2').html('big'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view19/test2/table.html: -------------------------------------------------------------------------------- 1 |
    nothing
    2 | -------------------------------------------------------------------------------- /view/test/view19/test2/table.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.table').html('steve'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /view/test/view2/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view2/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view3/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view3/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view3/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |
    3 |
    -------------------------------------------------------------------------------- /view/test/view4/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view4/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view4/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | callback(null, "
    "); 8 | }; 9 | -------------------------------------------------------------------------------- /view/test/view5/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view5/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view5/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |
    3 |
    -------------------------------------------------------------------------------- /view/test/view5/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h1').html('big'); 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view6/index.html: -------------------------------------------------------------------------------- 1 |
    name
    2 |
    template
    3 |
    presenter
    4 |
    parent
    -------------------------------------------------------------------------------- /view/test/view6/index.js: -------------------------------------------------------------------------------- 1 | module['exports'] = function (options, callback) { 2 | 3 | var $ = this.$; 4 | 5 | $('.name').html(this.name); 6 | $('.presenter').html(escape(this.presenter)); 7 | $('.parent').html(this.parent.name); 8 | $(".template").html(escape(this.template)); 9 | 10 | callback(null, $.html()); 11 | }; -------------------------------------------------------------------------------- /view/test/view6/layout.html: -------------------------------------------------------------------------------- 1 |
    name
    2 |
    template
    3 |
    presenter
    4 |
    parent
    5 |
    -------------------------------------------------------------------------------- /view/test/view6/layout.js: -------------------------------------------------------------------------------- 1 | module['exports'] = function (options, callback) { 2 | 3 | var $ = this.$; 4 | 5 | $('.layout-name').html(this.name); 6 | $('.layout-template').html(escape(this.template)); 7 | $('.layout-presenter').html(escape(this.presenter)); 8 | $('.layout-parent').html(this.parent.name); 9 | 10 | callback(null, $.html()); 11 | }; -------------------------------------------------------------------------------- /view/test/view7/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view7/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view7/layout.html: -------------------------------------------------------------------------------- 1 |

    nothing

    2 |
    3 |
    -------------------------------------------------------------------------------- /view/test/view7/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('h1').html('big'); 8 | $('.main').html('big'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view8/index.html: -------------------------------------------------------------------------------- 1 |
    nothing
    -------------------------------------------------------------------------------- /view/test/view8/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view8/layout.html: -------------------------------------------------------------------------------- 1 |
    2 |
    -------------------------------------------------------------------------------- /view/test/view8/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | this.parent.index.template = '
    \n\t
    name
    \n\t\n
    '; 8 | 9 | callback(null, $.html()); 10 | }; 11 | -------------------------------------------------------------------------------- /view/test/view9/index.html: -------------------------------------------------------------------------------- 1 |
    2 |
    name
    3 | 4 |
    5 | -------------------------------------------------------------------------------- /view/test/view9/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | $('.user > .name').html('Bob'); 8 | $('.user > .email').html('bob@bob.com'); 9 | 10 | callback(null, $.html()); 11 | }; 12 | -------------------------------------------------------------------------------- /view/test/view9/layout.html: -------------------------------------------------------------------------------- 1 |
    2 |
    -------------------------------------------------------------------------------- /view/test/view9/layout.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'); 2 | 3 | module['exports'] = function (options, callback) { 4 | 5 | var $ = this.$; 6 | 7 | this.parent.index.presenter = function (options, callback) { 8 | callback(null, "hi"); 9 | }; 10 | 11 | callback(null, $.html()); 12 | }; 13 | -------------------------------------------------------------------------------- /virtualhost/index.js: -------------------------------------------------------------------------------- 1 | var resource = require('resource'), 2 | virtualhost = resource.define('virtualhost'); 3 | 4 | virtualhost.schema.description = "provides virtual hosts"; 5 | 6 | virtualhost.property('host'); 7 | virtualhost.property('path'); 8 | 9 | virtualhost.persist('memory'); 10 | 11 | virtualhost.middle = function(req, res, next) { 12 | var connect = require('connect'), 13 | path = require('path'), 14 | host = req.headers.host.split(':'); 15 | host = host[0]; 16 | resource.virtualhost.find({ host: host }, function (err, results) { 17 | if (err || results.length === 0) { 18 | if (process.env.NODE_ENV === 'production') { 19 | // resource.logger.warn('unknown host: ' + host); 20 | next(); 21 | } else { 22 | resource.virtualhost.all(function (err, hosts) { 23 | // resource.logger.warn('unknown host: ' + host); 24 | // resource.logger.warn('available hosts are ' + JSON.stringify(hosts, true, 2)); 25 | next(); 26 | }); 27 | } 28 | } else { 29 | req.url = "/" + host + req.url; 30 | req.virtualhost = results[0].host; 31 | req.virtualpath = results[0].path; 32 | next(); 33 | } 34 | }); 35 | }; 36 | 37 | virtualhost.dependencies = { 38 | "connect": "2.7.1", 39 | }; 40 | 41 | exports.virtualhost = virtualhost; -------------------------------------------------------------------------------- /virtualhost/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "resource-virtualhost", 3 | "version": "0.4.2", 4 | "description": "provides virtual hosts", 5 | "keywords": [ 6 | "big.vc", 7 | "resource", 8 | "resources" 9 | ], 10 | "main": "./index.js", 11 | "dependencies": { 12 | "connect": "2.7.1", 13 | "resource": "0.4.x" 14 | } 15 | } --------------------------------------------------------------------------------