-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.json
1 lines (1 loc) · 1.78 KB
/
params.json
1
{"name":"Invisible.js","tagline":"Reusable models in the client and the server","body":"Invisible.js works on top of your [express](http://expressjs.com/) app leveraging [browserify](https://github.com/substack/node-browserify) to allow your domain models to work seamlessly in the client and the server. \r\n\r\n Invisible = require(\"invisible\");\r\n crypto = require(\"crypto\");\r\n _s = require(\"underscore.string\");\r\n\r\n function Person(firstName, lastName, email){\r\n this.firstName = firstName;\r\n this.lastName = lastName;\r\n this.email = email;\r\n }\r\n\r\n Person.prototype.fullName = function(){\r\n return this.firstName + ' ' + this.lastName;\r\n }\r\n\r\n Person.prototype.getAvatarUrl = function(){\r\n cleanMail = _s.trim(this.email).toLowerCase();\r\n hash = crypto.createHash(\"md5\").update(cleanMail).digest(\"hex\");\r\n return \"http://www.gravatar.com/avatar/\" + hash;\r\n }\r\n\r\n module.exports = Invisible.createModel(\"Person\", Person);\r\n\r\nRequire as usual in the server:\r\n\r\n Invisible = require(\"invisible\")\r\n john = new Invisible.Person(\"John\", \"Doe\", \"[email protected]\");\r\n john.fullName(); //John Doe\r\n\r\nIn the client, just add the invisible script:\r\n\r\n <script src=\"invisible.js\"></script>\r\n <script>\r\n jane = new Invisible.Person(\"Jane\", \"Doe\", \"[email protected]\");\r\n alert(jane.fullName()); //Jane Doe\r\n </script>\r\n\r\nVoilà! Restful API, MongoDB persistence, client and server validations and real-time events all come for free! See the [github project](https://github.com/invisiblejs/invisible/) for a full reference.","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}