0.2.0 • Published 9 years ago

fileproxy v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

node-fileproxy

Build Status

A simple HTTP proxy for serving static files

Installation

  $ [sudo] npm install fileproxy

Usage

Using http

fileproxy.server()

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

var host  = 'https://raw.githubusercontent.com';

var server = http.createServer(function(request, response) {
  fileproxy.serve(host, request, response, function(result, error) {
    console.log(result);
  });
});

server.listen(8000);

Using Expressjs

fileproxy.serverExpress

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

var app   = express();
var host  = 'https://raw.githubusercontent.com';

app.route('/:user/:repo/:branch/*').get(
  fixy.serveExpress(host, function(result, error) {
    console.log(result);
  })
);

app.listen(8000);

Callback is optional. It will return http response status and mime type for result, and http response status for error.

Open http://localhost:8000/MidEndProject/node-fileproxy/master/README.md in your browser. You will see a README file that gets from https://raw.githubusercontent.com/indexzero/node-portfinder/master/README.md. Note that node fileproxy will return file with mime type based on its file extension, so use it only for proxying a static file.

To Do

  • Koa

Maintainer

Fitra Aditya

License

MIT