travis-ci
178 of 178 new or added lines in 4 files covered. (100.0%)
243 of 284 relevant lines covered (85.56%)
8.87 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✔ |
|
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✔ |