├── index.js
├── .idea
├── scopes
│ └── scope_settings.xml
├── libraries
│ └── hapi_newrelic_node_modules.xml
└── workspace.xml
├── example
└── server.js
├── .gitignore
├── lib
├── newrelic.js
└── index.js
├── README.md
├── package.json
├── test
└── hapi-newrelic_test.js
└── gulpfile.js
/index.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./lib');
2 |
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/example/server.js:
--------------------------------------------------------------------------------
1 | /*
2 | * hapi-newrelic
3 | * https://github.com/lyric/hapi-newrelic
4 | *
5 | * Copyright (c) 2014 Lyric Hartley
6 | * Licensed under the MIT license.
7 | */
8 |
9 | 'use strict';
10 |
11 | var Hapi = require('hapi');
12 |
13 | var server = new Hapi.Server('localhost', 8000);
14 |
15 | server.pack.require('../', function() {
16 | server.start();
17 | console.log('Server running at ' + server.info.uri);
18 | });
19 |
--------------------------------------------------------------------------------
/.idea/libraries/hapi_newrelic_node_modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # Compiled binary addons (http://nodejs.org/api/addons.html)
20 | build/Release
21 |
22 | # Dependency directory
23 | # Deployed apps should consider commenting this line out:
24 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
25 | node_modules
26 |
--------------------------------------------------------------------------------
/lib/newrelic.js:
--------------------------------------------------------------------------------
1 | /**
2 | * New Relic agent configuration.
3 | *
4 | * See lib/config.defaults.js in the agent distribution for a more complete
5 | * description of configuration variables and their potential values.
6 | */
7 | exports.config = {
8 | /**
9 | * Array of application names.
10 | */
11 | app_name : ['My Application'],
12 | /**
13 | * Your New Relic license key.
14 | */
15 | license_key : 'license key here',
16 | logging : {
17 | /**
18 | * Level at which to log. 'trace' is most useful to New Relic when diagnosing
19 | * issues with the agent, 'info' and higher will impose the least overhead on
20 | * production applications.
21 | */
22 | level : 'info'
23 | }
24 | };
25 |
--------------------------------------------------------------------------------
/lib/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * hapi-newrelic
3 | * https://github.com/lyric/hapi-newrelic
4 | *
5 | * Copyright (c) 2014 Lyric Hartley
6 | * Licensed under the MIT license.
7 | */
8 |
9 | 'use strict';
10 |
11 | // Following the 'Node.js require(s) best practices' by
12 | // http://www.mircozeiss.com/node-js-require-s-best-practices/
13 |
14 | // // Nodejs libs
15 | // var fs = require('fs'),
16 | //
17 | // // External libs
18 | // debug = require('debug'),
19 | //
20 | // // Internal libs
21 | // data = require('./data.js');
22 |
23 | // Declare internals
24 | var internals = {};
25 |
26 | // Defaults
27 | internals.defaults = {};
28 |
29 | exports.register = function(plugin, options, next) {
30 |
31 | plugin.route({
32 | method: 'GET',
33 | path: '/',
34 | handler: function(request, reply) {
35 | reply('don\'t worry, be hapi!');
36 | }
37 | });
38 |
39 | next();
40 | };
41 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # hapi-newrelic
2 | [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-url]][daviddm-image]
3 |
4 | Add newrelic to a hapi project
5 |
6 |
7 | ## Install
8 |
9 | ```bash
10 | $ npm install --save hapi-newrelic
11 | ```
12 |
13 |
14 | ## API
15 |
16 | _(Coming soon)_
17 |
18 |
19 | ## Contributing
20 |
21 | In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [gulp](http://gulpjs.com/).
22 |
23 |
24 | ## Release History
25 |
26 | _(Nothing yet)_
27 |
28 |
29 | ## License
30 |
31 | Copyright (c) 2014 Lyric Hartley. Licensed under the MIT license.
32 |
33 |
34 |
35 | [npm-url]: https://npmjs.org/package/hapi-newrelic
36 | [npm-image]: https://badge.fury.io/js/hapi-newrelic.svg
37 | [travis-url]: https://travis-ci.org/lyric/hapi-newrelic
38 | [travis-image]: https://travis-ci.org/lyric/hapi-newrelic.svg?branch=master
39 | [daviddm-url]: https://david-dm.org/lyric/hapi-newrelic.svg?theme=shields.io
40 | [daviddm-image]: https://david-dm.org/lyric/hapi-newrelic
41 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hapi-newrelic",
3 | "description": "Add newrelic to a hapi project",
4 | "version": "0.0.0",
5 | "homepage": "https://github.com/lyric/hapi-newrelic",
6 | "bugs": "https://github.com/lyric/hapi-newrelic/issues",
7 | "license": "MIT",
8 | "main": "index",
9 | "author": {
10 | "name": "Lyric Hartley",
11 | "email": "lyrichartley@gmail.com"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "https://github.com/lyric/hapi-newrelic"
16 | },
17 | "keywords": [
18 | "hapi",
19 | "plugin"
20 | ],
21 | "dependencies": {
22 | "hoek": "2.3.0",
23 | "newrelic": "^1.7.4"
24 | },
25 | "devDependencies": {
26 | "gulp": "^3.6.2",
27 | "gulp-util": "2.2.16",
28 | "gulp-bump": "^0.1.8",
29 | "gulp-jshint": "^1.5.5",
30 | "gulp-nodemon": "^1.0.4",
31 | "jshint-stylish": "^0.2.0",
32 | "gulp-load-plugins": "^0.5.1",
33 | "gulp-plumber": "^0.6.2",
34 | "gulp-lab": "0.0.7",
35 | "hapi": "5.x.x",
36 | "lab": "3.x.x"
37 | },
38 | "peerDependencies": {
39 | "hapi": ">=2.x.x"
40 | },
41 | "engines": {
42 | "node": ">=0.10.22"
43 | },
44 | "scripts": {
45 | "test": "gulp test"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/test/hapi-newrelic_test.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Lab = require('lab'),
4 | Hapi = require('hapi');
5 |
6 | var describe = Lab.experiment;
7 | var it = Lab.test;
8 | var expect = Lab.expect;
9 | var before = Lab.before;
10 | var after = Lab.after;
11 |
12 | describe('hapiNewrelic', function() {
13 | var server = new Hapi.Server();
14 | it('Plugin successfully loads', function(done) {
15 | server.pack.require('../', function(err) {
16 |
17 | expect(err).to.not.exist;
18 |
19 | done();
20 | });
21 | });
22 |
23 | it('Plugin registers routes', function(done) {
24 | var table = server.table();
25 |
26 | expect(table).to.have.length(1);
27 | expect(table[0].path).to.equal('/');
28 |
29 | done();
30 | });
31 |
32 | it("Plugin route responses", function(done) {
33 | var table = server.table();
34 |
35 | expect(table).to.have.length(1);
36 | expect(table[0].path).to.equal("/");
37 |
38 | var request = {
39 | method: 'GET',
40 | url: '/'
41 | };
42 |
43 | server.inject(request, function(res) {
44 | expect(res.statusCode).to.equal(200);
45 | expect(res.result).to.equal('don\'t worry, be hapi!');
46 | done();
47 | });
48 |
49 | });
50 | });
51 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var gulp = require('gulp');
4 | var plugins = require('gulp-load-plugins')();
5 |
6 | var paths = {
7 | lint: ['./gulpfile.js', './lib/**/*.js'],
8 | watch: ['./gulpfile.js', './index.js', './lib/**', './test/**/*.js', '!test/{temp,temp/**}'],
9 | tests: ['./test/**/*.js', '!test/{temp,temp/**}']
10 | };
11 |
12 | gulp.task('lint', function () {
13 | return gulp.src(paths.lint)
14 | .pipe(plugins.jshint('.jshintrc'))
15 | .pipe(plugins.jshint.reporter('jshint-stylish'));
16 | });
17 |
18 | gulp.task('lab', function () {
19 | gulp.src(paths.tests, {cwd: __dirname})
20 | .pipe(plugins.plumber())
21 | .pipe(plugins.lab('-v -l -c'));
22 | });
23 |
24 | gulp.task('test', ['lint', 'lab']);
25 |
26 | gulp.task('watch', function () {
27 | gulp.run('test');
28 | gulp.watch(paths.watch, ['test']);
29 | });
30 |
31 | gulp.task('develop', function () {
32 | plugins.nodemon({ script: 'example/server.js', ext: 'js'})
33 | .on('change', ['test']);
34 | });
35 |
36 | gulp.task('bump', ['test'], function () {
37 | var bumpType = plugins.util.env.type || 'patch'; // major.minor.patch
38 | return gulp.src(['./package.json'])
39 | .pipe(plugins.bump({ type: bumpType }))
40 | .pipe(gulp.dest('./'));
41 | });
42 |
43 | gulp.task('release', ['bump']);
44 |
45 |
46 | gulp.task('default', ['test']);
47 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 | 1404235435822
113 | 1404235435822
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
144 |
147 |
148 |
149 |
150 |
151 |
152 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
--------------------------------------------------------------------------------