Skip to content
Projets

À propos

Framework web fonctionnel.

Développement web et applicatif

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

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)

Explorer des projets similaires

Chargement…