travis-ci
151 of 151 new or added lines in 4 files covered. (100.0%)
201 of 250 relevant lines covered (80.4%)
6.53 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) => { |
6✔ |
|
context.route({ |
6✔ |
|
method: route.methods,
|
6✔ |
|
path: route.path,
|
6✔ |
|
handler: (request, reply) => {
|
6✔ |
|
var payload = {
|
× |
|
request$: request,
|
6✔ |
|
response$: reply
|
6✔ |
|
} |
× |
|
|
6✔ |
|
seneca.act(route.pattern, payload, (err, response) => { |
× |
|
if (route.autoreply) {
|
× |
|
if (err) {
|
× |
|
reply(err) |
× |
|
} |
6✔ |
|
else {
|
6✔ |
|
reply(null, response)
|
× |
|
} |
6✔ |
|
} |
× |
|
}) |
6✔ |
|
} |
6✔ |
|
}) |
6✔ |
|
}) |
6✔ |
|
|
6✔ |
|
done(null, {routes: routes}) |
6✔ |
|
} |
6✔ |