travis-ci
308 of 308 new or added lines in 6 files covered. (100.0%)
405 of 463 relevant lines covered (87.47%)
11.42 hits per line
|
'use strict'
|
6✔ |
|
|
6✔ |
|
var _ = require('lodash') |
6✔ |
|
|
6✔ |
|
module.exports = function hapi (options, context, auth, 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✔ |
|
var payload = {
|
6✔ |
|
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✔ |