Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// response interface.
function responseBodyMiddleware (req, next) {
return next().then(res => {
return res.text().then(body => {
res.body = body
return res
})
})
}
var popsicleServerMiddleware = popsicleServer(app)
var middleware = compose([
responseBodyMiddleware,
popsicleServerMiddleware,
popsicle.middleware
])
return {
fetch: popsicle.toFetch(middleware, Request)
}
}
var compose = require('throwback').compose
var Request = require('servie').Request
var popsicle = require('popsicle')
// Set response text to "body" property to mimic popsicle v10
// response interface.
function responseBodyMiddleware (req, next) {
return next().then(res => {
return res.text().then(body => {
res.body = body
return res
})
})
}
var middleware = [responseBodyMiddleware, ...mware, popsicle.middleware]
return {
fetch: popsicle.toFetch(compose(middleware), Request)
}
}
return res
})
})
}
function createServer (router) {
return function (req, res) {
router(req, res, finalhandler(req, res))
}
}
var popsicleServerMiddleware = popsicleServer(createServer(app))
var middleware = compose([
responseBodyMiddleware,
popsicleServerMiddleware,
popsicle.middleware
])
return {
fetch: popsicle.toFetch(middleware, Request)
}
}