Skip to content

Commit ed74994

Browse files
committed
Add to README.ms
1 parent 6df1c3b commit ed74994

13 files changed

+306
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ hapi-lxjs
33

44
LXJS Repository for API building
55

6-
yo yo yo!
6+
_Hallo!_
7+
8+
Welcome to the Hapi Training for LXJS.

plugins/.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
8+
[*]
9+
10+
# Change these settings to your own preference
11+
indent_style = space
12+
indent_size = 2
13+
14+
# We recommend you to keep these unchanged
15+
end_of_line = lf
16+
charset = utf-8
17+
trim_trailing_whitespace = true
18+
insert_final_newline = true
19+
20+
[*.md]
21+
trim_trailing_whitespace = false

plugins/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
temp/
3+
npm-debug.log
4+
.DS_Store
5+
.idea

plugins/.jscs.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
3+
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
4+
"disallowImplicitTypeConversion": ["string"],
5+
"disallowKeywords": ["with"],
6+
"disallowMultipleLineBreaks": true,
7+
"disallowKeywordsOnNewLine": ["else"],
8+
"disallowTrailingWhitespace": true,
9+
"requireLineFeedAtFileEnd": true,
10+
"validateJSDoc": {
11+
"checkParamNames": true,
12+
"requireParamTypes": true
13+
}
14+
}

plugins/.jshintrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"curly": true,
3+
"eqeqeq": true,
4+
"immed": true,
5+
"latedef": true,
6+
"newcap": true,
7+
"noarg": true,
8+
"sub": true,
9+
"undef": true,
10+
"unused": true,
11+
"boss": true,
12+
"eqnull": true,
13+
"node": true,
14+
"globals": {
15+
"describe" : false,
16+
"it" : false,
17+
"before" : false,
18+
"beforeEach" : false,
19+
"after" : false,
20+
"afterEach" : false
21+
}
22+
}

plugins/.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- '0.10'

