Skip to content

Instantly share code, notes, and snippets.

@danielb2
Created October 19, 2015 12:36
Show Gist options
  • Save danielb2/330b492a85c1f6aee786 to your computer and use it in GitHub Desktop.
Save danielb2/330b492a85c1f6aee786 to your computer and use it in GitHub Desktop.

Revisions

  1. danielb2 created this gist Oct 19, 2015.
    17 changes: 17 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    {
    "name": "foo",
    "version": "1.0.0",
    "description": "good log trial thing",
    "main": "./start.js",
    "author": "me",
    "dependencies": {
    "blipp": "2.x.x",
    "good": "6.x.x",
    "good-console": "5.x.x",
    "good-file": "^5.1.0",
    "hapi": "8.x.x",
    "hoek": "2.x.x",
    "purdy": "1.x.x",
    "wreck": "6.x.x"
    }
    }
    55 changes: 55 additions & 0 deletions start.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    var Hapi = require('hapi');
    var Url = require('url');
    var Wreck = require('wreck');

    var server = new Hapi.Server();
    server.connection({ host: 'localhost', port: 8000 });

    var good = {
    options: {
    opsInterval: 5000,
    requestHeaders: true,
    requestPayload: true,
    reporters: [{
    reporter: 'good-console',
    events: {
    error: '*',
    log: '*',
    request: '*',
    response: '*',
    wreck: '*'
    }
    },
    {
    reporter: 'good-file',
    config: './wreck.log',
    events: {
    wreck: '*'
    }
    }]
    },
    register: require('good')
    };

    var handler = {
    proxy: {
    host: 'www.google.com.tw'
    }
    };

    server.route({
    method: 'GET',
    path: '/{url*}',
    config: {
    handler: handler
    }
    });




    server.register([good, { register: require('blipp') }], function (err) {

    server.start(function (err) { });
    });