travis-ci
181 of 181 new or added lines in 4 files covered. (100.0%)
245 of 287 relevant lines covered (85.37%)
8.86 hits per line
|
'use strict'
|
6✔ |
|
|
6✔ |
|
var _ = require('lodash') |
6✔ |
|
|
6✔ |
|
module.exports = function hapi (context, routes, done) { |
6✔ |
|
var seneca = this |
6✔ |
|
|
6✔ |
|
if (!context) {
|
× |
|
return done(new Error('no context provided')) |
× |
|
} |
6✔ |
|
|
6✔ |
|
_.each(routes, (route) => { |
12✔ |
|
context.route({ |
6✔ |
|
method: route.methods,
|
6✔ |
|
path: route.path,
|
6✔ |
|
handler: (request, reply) => {
|
6✔ |
|
request.on('peek', (chunk) => {
|
6✔ |
|
console.log('bananas')
|
× |
|
}) |
6✔ |
|
var payload = {
|
18✔ |
|
request$: request,
|
6✔ |
|
response$: reply,
|
6✔ |
|
args: {
|
6✔ |
|
body: request.payload,
|
6✔ |
|
route: route,
|
6✔ |
|
query: request.query,
|
6✔ |
|
params: request.params
|
6✔ |
|
} |
6✔ |
|
} |
6✔ |
|
|
6✔ |
|
seneca.act(route.pattern, payload, (err, response) => { |
18✔ |
|
if (route.autoreply) {
|
× |
|
if (err) {
|
× |
|
reply(err) |
× |
|
} |
6✔ |
|
else {
|
6✔ |
|
reply(null, response)
|
18✔ |
|
} |
6✔ |
|
} |
6✔ |
|
}) |
6✔ |
|
} |
6✔ |
|
}) |
6✔ |
|
}) |
6✔ |
|
|
6✔ |
|
done(null, {routes: routes}) |
12✔ |
|
} |
6✔ |