npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rode

v0.3.4

Published

Packet-Oriented Framework for ES6 and Express.

Downloads

66

Readme

rode.js

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]

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)

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

Models

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

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

Routes

A route for the above controller looks like:

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

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
        next();
      },
      (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:

Tests

You can run the test with the command:

$ grunt test

License

MIT