by Kilimanjaro · 15y ago · 0 comments
require session,models,template
function main(request,response){
session.start()
data = models.getEntries()
html = template.render('blog',data)
response.write(html)
}
Can not be simpler, hide all complexities from the coder so he can concentrate on building apps, not fighting with code.Ryan was developing Node for certain use cases. He chose the name "Node" because it was supposed to be a small piece of a larger web app. A few nested callbacks, programs that have a few hundred lines of code and don't have complex control flows work well. Hype created a large community which is pushing beyond such narrow goals. But it will take time to come up with good DSLs or add continuations to V8. For now the best solution is to learn how to organize async code, for which I've only seen one trivial example.
var app = express.Application(); // let me create apps, not servers
app.get('/', app.do('index',req,res));
app.run(); // set port in config.js
I'll keep an eye on express.(I'm not a CS guy, I just wanted to finish a digital art project involving buses and geolocation).
var session = require('session'),
models = require('models'),
template = require('template');
function main(request,response){
session.start(
models.getEntries.bind(models,
template.render.bind(template, 'blog',
response.write.bind(response))));
}
would be easy to put together with node.js; it's functionally equivalent to the above (though it assumes that data comes into the template.render call as the last argument(s)), and neatly avoids too much nesting. data = models.getEntries()
html = template.render('blog',data)
I may be wrong, but these two lines has to be blockingSorry for pointing the obvious;