node package manager
Painless code sharing. npm Orgs help your team discover, share, and reuse code. Create a free org ยป


ALAJS Get Started

ALAJS is a simple mvc framework based on koa.Thank you very much, you are a great middle framework!

1. Install

1. npm install alajs --save          
2. npm -g install node-dev     

2. Create app.js file and require alajs

var alajs = require('alajs');

3. Define an App

App = alajs({           /*please set the App to gobal*/
	name 		: 	'ALABLOG',
	databases	: 	{
		default:  'mysql:root@localhost/test',
		log 		: 'mongodb://localhost/test'
	models 		: 	['/share/models']

4. Define a module

	name 			:   'root',
	url 			: 	'/',
	path 			: 	'/app',
	controllers		: 	['/controllers','/otherCtrls'],
	staticResources : 	'/static',

5. Set default module


6. Define a server

var server = App.define.server({port:3000});

7. Load App to server


8. Startup server


9. Create a welcome.js file in controllers folder and define a controller

var welcome = App.define.controller({name:'welcome',url:'/welcome'})

10. Define an action function for response

welcome('you',function *(next){

	this.body = 'You are welcome!'


11. Start this app

node-dev --debug --harmony app.js

12. Visit http://localhost:3000/welcome/you