Created
July 30, 2013 18:11
-
-
Save ben-ng/6115346 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "geddy", | |
"description": "Web framework for Node.js", | |
"keywords": [ | |
"Web", | |
"framework", | |
"REST", | |
"MVC", | |
"realtime" | |
], | |
"version": "0.9.12", | |
"author": { | |
"name": "Matthew Eernisse", | |
"email": "[email protected]", | |
"url": "http://fleegix.org" | |
}, | |
"dependencies": { | |
"jake": "0.5.x", | |
"utilities": "0.0.x", | |
"model": "0.2.x", | |
"barista": "0.0.x", | |
"socket.io": "0.9.x", | |
"mime": "1.2.x" | |
}, | |
"bin": { | |
"geddy": "./bin/cli.js" | |
}, | |
"scripts": { | |
"test": "jake test" | |
}, | |
"main": "./lib/geddy", | |
"repository": { | |
"type": "git", | |
"url": "git://github.com/mde/geddy.git" | |
}, | |
"preferGlobal": true, | |
"devDependencies": { | |
"browserify": "1.16.x", | |
"socket.io-client": "0.9.x", | |
"handlebars": "latest", | |
"jade": "latest", | |
"swig": "latest", | |
"ejs": "latest", | |
"request": "latest" | |
}, | |
"engines": { | |
"node": "*" | |
}, | |
"readme": "# Geddy\n####A simple, structured web framework for Node\n\n```\n$ npm install -g geddy\n$ geddy app my_app\n$ cd my_app\n$ geddy\n// app now running on localhost:4000\n```\n\n[](https://travis-ci.org/mde/geddy)\n\n### Documentation\n\nDocs are located on the GeddyJS website: http://geddyjs.org/documentation\n\n### Goals\n\n * Easy to use\n * Modular\n * Fast\n\nGeddy should make things easy for the most basic applications,\nbut still let you get under the hood and tinker if you want.\n\n### Features\n\n * Powerful, flexible router\n * Easy resource-based routing\n * Database adapters for Postgres, MongoDB, Riak, and in-memory\n * App, resource and scaffold generators\n * Content-negotiation\n * Session support (in-memory, cookie)\n * Multiple template engine support (EJS, Jade, Mustache, Handlebars, Swig)\n * Real Time API generation (socket.io integration)\n * View helpers ([Docs](https://github.com/mde/geddy/wiki/View-Helpers))\n * Fully non-blocking\n\n### License\n\nApache License, Version 2\n\n### Prerequisites\n\nGeddy requires version 0.8.x of Node.js or higher, and the\n[Jake](https://github.com/mde/jake) JavaScript build-tool.\n\n### Installing with [NPM](http://npmjs.org/)\n\n```\n[sudo] npm -g install geddy\n```\n\nNote: Geddy (specifically, the generators) is a system-level\ntool, and wants to be installed globally.\n\n### Creating a Geddy application\n\nTo create Geddy applications simply run `geddy app <name>`.\nThen you can run `geddy` inside the application to start the server.\n\n```\nmde@localhost:~/work$ geddy app bytor\nCreated app bytor.\nmde@localhost:~/work$ cd bytor\nmde@localhost:~/work/bytor$ geddy\nServer running at http://127.0.0.1:4000/\n```\n\nGo to http://localhost:4000/, and you should see the introduction page.\n\n### Generating resources\n\nUse `geddy resource <name> [model properties]` to generate a resource in your application.\nA resources does not generate a view, but creates a view directory. A resource route will be\ncreated for you.\n\n````\nmde@localhost:~/work$ geddy resource snow_dog breed:string name:string color:string\n[Added] app/models/snow_dog.js\n[Added] app/controllers/snow_dogs.js\n[Added] Resource snow_dogs route added to config/router.js\n[Added] snow_dogs view directory\n```\n\nNow start your Geddy server and your new route will work. Trying this for example\nwill return the params for the index action in JSON:\n\n```\n$ curl localhost:4000/snow_dogs.json\n{\"params\":{\"method\":\"GET\",\"controller\":\"SnowDogs\",\"action\":\"index\",\"format\":\"json\"}}\n```\n\nGeddy generators handle plural inflections for model and controller names (e.g., \"person\" to \"people\").\nTo read about the model properties argument, see [Model properties](#model-properties).\n\n### Generating scaffolding\n\nUse `geddy scaffold <name> [model properties]` to generate scaffoling in your application.\nScaffolding creates full CRUD actions, includes views, and will default your configuration to use\n[Mongodb](http://www.mongodb.org/). Resource routes will be created for you.\n\n````\nmde@localhost:~/work$ geddy scaffold snow_dog breed:string name:string color:string\n[Added] app/models/snow_dog.js\n[Added] app/controllers/snow_dogs.js\n[Added] Resource snow_dogs route added to config/router.js\n[Added] View templates\n[Added] Database configuration to config/environment.js\n```\n\nNow start your Geddy server and you'll have new views created from scaffolding. Trying this for example\nwill return the content for the index action in HTML:\n\n```\n$ curl localhost:4000/snow_dogs\n<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <title>Geddy App | This app uses Geddy.js</title>\n <meta name=\"description\" content=\"\">\n <meta name=\"author\" content=\"\">\n\n <meta name=\"viewport\" content=\"width=device-width\" />\n\n <!-- The HTML5 shim, for IE6-8 support of HTML elements -->\n <!--[if lt IE 9]>\n <script src=\"http://html5shim.googlecode.com/svn/trunk/html5.js\"></script>\n <![endif]-->\n\n.....\n```\n\n### Model properties\n\nSome Geddy generators (resource, scaffold, and model) have an argument that takes a list of model\nproperties. Here's an example of a resource with some properties:\n\n```\ngeddy resource user name admin:boolean lastLogin:datetime\n```\n\nEach of these items include a name and an optional type. If there's no type given, it will default\nto string. The list of supported types are listed in the [model](https://github.com/mde/geddy/wiki/Models) documentation.\nIf no id property is given, then a default id property will be created with the type of string.\n\nYou can also use custom default properties:\n```\ngeddy resource user name:default admin:boolean\n```\nThe above example will use the property `name`(string) to display the items in the views instead of the default ID property. This way when generating scaffolds, it will look better out of the box.\n\n### Routes\n\nGeddy uses the Barista router: https://github.com/kieran/barista\n\nRoutes are created in a similar fashion to Merb or Rails.\n\n***Basic routes***\n```\nrouter.match('/moving/pictures/:id').to(\n {controller: 'Moving', action: 'pictures'});\n\nrouter.match('/farewells/:farewelltype/kings/:kingid').to(\n {controller: 'Farewells', action: 'kings'});\n\n//Can also match specific HTTP methods only\nrouter.match('/xandadu', 'get').to(\n {controller: 'Xanadu', action: 'specialHandler'});\n```\n\n***Resource routes***\n```\nrouter.resource('hemispheres');\n```\n\n### Resources and controllers\n\nGeddy's resource-based routes create url/request-method mappings\nfor easy CRUD operations:\n\n```\nGET */snow_dogs[.extension]\n(SnowDogs controller, index action)\n\nGET */snow_dogs/add[.extension]\n(SnowDogs controller, add action, for any new resource template; \"new\" is not usable as a JavaScript action name)\n\nPOST */snow_dogs[.extension]\n(SnowDogs controller, create action)\n\nGET */snow_dogs/:id[.extension]\n(SnowDogs controller, show action)\n\nGET */snow_dogs/:id/edit[.extension]\n(SnowDogs controller, edit action)\n\nPUT */snow_dogs/:id[.extension]\n(SnowDogs controller, update action)\n\nDELETE */snow_dogs/:id[.extension]\n(SnowDogs controller, remove action)\n```\n\nA simple controller that just responds with any\nform-post/query-string params looks like this:\n\n```javascript\nvar SnowDogs = function () {\n this.respondsWith = ['text', 'json', 'html'];\n\n this.index = function (params) {\n this.respond({params: params});\n };\n\n this.add = function (params) {\n this.respond({params: params});\n };\n\n this.create = function (params) {\n this.respond({params: params});\n };\n\n this.show = function (params) {\n this.respond({params: params});\n };\n\n this.update = function (params) {\n this.respond({params: params});\n };\n\n this.remove = function (params) {\n this.respond({params: params});\n };\n\n};\n\nexports.SnowDogs = SnowDogs;\n```\n\n## Content-negotiation\n\nGeddy can perform content-negotiation, and respond with with the\ncorrect format based on the requested filename extension.\n\nIf you have a JSON-serializable JavaScript object you want to\nreturn in JSON format, pass your JavaScript object to the\n`respond` method in the action on that controller.\n\n```javascript\nthis.respondsWith = ['text', 'json'];\n\nthis.show = function (params) {\n item = {foo: 'FOO', bar: 1, baz: false};\n this.respond(item);\n};\n```\n## Models and validations\n\nGeddy has a simple way of defining models with a full-featured\nset of data validations. The syntax is similar to models in\nRuby's ActiveRecord or DataMapper.\n\nHere is an example of a model with some validations:\n\n```javascript\nvar User = function () {\n this.property('login', 'string', {required: true});\n this.property('password', 'string', {required: true});\n this.property('lastName', 'string');\n this.property('firstName', 'string');\n\n this.validatesPresent('login');\n this.validatesFormat('login', /[a-z]+/, {message: 'Subdivisions!'});\n this.validatesLength('login', {min: 3});\n this.validatesConfirmed('password', 'confirmPassword');\n this.validatesWithFunction('password', function (s) {\n // Something that returns true or false\n return s.length > 0;\n });\n\n // Can define methods for instances like this\n this.someMethod = function () {\n // Do some stuff\n };\n};\n\n// Can also define them on the prototype\nUser.prototype.someOtherMethod = function () {\n // Do some other stuff\n};\n\nUser = geddy.model.register('User', User);\n```\n\nAlternatively, you can use the `defineProperties` method to lay out your model:\n\n```javascript\nvar User = function () {\n this.defineProperties({\n login: {type: 'string', required: true}\n , password: {type: 'string', required: true}\n , lastName: {type: 'string'}\n , firstName: {type: 'string'}\n });\n}\n```\n\nCreating an instance of one of these models is easy:\n\n```javascript\nvar params = {\n login: 'alex'\n, password: 'lerxst'\n, lastName: 'Lifeson'\n, firstName: 'Alex'\n};\nvar user = User.create(params);\n```\n\nData-validation happens on the call to `create`, and any\nvalidation errors show up inside an `errors` property on\nthe instance, keyed by field name. Instances have a `valid`\nmethod that returns a Boolean indicating whether the instance\nis valid.\n\n```javascript\n// Leaving out the required password field\nvar params = {\n login: 'alex'\n};\nvar user = User.create(params);\n\n// Prints 'false'\nutil.puts(user.valid());\n// Prints 'Field \"password\" is required'\nutil.puts(user.errors.password);\n```\n\n## Running the tests\n\nIn the geddy project directory, run `jake test`. The tests simply\nuse NodeJS's `assert` module, which throws an error on failure.\nIf there are no errors, the tests all ran successfully.\n\n- - -\nGeddy Web-app development framework copyright 2112\[email protected].\n\n", | |
"readmeFilename": "README.md", | |
"bugs": { | |
"url": "https://github.com/mde/geddy/issues" | |
}, | |
"_id": "[email protected]", | |
"dist": { | |
"shasum": "ea42bf78f80ce1f7fbb6b2b5000fb6e7f7981f59" | |
}, | |
"_from": "[email protected]", | |
"_resolved": "https://registry.npmjs.org/geddy/-/geddy-0.9.12.tgz" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment