JSPM

  • Created
  • Published
  • Downloads 91
  • Score
    100M100P100Q75299F
  • License MIT

Deliver local and remote static files

Package Exports

  • deliver

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (deliver) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

deliver

Deliver local and remote static files.

Install

npm install deliver --save

Usage

Local file

var deliver = require('deliver');
var http = require('http');

http.createServer(function (req, res) {
  // Conditionally set the request url
  req.url = '/some';
  
  deliver(req).pipe(res);
  
}).listen(3000);

Remote file (proxy)

var deliver = require('deliver');
var http = require('http');

http.createServer(function (req, res) {
  // Conditionally set the request url
  req.url = 'http://www.somewhere.com/somefile.html';
  
  deliver(req, {
    statusCode: 404
  }).pipe(res);
  
}).listen(3000);

deliver(path[, options])

Returns a stream

  • path - the path, relative or an http url, of the file to server
  • options
    • root - set the root directory that holds the static files to serve
    • statusCode - set the response status code. Overrides when proxying a remote file

Run Tests

npm install
npm test