plugins/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# backer
2+
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-url]][daviddm-image]
3+
4+
The best plugin ever
5+
6+
7+
## Install
8+
9+
```bash
10+
$ npm install --save backer
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 Ben Acker. Licensed under the MIT license.
32+
33+
34+
35+
[npm-url]: https://npmjs.org/package/backer
36+
[npm-image]: https://badge.fury.io/js/backer.svg
37+
[travis-url]: https://travis-ci.org/nvcexploder/backer
38+
[travis-image]: https://travis-ci.org/nvcexploder/backer.svg?branch=master
39+
[daviddm-url]: https://david-dm.org/nvcexploder/backer.svg?theme=shields.io
40+
[daviddm-image]: https://david-dm.org/nvcexploder/backer

plugins/example/server.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* backer
3+
* https://github.com/nvcexploder/backer
4+
*
5+
* Copyright (c) 2014 Ben Acker
6+
* Licensed under the MIT license.
7+
*/
8+
9+
'use strict';
10+
11+
var Hapi = require('hapi');
12+
var Plugin = require('../');
13+
14+
var server = new Hapi.Server('localhost', 8000);
15+
16+
server.pack.register(Plugin, function() {
17+
server.start();
18+
console.log('Server running at ' + server.info.uri);
19+
});

plugins/gulpfile.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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.jscs())
16+
.pipe(plugins.jshint.reporter('jshint-stylish'));
17+
});
18+
19+
gulp.task('lab', function () {
20+
gulp.src(paths.tests, {cwd: __dirname})
21+
.pipe(plugins.plumber())
22+
.pipe(plugins.lab('-v -l -c'));
23+
});
24+
25+
gulp.task('test', ['lint', 'lab']);
26+
27+
gulp.task('watch', function () {
28+
gulp.run('test');
29+
gulp.watch(paths.watch, ['test']);
30+
});
31+
32+
gulp.task('develop', function () {
33+
plugins.nodemon({ script: 'example/server.js', ext: 'js'})
34+
.on('change', ['test']);
35+
});
36+
37+
gulp.task('bump', ['test'], function () {
38+
var bumpType = plugins.util.env.type || 'patch'; // major.minor.patch
39+
return gulp.src(['./package.json'])
40+
.pipe(plugins.bump({ type: bumpType }))
41+
.pipe(gulp.dest('./'));
42+
});
43+
44+
gulp.task('release', ['bump']);
45+
46+
gulp.task('default', ['test']);

plugins/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib');

plugins/lib/index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* backer
3+
* https://github.com/nvcexploder/backer
4+
*
5+
* Copyright (c) 2014 Ben Acker
6+
* Licensed under the MIT license.
7+
*/
8+
9+
'use strict';
10+
11+
// Declare internals
12+
var internals = {};
13+
14+
// Defaults
15+
internals.defaults = {};
16+
17+
exports.register = function(plugin, options, next) {
18+
19+
plugin.route({
20+
method: 'GET',
21+
path: '/',
22+
handler: function(request, reply) {
23+
reply('don\'t worry, be hapi!');
24+
}
25+
});
26+
27+
next();
28+
};
29+
30+
exports.register.attributes = {
31+
pkg: require('../package.json')
32+
};

plugins/package.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "backer",
3+
"description": "The best plugin ever",
4+
"version": "0.0.0",
5+
"homepage": "https://github.com/nvcexploder/backer",
6+
"bugs": "https://github.com/nvcexploder/backer/issues",
7+
"license": "MIT",
8+
"main": "index",
9+
"author": {
10+
"name": "Ben Acker",
11+
"email": "[email protected]"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/nvcexploder/backer"
16+
},
17+
"keywords":[
18+
"hapi",
19+
"plugin"
20+
],
21+
"dependencies": {
22+
"joi": "4.6.1",
23+
"lout": "5.0.0",
24+
"hoek": "2.3.0"
25+
},
26+
"devDependencies": {
27+
"gulp": "^3.6.2",
28+
"gulp-util": "2.2.16",
29+
"gulp-bump": "^0.1.8",
30+
"gulp-jscs": "^0.4.2",
31+
"gulp-jshint": "^1.5.5",
32+
"gulp-nodemon": "^1.0.4",
33+
"jshint-stylish": "^0.2.0",
34+
"gulp-load-plugins": "^0.5.1",
35+
"gulp-plumber": "^0.6.2",
36+
"gulp-lab": "0.0.7",
37+
"hapi": "6.x.x",
38+
"lab": "3.x.x"
39+
},
40+
"peerDependencies": {
41+
"hapi": ">=2.x.x"
42+
},
43+
"engines": {
44+
"node": ">=0.10.22"
45+
},
46+
"scripts": {
47+
"test": "gulp test"
48+
}
49+
}

plugins/test/backer_test.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict';
2+
3+
var Lab = require('lab'),
4+
Hapi = require('hapi'),
5+
Plugin = require('../');
6+
7+
var describe = Lab.experiment;
8+
var it = Lab.test;
9+
var expect = Lab.expect;
10+
var before = Lab.before;
11+
var after = Lab.after;
12+
13+
describe('backer', function() {
14+
var server = new Hapi.Server();
15+
it('Plugin successfully loads', function(done) {
16+
server.pack.register(Plugin, function(err) {
17+
18+
expect(err).to.not.exist;
19+
20+
done();
21+
});
22+
});
23+
24+
it('Plugin registers routes', function(done) {
25+
var table = server.table();
26+
27+
expect(table).to.have.length(1);
28+
expect(table[0].path).to.equal('/');
29+
30+
done();
31+
});
32+
33+
it('Plugin route responses', function(done) {
34+
var table = server.table();
35+
36+
expect(table).to.have.length(1);
37+
expect(table[0].path).to.equal('/');
38+
39+
var request = {
40+
method: 'GET',
41+
url: '/'
42+
};
43+
44+
server.inject(request, function(res) {
45+
expect(res.statusCode).to.equal(200);
46+
expect(res.result).to.equal('don\'t worry, be hapi!');
47+
done();
48+
});
49+
50+
});
51+
});

0 commit comments

Comments
 (0)