• Stars
    star
    425
  • Rank 98,492 (Top 2 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

middleware for node-http-proxy to modify the remote website response with trumpet

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

More Repositories

1

torrential

Workshopper for creating a simple p2p bittorrent network
JavaScript
58
star
2

localstorage-down

localstorage implementation of leveldown
JavaScript
41
star
3

chrome-fs

Use the Node `fs` API in Chrome Apps
JavaScript
17
star
4

tide-morth-example

An example application using mongodb rust tide and handlebars A.K.A MoRTH stack
Rust
14
star
5

tide-trace

USDT middleware for Tide to enable dynamic probes that can be used with ebpf on Linux and Dtrace on other *nixes
Rust
12
star
6

sqlcdcstream

A stream of SQL Server Change Events
JavaScript
11
star
7

node-leveldown-gap

A leveldown implementation for Phonegap - mothballed please see localstorage-down
JavaScript
10
star
8

tide-handlebars

Use handlebar templates in tide
Rust
10
star
9

dtrace-express

A library that implements dtrace for express
JavaScript
9
star
10

dtrace-streams

Streaming API for DTrace
JavaScript
7
star
11

peerconf-2013

Slides From PeerConf
JavaScript
5
star
12

tide-rhai

Rhai scripts in tide servers
Rust
5
star
13

dtrace-leveldb-blogpost

Support Files for the dtrace and leveldb blog post
D
3
star
14

logentries-dtrace

A library for logging DTrace events into logentires.
JavaScript
3
star
15

uftp

A wrapper around UFTP an encrypted multicast file transfer library
Python
3
star
16

coolamber

A modular application container for node.js
JavaScript
2
star
17

project-stats

Pull and visualize contributor stats from github projects
HTML
2
star
18

rust-usdt-helloworld

A simple example of Userland Statically Defined Tracing in rust
Rust
2
star
19

helm-2-podman

repo to demo piping helm output to podman
Smarty
2
star
20

sqlcdcmanager

A tool to expose the changes in an sql server database to node applications
JavaScript
2
star
21

chrome-os

Use the Node `os` API in Chrome Apps
JavaScript
2
star
22

fastify-loopback-example

An example of using Fasity and Loopback together
TypeScript
2
star
23

wasi-crun-example

A sample wasi container to be host in crun
Rust
2
star
24

firmata-stream

Arduino Firmata integration through streams
JavaScript
2
star
25

clowder

An knowledge sharing system for a disconnected world
JavaScript
1
star
26

luvdbie

Leveldb tcp server
1
star
27

converserjs

A javascript client to wrap converser.io requests
JavaScript
1
star
28

rust-tide

An appsody stack for https://github.com/http-rs/tide
Dockerfile
1
star
29

buccina

An evented ASN1 Parser
JavaScript
1
star
30

scotlandjs

Presentation and Demo from scotlandjs on P2P
JavaScript
1
star
31

dublinjs

A locker project for Dublin JS
1
star
32

cobh

A scratch pad
JavaScript
1
star
33

lancasterstemmer-stream

A stream wrapper around the fantastic natural
1
star
34

GBNC

Slides For Great British Node Conf
JavaScript
1
star
35

nodejs-dns-performance

A sample node app based on node USDT build to demonstrate per request DNS performane
JavaScript
1
star
36

no9.github.io

Blog
JavaScript
1
star
37

cloud-events-backoff

A project to manage retries for cloud events
1
star
38

nodejsdublin-28-06-2012

C#
1
star
39

tide-scs

A self contained system implementation in Tide
1
star
40

twentymental

A twitter viewer for SINGLY
1
star
41

surch

Locker Project Search Viewer
JavaScript
1
star
42

arduino-sketches

Repo For Arduino stuff
C++
1
star
43

clappr

An solution to the first world problem of hurting your hands at conferences
1
star
44

photorinse

A photo filter for lockerproject
1
star
45

checkout

Dartsboard UI
JavaScript
1
star
46

gameoflife

A javascript game of life based Conways Game Of Life
JavaScript
1
star
47

watson-machine-learning-rs

An unofficial rust helper for integrating with IBM watson machine learning
Rust
1
star
48

clowt

A sample RAG implementation in Rust
Rust
1
star