Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including alajs with all npm packages installed. Try it out:

var alajs = require("alajs")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

alajs v2.0.3

nodeJs mvc framework

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

App.define.module({
    name            :   'root',
    url             :   '/',
    path            :   '/app',
    controllers     :   ['/controllers','/otherCtrls'],
    staticResources :   '/static',
})

###5. Set default module

App.define.defaultModule('root');

###6. Define a server

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

###7. Load App to server

server.loader(App);

###8. Startup server

server.bootstrap();

###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

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free