GitXplorerGitXplorer
m

tako

public
317 stars
17 forks
14 issues

Commits

List of commits on branch master.
Unverified
1cee370c35d70cf4b67186ec23fe8ff2a9d673eb

Merge pull request #29 from lordnox/master

mmikeal committed 12 years ago
Unverified
6edd82a7893e2a6d059d7167e95201897eb02f48

it was not enough...

committed 12 years ago
Unverified
f601fc43aafba4f2c9a4b29cf58c95484bdbe6b2

fixed no content type for put & post

committed 12 years ago
Unverified
ba302507201da50d3eaaa1e5b815c59c6acd27cd

Merge pull request #27 from DamonOehlman/master

mmikeal committed 12 years ago
Unverified
82a31f388a6899dce899ee3154dc1a0d991f6ce9

Fixed body variable leak

committed 12 years ago
Unverified
3d05337f3840bffdf7fe4a612b1506ad11f839b0

Tweaked loop variables to prevent global scope leakage

committed 12 years ago

README

The README file for this repository.

tako -- Functional web framework.

Install

  npm install tako

Add Sockets

  npm install socket.io

Or from source:

  git clone git://github.com/mikeal/tako.git 
  cd tako
  npm link

Usage

var tako = require('tako')
  , request = require('request')
  , path = require('path')
  , app = tako()
  ;

app.route('/static/*').files(path.join(__dirname, 'static'))

app.route('/proxypass', function (req, resp) {
  req.pipe(request("http://otherserver.com"+req.url).pipe(resp))
})

app.route('/hello.json').json({msg:'hello!'})

app.route('/plaintext').text('I like text/plain')

app.route('/')
  .html(function (req, resp) {
    request('http://me.iriscouch.com/db', {json:true}, function (e, r) {
      if (e) return resp.error(e)
      if (r.statusCode !== 200) return resp.error(r)
      resp.end('<html><head>cool</head><body>'+r.body.index+'</body></html>')
    })
  })
  .methods('GET')
  ;

// Ported example from socket.io docs to show integration
app.sockets.on('connection', function (socket) {
  app.sockets.emit('news', { will: 'be received by everyone'});
  socket.on('disconnect', function () {
    app.sockets.emit('user disconnected')
  })
})
  
app.httpServer.listen(80)
app.httpsServer.listen(443)

Routing multiple domains

var tako = require('../index')
  , app1 = tako()
  , app2 = tako()
  , default = tako()
  , router = tako.router()
  ;
  
app1.route('/name').text('app1')
app2.route('/name').text('app2')
default.route('/name').text('default')

router.host('app1.localhost', app1)
router.host('app2.localhost', app2)
router.default(default)

router.httpServer.listen(80)
router.httpsServer.listen(443)