0.0.9 • Published 10 years ago

eng v0.0.9

Weekly downloads
6
License
ISC
Repository
github
Last release
10 years ago

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 example project: tester
$ eng install // and follow instruction

Next Run Project:

# cd into the new folder example project: tester
$ cd tester

# fire up the server
$ eng run // or node server.js

Removing Project:

$ eng uninstall project_name

MVC Controller

Application/Controll/home.js:

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

Create Controller Project:

$ eng create-controller // and follow instruction example: test

Eng will generate code:

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

Create any method:

	exports.test = {
		
		test_index: function(){
			this.setContent("Hello World");
		}
		
		test_second: function(){
			this.setContent("Hello World second");
		}
		
	};
	
	// run: http://localhost:8080/test/second/

Create __construct:

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

Create autoload Model & Library:

	exports.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();
		},
		
		test_index: function(){
			this.setContent( this.name +" "+ this.mylib );
		}
		
	};
	
	
	// Create Model in Application/Model/user.js
	exports.user = {
		getUserName: function(){ return 'ukungzulfah'; }
	};
	
	
	// Create Library in System/Lib/libs.js
	exports.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:

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

Example Call Model from Controller:

	exports.test = {
		
		test_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:

	exports.test = {
		
		test_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

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago