View on GitHub

Froyo

A simple, micro-framework for Node.js.

Download this project as a .zip file Download this project as a tar.gz file

Froyo

Node.js Micro Awesomeness

froyois a simple, expressive node.js micro-framework.

Install

With npm:

npm install froyo

Install from source:

git clone git://github.com/PyScripter255/frozen-yogurt.git
cd frozen-yogurt
npm install

Example

var froyo = require("froyo")
var app = froyo.app();

var thePosts = {
    "bob": ["Froyo is cool", "Have you tried it?"],
    "joe": ["Really?", "Nope"]
}

function givePosts(req, res){
    res.writeHead(200, {"Content-Type": "text/json"})
    res.end(JSON.stringify(thePosts))
}

function index(req, res){
    res.render("./index.html", {lasestPost: "foobar"}) // using the default mustache templates
}

var postComment = {
    post: function(req, res){
        res.writeHead(200, {"Content-Type": "text/json"})
        var comment = "";
        req.on("data", function(data){
            var comment += data;
        })
        req.on("end", function(){
            posts[req.params.post].addComment(JSON.parse(comment))
        })
        }
}

app.scoop({
    "/": index,
    "/posts": givePosts,
    "/comment/:post": postComment
})

app.start(8080);

License

The MIT License

Tutorial

here