Skip to content

Commit

Permalink
refactor: convert connection options to constructor options
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMurphy committed Nov 10, 2017
1 parent a6832e7 commit 2824293
Show file tree
Hide file tree
Showing 56 changed files with 138 additions and 282 deletions.
4 changes: 1 addition & 3 deletions API.md
Expand Up @@ -14,9 +14,7 @@ combine **bell** with the [**hapi-auth-cookie**](https://github.com/hapijs/hapi-

```javascript
var Hapi = require('hapi');
var server = new Hapi.Server();

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

// Register bell with the server
server.register(require('bell'), function (err) {
Expand Down
4 changes: 1 addition & 3 deletions README.md
Expand Up @@ -26,9 +26,7 @@ Twitter:

```javascript
var Hapi = require('hapi');
var server = new Hapi.Server();

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

// Register bell with the server
server.register(require('bell'), function (err) {
Expand Down
3 changes: 1 addition & 2 deletions examples/arcgisonline.js
Expand Up @@ -7,8 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


const server = new Hapi.Server();
server.connection({ port: 8000 });
const server = new Hapi.Server({ port: 8000 });

server.register(Bell, (err) => {

Expand Down
3 changes: 1 addition & 2 deletions examples/discord.js
Expand Up @@ -7,8 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


const server = new Hapi.Server();
server.connection({ port: 8000 });
const server = new Hapi.Server({ port: 8000 });

server.register(Bell, (err) => {

Expand Down
3 changes: 1 addition & 2 deletions examples/facebook.js
Expand Up @@ -7,8 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


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

server.register(Bell, (err) => {

Expand Down
3 changes: 1 addition & 2 deletions examples/google.js
Expand Up @@ -7,8 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


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

server.register(Bell, (err) => {

Expand Down
3 changes: 1 addition & 2 deletions examples/linkedin.js
Expand Up @@ -7,8 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


const server = new Hapi.Server();
server.connection({ port: 8000 });
const server = new Hapi.Server({ port: 8000 });

server.register(Bell, (err) => {

Expand Down
3 changes: 1 addition & 2 deletions examples/meetup.js
Expand Up @@ -7,8 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


const server = new Hapi.Server();
server.connection({ port: 8000 });
const server = new Hapi.Server({ port: 8000 });

server.register(Bell, (err) => {

Expand Down
3 changes: 1 addition & 2 deletions examples/nest.js
Expand Up @@ -7,8 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


const server = new Hapi.Server();
server.connection({ port: 8000 });
const server = new Hapi.Server({ port: 8000 });

server.register(Bell, (err) => {

Expand Down
3 changes: 1 addition & 2 deletions examples/office365.js
Expand Up @@ -7,8 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


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

server.register(Bell, (err) => {

Expand Down
3 changes: 1 addition & 2 deletions examples/okta.js
Expand Up @@ -6,8 +6,7 @@ const Hapi = require('hapi');
const Hoek = require('hoek');
const Boom = require('boom');

const server = new Hapi.Server();
server.connection({ port: 8000 });
const server = new Hapi.Server({ port: 8000 });

server.register([require('hapi-auth-cookie'), require('../')], (err) => {

Expand Down
3 changes: 1 addition & 2 deletions examples/slack.js
Expand Up @@ -7,8 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


const server = new Hapi.Server();
server.connection({ port: 8000 });
const server = new Hapi.Server({ port: 8000 });

server.register(Bell, (err) => {

Expand Down
5 changes: 1 addition & 4 deletions examples/twitch.js
Expand Up @@ -7,10 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


const server = new Hapi.Server();
server.connection({
port: 8000
});
const server = new Hapi.Server({ port: 8000 });

server.register(Bell, (err) => {

Expand Down
3 changes: 1 addition & 2 deletions examples/twitter.js
Expand Up @@ -7,8 +7,7 @@ const Hoek = require('hoek');
const Bell = require('../');


const server = new Hapi.Server();
server.connection({ port: 8000 });
const server = new Hapi.Server({ port: 8000 });

server.register(Bell, (err) => {

Expand Down
2 changes: 1 addition & 1 deletion lib/oauth.js
Expand Up @@ -206,7 +206,7 @@ exports.v2 = function (settings) {

reply.unstate(cookie);

const requestState = request.query.state || '';
const requestState = request.query.state || '';
if (state.nonce !== requestState.substr(0, Math.min(requestState.length, internals.nonceLength))) {
return reply(Boom.internal('Incorrect ' + name + ' state parameter'));
}
Expand Down
30 changes: 9 additions & 21 deletions test/index.js
Expand Up @@ -30,8 +30,7 @@ describe('Bell', () => {
const mock = new Mock.V1();
mock.start((provider) => {

const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80 });
const server = new Hapi.Server({ host: 'localhost', port: 80 });
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down Expand Up @@ -72,8 +71,7 @@ describe('Bell', () => {
const mock = new Mock.V1();
mock.start((provider) => {

const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80 });
const server = new Hapi.Server({ host: 'localhost', port: 80 });
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down Expand Up @@ -124,8 +122,7 @@ describe('Bell', () => {
const mock = new Mock.V1({ signatureMethod: 'RSA-SHA1' });
mock.start((provider) => {

const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80 });
const server = new Hapi.Server({ host: 'localhost', port: 80 });
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down Expand Up @@ -176,8 +173,7 @@ describe('Bell', () => {
const mock = new Mock.V2();
mock.start((provider) => {

const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80 });
const server = new Hapi.Server({ host: 'localhost', port: 80 });
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down Expand Up @@ -227,8 +223,7 @@ describe('Bell', () => {
const mock = new Mock.V2({ useParamsAuth: false });
mock.start((provider) => {

const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80 });
const server = new Hapi.Server({ host: 'localhost', port: 80 });
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down Expand Up @@ -278,8 +273,7 @@ describe('Bell', () => {
const mock = new Mock.V1();
mock.start((provider) => {

const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80 });
const server = new Hapi.Server({ host: 'localhost', port: 80 });
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down Expand Up @@ -319,8 +313,7 @@ describe('Bell', () => {
const mock = new Mock.V1();
mock.start((provider) => {

const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80 });
const server = new Hapi.Server({ host: 'localhost', port: 80 });
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down Expand Up @@ -388,8 +381,7 @@ describe('Bell', () => {

it('exposes OAuth via plugin', (done) => {

const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80 });
const server = new Hapi.Server({ host: 'localhost', port: 80 });
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand All @@ -403,8 +395,7 @@ describe('Bell', () => {
const mock = new Mock.V1();
mock.start((provider) => {

const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80 });
const server = new Hapi.Server({ host: 'localhost', port: 80 });
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down Expand Up @@ -446,7 +437,6 @@ describe('Bell', () => {
});

const server = new Hapi.Server();
server.connection();
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down Expand Up @@ -497,7 +487,6 @@ describe('Bell', () => {
});

const server = new Hapi.Server();
server.connection();
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down Expand Up @@ -549,7 +538,6 @@ describe('Bell', () => {
});

const server = new Hapi.Server();
server.connection();
server.register(Bell, (err) => {

expect(err).to.not.exist();
Expand Down
6 changes: 2 additions & 4 deletions test/mock.js
Expand Up @@ -30,8 +30,7 @@ exports.V1 = internals.V1 = function (options) {

this.tokens = {};

this.server = new Hapi.Server();
this.server.connection({ host: 'localhost' });
this.server = new Hapi.Server({ host: 'localhost' });
this.server.route([
{
method: 'POST',
Expand Down Expand Up @@ -163,8 +162,7 @@ exports.V2 = internals.V2 = function (options) {
this.codes = {};

this.useParamsAuth = (options.useParamsAuth === false ? false : true);
this.server = new Hapi.Server();
this.server.connection({ host: 'localhost' });
this.server = new Hapi.Server({ host: 'localhost' });
this.server.route([
{
method: 'GET',
Expand Down

0 comments on commit 2824293

Please sign in to comment.