Giter Site home page Giter Site logo

harmon's Introduction

harmon

A middleware component for node-http-proxy using trumpet to parse and transform the response from the proxied server.

build status

npmico

harmon

install

$ npm install harmon

examples

Overview


In this example the HTML below is returned from the remote server and parsed:

<html>
	<head></head>
	<body>
		<div class="a">Nodejitsu Http Proxy</div>
		<div class="b">&amp; Frames</div>
	</body>
</html>

The following line is removed:

<div class="b">&amp; Frames</div> 

And is replaced with:

<div>+ Trumpet</div>

Run It!


from your project root:

$ cd node_modules/harmon/examples
$ node simple.js

Browse to localhost:8000 and you should see:

simple output

Code

var http = require('http'),
    connect = require('connect'),
    httpProxy = require('http-proxy');


    var selects = [];
    var simpleselect = {};

        simpleselect.query = '.b';
        simpleselect.func = function (node) {
           node.createWriteStream().end('<div>+ Trumpet</div>');
        }

        selects.push(simpleselect);

        //
        // Basic Connect App
        //
        var app = connect();

        var proxy = httpProxy.createProxyServer({
              target: 'http://localhost:9000'
        })

        //Additional true parameter can be used to ignore js and css files. 
        //app.use(require('../')([], selects, true));

        app.use(require('../')([], selects));

        app.use(function (req, res) {
                   proxy.web(req, res);
                });

        http.createServer(app).listen(8000);

        http.createServer(function (req, res) {
             res.writeHead(200, { 'Content-Type': 'text/html' });
               res.write('<html><head></head><body><div class="a">Nodejitsu Http Proxy</div><div class="b">&amp; Frames</div></body></html>');
                 res.end();
        }).listen(9000);

or See how images could be rotated.

$ cd node_modules/harmon/examples
$ node rotate.js

See trumpet for the types of queries and functions you can use.

Contributors

fabiosantoscode

no9

smazurov

sergiator

harmon's People

Contributors

arcanoxdragon avatar blakmatrix avatar brettz9 avatar ecolinet avatar fabiosantoscode avatar gnrlbzik avatar guypaddock avatar jbarna avatar jhorlin avatar leveneg avatar lonerifle avatar mikehedman avatar no9 avatar peebles avatar smazurov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.