オートダフェ

Autodafe -node.js Webアプリケーション開発フレームワーク



記事の内容には、無関係なコードが記述されている場合があります。 このフレームワークには長い間独自のサイトautodafe.wsがありました



すぐに使える最もおいしいパン:





軟膏で飛ぶ:









ハローワールド





次に、サイトのルートを入力するときに1ページのみを表示し、その他の場合は404エラーを表示するアプリケーションを作成するプロセスについて説明します。 主な目標は、読者にAutodafeのアプリケーションの構成を少し紹介することです。



手順1.ファイル構造を準備します。





はい、現在このステップは自動化されていません。



hello_worldプロジェクトのディレクトリに名前を付けます。これは、最も単純なアプリケーション用のディレクトリです。



 / hello_world
   / configここに構成ファイルを保存します
     /main.js 1つで十分です
   /ここにコントローラーを追加し、卓越したアプリケーションのロジックを決定するコントローラーを追加します
     /site.js単一ページの単一アクションを持つ唯一のコントローラー
   /ビューのビュー場所
     /index.htmlメインページビュー
   /index.js入力スクリプト




ステップ2. Autodafeをインストールする





 cd hello_world
 npm install autodafe




通常、すべてが非常にスムーズに進みます))(フェドラ、ミントでテスト済み)



ステップ3.ファイルごと



入力スクリプトindex.js



その中で、構成ファイルautodafeを接続するだけでなく、アプリケーションを作成して実行します。



var config = require( './config/main' ); var autodafe = require( 'autodafe' ); autodafe.create_application( config ).run();
      
      







Main.js構成ファイル





 module.exports = { //   (       ) name : 'hello_world', //   ,        , , , // ,           base_dir : require('path').join( __dirname, '..' ), //  ,         Application.get_param params : { your_name : 'Andrey' //         }, //          router : { rules : { '/' : 'site.index' } }, //    components : { // http  http : { port : 3000 } } };
      
      







Site.jsコントローラー





  //   Controller module.exports = Site.inherits( global.autodafe.Controller ); /** *     ,        */ function SiteController( params ) { this._init( params ); } /** *   .      router.rules      */ SiteController.prototype.index = function ( response, request ) { //    index.html    response.send({ name : this.app.params['your_name' ] } ); };
      
      







最後に、ビューindex.html



注意する必要があるのは、コントローラーから渡される{name}パラメーターのみです。 Autodafeはダストを使用してレンダリングします

 <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>Autodafe hello world</title> </head> <body> <h1>Hello {name}!</h1> </body> </html>
      
      







打ち上げ



 node index.js


そして、ブラウザでlocalhost:3000に移動します



フレームワークの詳細情報の入手先



ウェブサイトautodafe.ws

githubのソースコード: autodafe 、そこに3つの小さなデモがあります+ common_config.jsファイルには、すべてのコンポーネントを最大限に使用してアプリケーションをセットアップする例を見ることができます

Twitterフレームワーク@node_autodafeをフォローする



開発に参加したい場合、または何らかの方法でフレームワークの開発を支援したい場合は、PMまたはgmail.comのjifeonに書き込みます。



All Articles