Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

streaming http + file routing proxy. serve apps with node point javascript!

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 node_modules
Octocat-spinner-32 test
Octocat-spinner-32 defaults.js
Octocat-spinner-32 index.js
Octocat-spinner-32 package.json

serve apps with node point javascript! uses the unreleased streaming web framework codenamed tako

all you need is a folder full of static assets and a little bit o' javascripts:

var tako = require('tako')
  , http = require('http')
  , path = require('path')
  , rewriter = require('rewriter')
  , rewrites = [ 
      { from:"/", to:'index.html' }

var t = tako()

rewriter(t, rewrites, { attachments: path.resolve(__dirname, 'attachments') })

t.listen(function(handler) {
  return http.createServer(handler)
}, 9999)

rewriter was built to work easily with couchdb! you can do things like serve couchapps from node and proxy to couch:

var couch = "http://localhost:5984"
  , rewrites = [ 
      {from:"/", to:'index.html'}
    , {from:"/api/couch", to: couch + "/"}
    , {from:"/api/couch/*", to: couch + "/*"}
    , {from:"/api", to: couch + "/appdatabase"}
    , {from:"/api/*", to: couch + "/appdatabase/*"}
    , {from:"/db/:id", to: couch + "/:id/"}
    , {from:"/db/:id/*", to: couch + "/:id/*"}

rewriter(t, rewrites)

there is also a shorthand for querying the couch view server (start to: with _ and pass in the design document URL):

var rewrites = [ 
    {from:"/api/applications/:dataset", to:"_view/applications", query:{endkey:":dataset", startkey:":dataset", include_docs:"true", descending: "true"}}
  , {from:"/api/applications", to:"_view/applications", query:{include_docs:"true", descending: "true"}}
  , {from:"/api/applications/user/:user", to:"_view/applications_by_user", query:{endkey:":user", startkey:":user", include_docs:"true", descending: "true"}}
  , {from:"/api/datasets/:user", to:"_view/by_user", query:{endkey: [":user",null], startkey:[":user",{}], include_docs:"true", descending: "true"}}
  , {from:"/api/datasets", to:"_view/by_date", query:{include_docs:"true", descending: "true"}}

rewriter(t, rewrites, {ddoc: "http://localhost:5984/mydataset/_design/mydesigndocument"})

MIT License

Something went wrong with that request. Please try again.