# rode

> Packet-Oriented Framework for ES6 and Express.

Latest version **0.3.4** (published 2014-05-11) · 0 weekly downloads

## Install

```sh
npm install rode
pnpm add rode
yarn add rode
bun add rode
```

Provides the commands `rode`, `rode-new`, `rode-generate`.

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.4 |
| Published | 2014-05-11 |
| First published | 2013-11-11 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 18 |
| Known vulnerabilities | 0 (+15 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 46 |
| Author | Mariano Pardo |
| Maintainers | marianopardo |
| Keywords | framework, boilerplate, mvc, express, es6, rest, restful, model, controller |

## Links

- npm: https://www.npmjs.com/package/rode
- Repository: https://github.com/codexar/rode
- Issues: https://github.com/codexar/rode/issues
- npm.io page: https://npm.io/package/rode

## Dependencies (18)

- [hjs](https://npm.io/package/hjs.md) 0.0.x
- [jade](https://npm.io/package/jade.md) 1.x.x
- [extfs](https://npm.io/package/extfs.md) 0.x.x
- [prfun](https://npm.io/package/prfun.md) 0.1.x
- [mkdirp](https://npm.io/package/mkdirp.md) 0.5.x
- [string](https://npm.io/package/string.md) 1.8.x
- [stylus](https://npm.io/package/stylus.md) 0.x.x
- [express](https://npm.io/package/express.md) 4.x.x
- [request](https://npm.io/package/request.md) 2.34.x
- [soynode](https://npm.io/package/soynode.md) 0.3.x
- [traceur](https://npm.io/package/traceur.md) 0.0.32
- [es6-shim](https://npm.io/package/es6-shim.md) 0.10.x
- [mongoose](https://npm.io/package/mongoose.md) 3.8.x
- [commander](https://npm.io/package/commander.md) 1.x.x
- [ejs-locals](https://npm.io/package/ejs-locals.md) 1.0.x
- [underscore](https://npm.io/package/underscore.md) 1.x.x
- [less-middleware](https://npm.io/package/less-middleware.md) 1.0.x
- [es6-module-loader](https://npm.io/package/es6-module-loader.md) 0.6.x

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 0.3.4 (latest) — 2014-05-11
- 0.3.3 — 2014-04-22
- 0.3.2 — 2014-04-15
- 0.3.1 — 2014-04-11
- 0.3.0 — 2014-04-11
- 0.2.12 — 2014-03-23
- 0.2.11 — 2014-03-16
- 0.2.10 — 2014-03-16
- 0.2.9 — 2014-03-16
- 0.2.8 — 2014-03-14
- 0.2.7 — 2014-03-09
- 0.2.6 — 2014-03-09
- 0.2.5 — 2014-03-08
- 0.2.4 — 2014-03-07
- 0.2.3 — 2014-03-04
- … 31 more at https://npm.io/package/rode/versions

## README

rode.js
====

Packet-Oriented Framework for [ES6](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts) and [Express](http://expressjs.com).

##Table of Contents:

- [ECMAScript 6](#es6)
- [Getting started](#getting-started)
- [Packages](#packages)
- [Models](#models)
- [Controllers](#controllers)
- [Routes](#routes)
- [Middleware on Routes](#middleware-routes)
- [Restful APIs](#restful-apis)
- [Templates engines](#templates-engines)
- [Tests](#tests)


## <a name="es6"></a>ECMAScript 6

rode.js framework is a stable way to use [ES6](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts) today.
[ES6](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts) support is provided by [traceur](https://npmjs.org/package/traceur), [es6-shim](https://npmjs.org/package/es6-shim) and [es6-module-loader](https://npmjs.org/package/es6-module-loader).

rode.js is based on [Express](http://expressjs.com), but we not rewrite it, you can still using all the [features of Express](http://expressjs.com/4x/api.html).


## <a name="getting-started"></a>Getting started

Install rode.js globally and generate a new project:

    # npm install -g rode
    $ rode new --view ejs --css less --sessions myProject

Install project dependencies:

    $ npm install

Start the server:

    $ node app

Usage of `rode new`:

    Usage: rode new [options] [dir]

    Options:

      -h, --help          output usage information
      -V, --version       output the version number
      -v, --view          add view engine support (jade|ejs|hogan|soy) (defaults to jade)
      -c, --css           add stylesheet support (less|stylus|css) (defaults to plain css)


## <a name="packages"></a>Packages

A package (or bundle) is a component of your application with its own MVC.

You can simply create a new package with the command:

    $ rode generate PackageName

    Usage: rode generate package <package>

    Options:

      -h, --help   output usage information
      -r, --rest   config rest api for this package
      -f, --force  force on existing package


## <a name="models"></a>Models

In a model you should add all your business logic:

```js
import { Model } from 'rode/loader';

export class MyModel extends Model {

  /**
   * Sample method, converts a string to upper case
   */
  sampleMethod(str) {
    return str.toUpperCase();
  }

}
```

You can generate a Model `myModel` for a package `User` with the command:

    $ rode generate User:model myModel


## <a name="controllers"></a>Controllers

Controllers and Routes works together to facilitate the routing of the application.

A controller looks like:

```js
export class HelloController {

  /**
   * sayHello Action
   */
  sayHello(req, res) {
    res.render('index', {
      title: 'Hello World!'
    });
  }

}
```

You can generate a Controller `myController` for a package `User` with the command:

    $ rode generate User:controller myController


## <a name="routes"></a>Routes

A route for the above controller looks like:

```js
import { Router } from 'rode/loader';
var router = new Router();

/**
 * [GET] /
 * Calls HelloController.sayHello
 */
router.add({
  controller: 'Hello', // defaults 'Main'
  pattern: '/hello',
  action: 'sayHello',
  method: 'GET' // defaults 'GET'
});

export {router};
```


## <a name="middleware-routes"></a>Middleware on Routes

Here's an example of how to define a middleware on routes:

```js
export class UserController {
  showPrivateData() {
    return [
      (req, res, next) => {
        // Check permissions
        next();
      },
      (req, res) => {
        // Show Private Data
      }
    ];
  }
}
```


## <a name="restful-apis"></a>Restful APIs

Make a Restful API can not be more easy.

Create your REST package with the command:

    $ rode generate package PackageName --rest

Or add `router.restApi = '/api/products';` on the `routes.js` of any package.

Now you should create methods on your `RestController.js` following simple naming conventions.

Here are some examples:

```js
// [GET] /api/products
get(req, res) { ... }

// [POST] /api/products
post(req, res) { ... }

// [GET] /api/products/sponsored
getSponsored(req, res) { ... }

// [PUT] /api/products/sponsored
putSponsored(req, res) { ... }

// [POST] /api/products/sponsored/today
postSponsoredToday(req, res) { ... }

// [GET] /api/products/:id
getById(req, res) { ... }

// [POST] /api/products/:id
postById(req, res) { ... }

// [DELETE] /api/products/:id
deleteById(req, res) { ... }

// [GET] /api/products/:id/comments
getByIdComments(req, res) { ... }

// [PUT] /api/products/:id/comments/:id2
putByIdCommentsById(req, res) { ... }
```

You can create as many combinations as you like.
Remember that each package can have its own `RestController.js`


## <a name="templates-engines"></a>Templates engines

rode.js supports all this templates engines:

* [Jade](http://jade-lang.com/) (default template)
* [Ejs](http://embeddedjs.com/) (using [ejs-locals](https://github.com/RandomEtc/ejs-locals))
* [Hogan.js](http://twitter.github.io/hogan.js/)
* [Google Closure Templates](https://developers.google.com/closure/templates/)
* Since you still can use express, you can use any template that express support


## <a name="tests"></a>Tests

You can run the test with the command:

    $ grunt test


## License

[MIT](https://github.com/codexar/rode/blob/master/LICENSE)

---
_Source: https://npm.io/package/rode · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
