<commit_before>## Geddy: a small, hackable Web app development framework for Node.js
- - -

### Goals

  * Make the simple stuff easy without making the hard stuff impossible
  * Performance, simplicity, modularity
  * Reasonable defaults, easy to override
  * Simple API, simple codebase

Geddy should make things easy for the most basic applications,
but still let you get under the hood and tinker if you want.

### Features

  * Powerful, flexible router
  * Easy resource-based routing
  * App and resource generators
  * Content-negotiation
  * Session support (in-memory and CouchDB)
  * Templating (EJS), partials support
  * Fully non-blocking

### License

Apache License, Version 2

### Building and installing Geddy

** Prerequisites**

Geddy requires version 0.1.91 of Node.js.

To get Geddy from GitHub and install it:

    git clone git://github.com/mde/geddy.git
    cd geddy
    make && sudo make install

### Routes

Routes are similar to Merb or Rails routes. 

**Basic routes**
  
    router.match('/moving/pictures/:id').to(
      {controller: 'Moving', action: 'pictures'});

    router.match('/farewells/:farewelltype/kings/:kingid').to(
       {controller: 'Farewells', action: 'kings'});

    //Can also match specific HTTP methods only
    router.match('/xandadu', 'get').to(
      {controller: 'Xandadu', action: 'specialHandler'});

**Resource-based routes**
  
    router.resource('hemispheres');

### Creating a Geddy app

Geddy comes with a utility called `geddy-gen` you can use to
create an app. Run `geddy` to start the server.

    mde@localhost:~/work$ geddy-gen app bytor
    Created app bytor.
    mde@localhost:~/work$ cd bytor
    mde@localhost:~/work/bytor$ geddy
    Server running at http://127.0.0.1:8000/

Go to http://localhost:8000/, and you should see:

Attention all planets of the Solar Federation

### Adding resources

Use `geddy-gen resource` in your app directory to add a
resource. The route will be set up automatically for you.

    mde@localhost:~/work/bytor$ geddy-gen resource snow_dogs
    [ADDED] ./app/controllers/snow_dogs.js
    resources snow_dogs route added to ./config/router.js
    Created view templates.

Restart Geddy, and you'll see the new route working. Hit your
new route -- for example, http://localhost:8000/snow_dogs.json,
and you should see something like this:

{"method":"index","params":{"extension":"json"}}

### App layout

After adding a resource, a Geddy app is laid out like this:

    mde@localhost:~/work/bytor$ find .
    .
    ./config
    ./config/config.js
    ./config/router.js
    ./app
    ./app/controllers
    ./app/controllers/snow_dogs.js
    ./app/controllers/main.js
    ./app/controllers/application.js
    ./app/views
    ./app/views/snow_dogs
    ./app/views/snow_dogs/show.html.ejs
    ./app/views/snow_dogs/add.html.ejs
    ./app/views/snow_dogs/index.html.ejs
    ./public

### Resources and controllers

Geddy's resource-based routes create url/request-method mappings
for easy CRUD operations like this:

GET */snow_dogs*<br/>
(SnowDogs controller, index action)<commit_msg>Updated README to describe model stubs and pluralization with geddy-gen resource.<commit_after>## Geddy: a small, hackable Web app development framework for Node.js
- - -

### Goals

  * Make the simple stuff easy without making the hard stuff impossible
  * Performance, simplicity, modularity
  * Reasonable defaults, easy to override
  * Simple API, simple codebase

Geddy should make things easy for the most basic applications,
but still let you get under the hood and tinker if you want.

### Features

  * Powerful, flexible router
  * Easy resource-based routing
  * App and resource generators
  * Content-negotiation
  * Session support (in-memory and CouchDB)
  * Templating (EJS), partials support
  * Fully non-blocking

### License

Apache License, Version 2

### Building and installing Geddy

** Prerequisites**

Geddy requires version 0.1.91 of Node.js.

To get Geddy from GitHub and install it:

    git clone git://github.com/mde/geddy.git
    cd geddy
    make && sudo make install

### Routes

Routes are similar to Merb or Rails routes. 

**Basic routes**
  
    router.match('/moving/pictures/:id').to(
      {controller: 'Moving', action: 'pictures'});

    router.match('/farewells/:farewelltype/kings/:kingid').to(
       {controller: 'Farewells', action: 'kings'});

    //Can also match specific HTTP methods only
    router.match('/xandadu', 'get').to(
      {controller: 'Xandadu', action: 'specialHandler'});

**Resource-based routes**
  
    router.resource('hemispheres');

### Creating a Geddy app

Geddy comes with a utility called `geddy-gen` you can use to
create an app. Run `geddy` to start the server.

    mde@localhost:~/work$ geddy-gen app bytor
    Created app bytor.
    mde@localhost:~/work$ cd bytor
    mde@localhost:~/work/bytor$ geddy
    Server running at http://127.0.0.1:8000/

Go to http://localhost:8000/, and you should see:

Attention all planets of the Solar Federation

### Adding resources

Use `geddy-gen resource` in your app directory to add a
resource. The route will be set up automatically for you.

    mde@localhost:~/work/bytor$ geddy-gen resource snow_dog
    [ADDED] ./app/models/snow_dog.js
    [ADDED] ./app/controllers/snow_dogs.js
    resources snow_dogs route added to ./config/router.js
    Created view templates.

Restart Geddy, and you'll see the new route working. Hit your
new route -- for example, http://localhost:8000/snow_dogs.json,
and you should see something like this:

{"method":"index","params":{"extension":"json"}}

The geddy-gen utility doesn't handle fancy pluralization between
model and controller -- the default is simply to add an "s"
to your resource name to use for the plural in controller
names and paths.

However, you can specify different singular/plural names when
generating your resource. Separate the singular and plural
names by a comma, like this:

    mde@localhost:~/work/bytor$ geddy-gen resource person,people
    [ADDED] ./app/models/person.js
    [ADDED] ./app/controllers/people.js
    resources people route added to ./config/router.js
    Created view templates.

### App layout

After adding a resource, a Geddy app is laid out like this:

    mde@localhost:~/work/bytor$ find .
    .
    ./config
    ./config/config.js
    ./config/router.js
    ./app
    ./app/controllers
    ./app/controllers/snow_dogs.js
    ./app/controllers/main.js
    ./app/controllers/application.js
    ./app/views
    ./app/views/snow_dogs
    ./app/views/snow_dogs/show.html.ejs
    ./app/views/snow_dogs/add.html.ejs
    ./app/views/snow_dogs/index.html.ejs
    ./public

### Resources and controllers

Geddy's resource-based routes create url/request-method mappings
for easy CRUD operations like this:

GET */snow_dogs*<br/>
(SnowDogs controller, index action)
{'fraction_non_alphanumeric': 0.10913335278669391, 'fraction_numerical': 0.006711409395973154, 'mean_word_length': 3.4055269922879177, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2680602', 'n_tokens_mistral': 2223, 'n_tokens_neox': 2131, 'n_words': 717}