Jackson
Jackson is a web application framework for Node with a focus on simplicity, composability and ease of use, including the batteries you need to build everyday web applications.
Jackson is a new project under early development.
Quick-and-dirty example
Jackson is currently undocumented and you shouldn't use it yet for non-trivial/production sites.
Here is an example which outlines how routes, controllers and applications work in Jackson:
@route '/''Posts#index' @route '/posts''Posts#index' @route '/posts/:id''Posts#show' # or use shorthand to create a whole resource à la Rails # @resource('/posts', 'Posts') templateRoot: __dirname + '/templates' templateDir: 'posts' : -> @render'index.html'posts: Postall : @render'show.html'post: Postfindid @resource '/posts''Posts' : -> @respondPostall : if post = Postfindid @respondpost else @respond404 @route '/''Dashboard#overview' templateRoot: __dirname + '/admin_templates' @beforeAll 'authenticate' # contrived example, demonstrates before filters : -> if @reqip isnt '127.0.0.1' @respond403'Local only.' true : -> @render 'overview.html' blog = blogmount '/api'blogmount '/admin' bloglisten1234
Command-line interface
Jackson has a neat command line interface, with the jack
command.
Create a new application:
$ jack new MyApp
$ cd my_app/
Pass --js
to jack new
if you would prefer not to use CoffeeScript.
Start the application:
$ jack server
This is the default command, so you can just use:
$ jack
.
The default Jackson port is 1234. Pass another like jack --port 5858
You can also listen on a Unix socket with jack --socket /tmp/myapp.socket
Application REPL!
You can drop into a REPL with your application loaded:
$ jack repl
('r' for short)
Your app is available as app
. You'll also have Jackson
and your application class defined.
If you want to expose more to the REPL, add stuff too app.repl like:
app.repl.greet = -> 'hello'
When in the REPL, you'll be able to use greet()
.