Packet-Oriented Framework for ES6 and Express.


Packet-Oriented Framework for ES6 and Express.

##Table of Contents:

ECMAScript 6

rode.js framework is a stable way to use ES6 today. ES6 support is provided by traceur, es6-shim and es6-module-loader.

rode.js is based on Express, but we not rewrite it, you can still using all the features of Express.

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]


  -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 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>


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


In a model you should add all your business logic:

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


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

A controller looks like:

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 route for the above controller looks like:

import { Router } from 'rode/loader';
var router = new Router();
 * [GET] /
 * Calls HelloController.sayHello
  controller: 'Hello', // defaults 'Main' 
  pattern: '/hello',
  action: 'sayHello',
  method: 'GET' // defaults 'GET' 
export {router};

Middleware on Routes

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

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

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:

// [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

Templates engines

rode.js supports all this templates engines:


You can run the test with the command:

$ grunt test