eng

0.0.9 • Public • Published

eng

Eng Engine is a framework that uses the concept of MVC node.js

Installation

With node:

# Get the latest stable release of Eng 
$ sudo npm install eng -g // require -g

Your First Eng Project

Create a new Project:

# Create the app 
$ eng install // and follow instruction

Next Run Project:

# cd into the new folder 
cd tester
 
# fire up the server 
$ eng run // or node server.js

Removing Project:

$ eng uninstall project_name

MVC Controller

Application/Controll/home.js:

    export.home = {
        
        home_index: function(){
            this.setContent("Hello World");
        }
        
    };
    
    // run: http://localhost:8080/home/ or http://localhost:8080/

Create Controller Project:

$ eng create_controller // and follor instruction example: test

Eng will generate code:

    export.test = {
        
        home_index: function(){
            this.setContent("Hello World");
        }
        
    };
    
    // run: http://localhost:8080/test/

Create any method:

    export.test = {
        
        home_index: function(){
            this.setContent("Hello World");
        }
        
        home_second: function(){
            this.setContent("Hello World second");
        }
        
    };
    
    // run: http://localhost:8080/test/second/

Create __construct:

    export.test = {
        
        name: '',
        
        __construct: function(){
            this.name = 'ukungzulfah';
        },
        
        home_index: function(){
            this.setContent("Hello " + this.name);
        }
        
    };
    
    // run: http://localhost:8080/test/

Create autoload Model & Library:

    export.test = {
        
        name: '',
        mylib: '',
        
        include: [
            {
                type'lib', // library autoload
                name: 'libs'
            },
            {
                type'model', // Model autoload
                name: 'user'
            }
        ],
        
        __construct: function(){
            this.name = this.user.getUserName();
            this.mylib = this.libs.getLibName();
        },
        
        home_index: function(){
            this.setContent( this.name +" "+ this.mylib );
        }
        
    };
    
    
    // Create Model in Application/Model/user.js
    export.user = {
        getUserName: function()return 'ukungzulfah'; }
    };
    
    
    // Create Library in System/Lib/libs.js
    export.libs = {
        getLibName: function()return 'ukungzulfah'; }
    };
    
    // run: http://localhost:8080/test/

MVC Model

Create function for transaction with database [ mysql / mongodb / etc ] with modul from node.js and create function here

Create Example Model: Application/Model/user.js:

    export.user = {
        getUserName: function()return 'ukungzulfah'; }
    };

Example Call Model from Controller:

    export.test = {
        
        home_index: function(){
            var self=this;
            self.model('user'function(){
                self.setContent( self.user.getUserName() );
            });
        }
        
    };

MVC View

Create view in format html in folder Application/View/ .html: and you can include ejs here:

Create View Example: Application/View/index.html:

    <html>
    
        <head>
            <title> <%= title %> </title>
        </head>
        
        <body>
            <h1> <%= body %> </h1>
        </body>
        
    </html>

Example Call View from Controller and send data to View:

    export.test = {
        
        home_index: function(){
            var self=this;
            var data = {
                title: "Eng MVC Node.js",
                body: "Hello World"
            };
            
            self.view('index', function(content){
                self.setContent( content );
            }, data);
        }
        
    };

Group on G+   Follow Twitter

Thanks to Nodejs

Ukungzulfah

Readme

Keywords

Package Sidebar

Install

npm i eng

Weekly Downloads

4

Version

0.0.9

License

ISC

Last publish

Collaborators

  • ukungzulfah