node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…


Sulphur =======


Sulphur is a simple web framework for Node.js.

S = require('sulphur')
app = new S.Application()

# GET /
app.get (req, res) ->
    res.send('Hello, world!')

# GET /api/users/
app.get 'api', 'users', (req, res) ->
    users = [
        {username: 'aardvarrk', age: 17},
        {username: 'john', age: 18}

# POST /posts/42/comments/ 'posts', ':id', 'comments', (req, res) ->
    post_id = req.parameters['id']
    # TODO: Save comment.
    res.send('Comment posted!')

The default router takes a variable number of arguments. If you prefer it to take one argument that is a /-separated string, you can use a custom router like this:

S = require('sulphur')

class Router extends S.Router
    addRoute: (method, path, handler) ->
        segments = (segment for segment in path.split('/') when segment != '')
        super(method, segments..., handler)

app = new S.Application({router: new Router()})

# GET /posts/:id/comments/
app.get '/posts/:id/comments/', (req, res) ->
  • Call rendering engine.
    • Provide an interface for rendering engines.
  • Server static files.