Skip to content

Commit

Permalink
Ported to Hapi v17
Browse files Browse the repository at this point in the history
Hurray on the big perf improvement! Good was removed because it was not
ported yet.
  • Loading branch information
mcollina committed Oct 27, 2017
1 parent 1f411d7 commit 91bf2fc
Show file tree
Hide file tree
Showing 12 changed files with 343 additions and 484 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: node_js
sudo: false
node_js:
- "4"
- "6"
- "7"
- "8"
after_script:
- npm run coveralls
46 changes: 0 additions & 46 deletions benchmarks/good.js

This file was deleted.

47 changes: 19 additions & 28 deletions benchmarks/hapi-pino-extreme.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
'use strict'

const Hapi = require('hapi')
require('make-promises-safe')

const server = new Hapi.Server()
server.connection({
host: 'localhost',
port: 3000
})
const Hapi = require('hapi')

server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
return reply('hello world')
}
})
async function start () {
const server = Hapi.server({ port: 3000 })

server.register({
register: require('..'),
options: {
extreme: true
}
}, (err) => {
if (err) {
console.error(err)
process.exit(1)
}
server.route({
method: 'GET',
path: '/',
handler: async function (request, h) {
return 'hello world'
}
})

server.start((err) => {
if (err) {
console.error(err)
process.exit(1)
await server.register({
plugin: require('..'),
options: {
extreme: true
}
})
})
await server.start()
}

start()
56 changes: 24 additions & 32 deletions benchmarks/hapi-pino-merge-hapi-log.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
'use strict'

require('make-promises-safe')

const Hapi = require('hapi')

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

server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
return reply('hello world')
}
})

server.register({
register: require('..'),
options: {
mergeHapiLogData: true
}
}, (err) => {
if (err) {
console.error(err)
process.exit(1)
}

server.on('response', () => {
server.log(['info'], { hello: 'world' })
async function start () {
const server = Hapi.server({ port: 3000 })

server.route({
method: 'GET',
path: '/',
handler: async function (request, h) {
return 'hello world'
}
})

server.start((err) => {
if (err) {
console.error(err)
process.exit(1)
await server.register({
plugin: require('..'),
options: {
mergeHapiLogData: true
}
})
})

server.events.on('response', () => {
server.log(['info'], { hello: 'world' })
})

await server.start()
}

start()
51 changes: 24 additions & 27 deletions benchmarks/hapi-pino-no-merge-hapi-log.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
'use strict'

require('make-promises-safe')

const Hapi = require('hapi')

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

server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
return reply('hello world')
}
})

server.register(require('..'), (err) => {
if (err) {
console.error(err)
process.exit(1)
}

server.on('response', () => {
server.log(['info'], { hello: 'world' })
async function start () {
const server = Hapi.server({ port: 3000 })

server.route({
method: 'GET',
path: '/',
handler: async function (request, h) {
return 'hello world'
}
})

server.start((err) => {
if (err) {
console.error(err)
process.exit(1)
await server.register({
plugin: require('..'),
options: {
mergeHapiLogData: false
}
})
})

server.events.on('response', () => {
server.log(['info'], { hello: 'world' })
})

await server.start()
}

start()
39 changes: 15 additions & 24 deletions benchmarks/hapi-pino.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
'use strict'

const Hapi = require('hapi')

const server = new Hapi.Server()
server.connection({
host: 'localhost',
port: 3000
})
require('make-promises-safe')

server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
return reply('hello world')
}
})
const Hapi = require('hapi')

server.register(require('..'), (err) => {
if (err) {
console.error(err)
process.exit(1)
}
async function start () {
const server = Hapi.server({ port: 3000 })

server.start((err) => {
if (err) {
console.error(err)
process.exit(1)
server.route({
method: 'GET',
path: '/',
handler: async function (request, h) {
return 'hello world'
}
})
})

await server.register(require('..'))
await server.start()
}

start()
36 changes: 15 additions & 21 deletions benchmarks/hapi-pure.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
'use strict'

require('make-promises-safe')

const Hapi = require('hapi')

// Create a server with a host and port
const server = new Hapi.Server()
server.connection({
host: 'localhost',
port: 3000
})
async function start () {
const server = Hapi.server({ port: 3000 })

server.route({
method: 'GET',
path: '/',
handler: async function (request, h) {
return 'hello world'
}
})

// Add the route
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
return reply('hello world')
}
})
await server.start()
}

// Start the server
server.start((err) => {
if (err) {
console.error(err)
process.exit(1)
}
})
start()
49 changes: 0 additions & 49 deletions example-good.js

This file was deleted.

Loading

0 comments on commit 91bf2fc

Please sign in to comment.