Docs - rudimk/neu-berliner GitHub Wiki
Welcome to the neu-berliner wiki!
Hello World
app = require 'neu-berliner'
app.get '/', -> 'Hello, world!'
app.run 4567
Pretty simple, as you can see. Here's how you can define settings, for your web app:
app.public = __dirname + '/public' # static files
app.views = __dirname + '/views' # view templates
app.session_secret = 'mhfg354xvcs' # key for encrypting sessions
app.get '/confs/:name', ->
JSON.stringify @params
app.put '/confs/:name', (name) ->
name
app.get '/download/*.*', ->
@params.splat.join ', '
app.post '/confs', ->
@status 201
@headers 'Content-Type': 'application/json'
JSON.stringify @params
app.get '/legacy', ->
@redirect '/hello'
app.options '/', ->
@headers
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, PUT, DELETE'
@render ''
And here's how the code above, would respond to requests thrown with cURL:
$ curl 'localhost:4567/confs/eurucamp?bears=awesome'
{"name":"eurucamp","bears":"awesome"}
$ curl -X PUT localhost:4567/confs/jsconf
jsconf
$ curl localhost:4567/download/foo.js
foo, js
$ curl -iX POST localhost:4567/confs -d 'horses=fake'
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 17
Set-Cookie: session=XABfKjq2xvCavSitaxu0BC9XSl...; Path=/; HttpOnly
Connection: keep-alive
{"horses":"fake"}
$ curl -i localhost:4567/legacy
HTTP/1.1 303 See Other
Location: /hello
Connection: keep-alive
Transfer-Encoding: chunked
$ curl -iX OPTIONS localhost:4567/
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, PUT, DELETE
Connection: keep-alive
More docs coming up very soon!