News for hackers. Stuff that matters.
Re:Berliner: Sinatra like Framework written in 16 lines of C... by whalesalad on Wednesday August 22, 2012 @10:56AM (#4417631)
I'm disappointed that this is mostly a joke. I really like the docs and have been looking for something along these lines lately.
Re:Berliner: Sinatra like Framework written in 16 lines of C... by danneu on Wednesday August 22, 2012 @11:20AM (#4417777)
Zappa[0] is a cool Coffeescript wrapper around Express. Unfortunately, Maurice Machado[1] dropped off the radar last October so some other people stepped in to maintain it at https://github.com/zappajs/zappajs.

Maurice also wrote Coffeekup[2] (a Coffeescript Jade) which has also been taken over by the community as a project called Coffeecup[3].

(Sincerely hope Maurice is ok. He was real active and put a lot of effort into his projects up until his disappearance.)

    [0]: http://zappajs.org/docs/crashcourse/
    [1]: http://twitter.com/mauricemach
    [2]: http://coffeekup.org/ && https://github.com/mauricemach/coffeekup
    [3]: https://github.com/gradus/coffeecup
Re:Berliner: Sinatra like Framework written in 16 lines of C... by grncdr on Wednesday August 22, 2012 @02:55PM (#4418950)
Warning: shameless self-promotion ahead:

   db = require('./your_sexy_data_access_module')
   server = require('lazorse').server port: 3000, ->
     # in this context we register resources the app using @resource
     @resource '/things/{thingId}':
       shortName: "Things"
       GET: ->
         db.getThing @thingId, @data
       POST: ->
         db.getThing @thingId, (err, thing) =>
           return @next(err) if err
           thing.update(@req, @data)
Where @data is node-style callback function taking (err, data), and the data will be rendered by a separate middleware layer that inspects Accept headers and does the Right Thing.

There's a lot more than should be covered in an HN comment, but in interest of DRYing out the above example, let's rewrite it to use a coercion to retrieve "thing" instances.

   db = require('./your_sexy_data_access_module')
   server = require('lazorse').server port: 3000, ->

     @coerce 'thing', "Things are whatever this app deals in", db.getThing

     @resource '/things/{thing}':
       shortName: "Things"
       GET: ->
         # Use @ok because we won't get here if there was an error retrieving
         # the thing
         @ok @thing
       POST: ->
         @thing.update @req, @data
 
See http://betsmartmedia.github.com/Lazorse for full API docs and examples. Bug reports, pull requests, flame comments etc. are all very welcome :)
Re:Berliner: Sinatra like Framework written in 16 lines of C... by gee_totes on Wednesday August 22, 2012 @11:45AM (#4417918)
Yeah, the thing that gave it way for me was: * Since this is such a small module, it’s almost certainly bug-free
Re:Berliner: Sinatra like Framework written in 16 lines of C... by KaoruAoiShiho on Wednesday August 22, 2012 @11:18AM (#4417767)
? What's wrong with express?
Re:Berliner: Sinatra like Framework written in 16 lines of C... by whalesalad on Wednesday August 22, 2012 @12:49PM (#4418268)
Do you know how much boilerplate crap is required before you can do hello world with express?
Re:Berliner: Sinatra like Framework written in 16 lines of C... by secoif on Wednesday August 22, 2012 @02:21PM (#4418777)
>Do you know how much boilerplate crap is required before you can do hello world with express?

This much:

var app = require('express')(); app.get('*', function(req, res) { res.send('hello world'); }); app.listen(8080);

Hello world probably a bad example.