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 🙏

© 2025 – Pkg Stats / Ryan Hefner

genie-express

v0.2.5

Published

A framework for express

Downloads

26

Readme

genie

Build Status

Genie is framework for Express3.x based to Klass.

Installation

Get the CLI

$ npm install genie-express -g

Quick Start

Create an app

$ genie create my-app
$ cd my-app $$ npm install genie-express

Start your app

$ node server.js

Scaffold

$ genie controller [name]
$ genie model [name]
$ genie service [name]
$ genie factory [name]

Examples

Controller

module.exports = function (app, config) {
  var ApplicationController = app.getController("Application", true);
  var IndexController = ApplicationController.extend(function(){
    this.routes = {
      "index" : "/"
    };
    this.addBeforeAction("action", function(res, req, next){
      var CheckFactory = app.getFactory("Check");
      CheckFactory.start(res, req, next);
    });
    this.addBeforeAction("get", function(res, req, next){
      var CheckFactory = app.getFactory("Check");
      CheckFactory.start(res, req, next);
    });
    this.addBeforeAction("get", function(res, req, next){
      var CheckService = app.getService("Check");
      CheckService.start(res, req, next);
    });
  }).methods({
    getIndex : function(req, res){
      res.render("index", {
        title : "Hello, Genie"
      });
    },
  });
  return IndexController;
}

Model

'use strict';
module.exports = function(app){
  var ApplicationModel = app.getModel('Application', true);
  var CheckModel = ApplicationModel.extend(function(){
    this.app = app;
    this.modelName = "Check";
    this.rooms = ['Apple', 'Orange', 'Grape'];
  }).methods({
    getRoom : function(id){
      console.log(this.rooms);
      return this.rooms[id];
    }
  });
  return CheckModel;
};

Service

'use strict';
module.exports = function(app){
  var ApplicationService = app.getService('Application', true);
  var CheckService = ApplicationService.extend(function(app){
    this.app = app;
    this.serviceName = "Check";
    this.config = this.Config();
    this.num = this.config.num;
  }).methods({
    start : function(req, res, next){
      this.supr();
      console.log("service: "+ this.num++);
      next();
    }
  });
  return CheckService;
};

Factory

'use strict';
module.exports = function(app){
  var ApplicationFactory = app.getFactory('Application', true);
  var CheckFactory = ApplicationFactory.extend(function(){
    this.factoryName = "Check";
    this.num = 0;
  }).methods({
    start : function(req, res, next){
      this.supr();
      console.log("factory: "+ this.num++);
      next();
    }
  });
  return CheckFactory;
};

View

Uses Twig to render Template

<div id="title">{% block content %}{% endblock %}</div>
{% extends "layout.twig" %}
{% block content %}
{{ title }}
{% endblock %}

Routing

Routings are extract from method of controller.
Extract methods are GET, POST, PUT and DELETE.

get /index

getIndex : function(req, res){
  res.render("index", {
    title : "Get index"
  });
}

post /create

postCreate : function(req, res){
  res.render("index", {
    title : "Post create"
  });
}

Params are extract from property of controller.

get /test/member/:id

// controllers/test/TestController.js

module.exports = function (app, config) {
  var ApplicationController = app.getController("Application", true);
  var TestController = ApplicationController.extend(function(){
    this.params = {
      "member" : [":id"]
    };
  }).methods({
    getMember : function(req, res){
      res.render("index", {
        title : "Genie is "+req.params.id
      });
    },
  });
  return TestController;
}

In the case of a different method?

this.params = {
  "member" : {
    get : [":id"],
    post: [":test"]
  }
};

Routes change extract from property of controller.

get /test/

// controllers/test/TestController.js

module.exports = function (app, config) {
  var ApplicationController = app.getController("Application", true);
  var TestController = ApplicationController.extend(function(){
    this.routes = {
      "index": "/test/"
    };
  }).methods({
    getIndex : function(req, res){
      res.render("index", {
        title : "Genie is test"
      });
    },
  });
  return TestController;
}

Service and Factory

Service will create an instance for each call.

module.exports = function (app, config) {
  var ApplicationController = app.getController("Application", true);
  var TestController = ApplicationController.extend(function(){
    this.TestService = this.app.getService("Test");
  })
}

Factory will call the same instance.

module.exports = function (app, config) {
  var ApplicationController = app.getController("Application", true);
  var TestController = ApplicationController.extend(function(){
    this.TestFactory = this.app.getFactory("Test");
  })
}