0.0.9 • Published 12 years ago

tubing-view v0.0.9

Weekly downloads
12
License
-
Repository
github
Last release
12 years ago

tubing-view

View Pipeline

Installation

npm install tubing-view

Usage

var mime = require('mime')
  , http = require('http')
  , ViewPipeline = require('tubing-view').ViewPipeline;

var pipeline = ViewPipeline.configure({
  path: {
    content: process.cwd() + '/content'
  }
}).publish_to(function(err, cmd) {
  function write_res(code, content, content_type) {
    cmd.res.writeHead(code, {
      'Content-Type': content_type ? mime.lookup(content_type) : 'text/plain',
      'Content-Length': content.length
    });
    cmd.res.end(content);
  }
  
  if (err) return write_res(500, err.stack);
  if (!cmd.content) return write_res(404, 'Not Found');
  
  write_res(200, cmd.content, cmd.content_type);
});

http.createServer(function(req, res) {
  pipeline.push({
    req: req,
    res: res
  });
}).listen(3000);

License

Copyright (c) 2013 Matt Insler Licensed under the MIT license.

0.0.9

12 years ago

0.0.8

12 years ago

0.0.7

12 years ago

0.0.6

12 years ago

0.0.5

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago