express-override

0.1.9 • Public • Published

Express-Override

Express の拡張プラグインです。(Version2.5.x & 3.x.x) Expressをベースに新たにフレームワークを作成するのではなく、Expressのまま使用する為の最低限のライブラリ群です。 現在のバージョン0.1.xでは、

  • routesで実行するモジュールのファイル分割 (handlers)
  • 全handlersで使用出来るグローバルオブジェクトの提供
  • klass.js の使用によるhandlers/modelsの継承

のみの機能です。

Installation

基本仕様はexpressコマンドにより、アプリケーションのベースファイルが作成された後に実行される事を想定しています。 eorコマンドの引数にはexpressコマンドの引数と同じ物を指定すると、sampleファイルがすぐに使用出来る様になります。

$ npm install -g express-override 

Quick Start

Initialize

$ eor [same options]
$ npm install -d

or

$ eor [same options]
$ npm install express-override

Run

$ node eor-sample-app.js

Browser

http://localhost:3000
http://localhost:3000/hello

Other

Expressのバージョンを指定する事でサンプルファイル(eor-sample-app.js)をExpressのバージョンに合わせて作成します。 デフォルトではVersion2。

$ eor -x 2

OR

$ oer -x 3

Example

/handlers/SampleHandlers.js

module.exports = function(eor){
  return eor.define("Application").extend(function(){
    this.title = "Express Override";
  })
  .methods({
    index : function(req, res) {
      var sampleModel = eor.getModule("Sample", "Model");
      if(sampleModel.index()){
        res.render('index', { title: this.title })
      }else{
        res.render('index', { title: this.title, error_message : "ErrorCode => -1111"});
      }
    },
 
    hello : function(req, res) {
      res.render('index', { title: eor.shared.name })
    }
  })
};

/models/SampleModel.js

module.exports = function(eor){
  return eor.define("Application", "Model").extend(function(){
    this.myName = "SampleModel";
  })
  .methods({
    index : function(){
      return this.myName == "SampleModel";
    }
  });
};

今後のアップデート方針

Expressを使用したアプリケーションで車輪の再開発を防ぐ事を目的としたscaffold機能や、 Expressのバージョン互換吸収等を目的に更新して行きます。

Readme

Keywords

none

Package Sidebar

Install

npm i express-override

Weekly Downloads

6

Version

0.1.9

License

BSD

Last publish

Collaborators

  • Kyohei Ueshiba