use composite, add error handler

This commit is contained in:
Lloyd Brookes
2016-05-18 11:35:11 +01:00
parent 4ae36ffe63
commit 34f245c49d
4 changed files with 69 additions and 24 deletions

View File

@ -35,7 +35,24 @@ if (options.misc.help) {
return
}
const app = localWebServer({
const convert = require('koa-convert')
const Koa = require('koa')
const app = new Koa()
const _use = app.use
app.use = x => _use.call(app, convert(x))
// app.use((ctx, next) => {
// return next()
// .catch(err => {
// console.error('FUKKK', err)
// })
// })
app.on('error', err => {
console.error('ERROROO', err)
})
const ws = localWebServer({
static: {
root: options.server.directory,
options: {
@ -62,6 +79,8 @@ if (options.misc.help) {
mocks: options.server.mocks
})
app.use(ws)
if (options.server.https) {
options.server.key = path.resolve(__dirname, '..', 'ssl', '127.0.0.1.key')
options.server.cert = path.resolve(__dirname, '..', 'ssl', '127.0.0.1.crt')