Open OleileiA opened 7 years ago
That is definitely strange. I will have to try and reproduce it in a few hours (after I get a little sleep). Whatever it is, it shouldn't be too difficult to sort out.
Hey, sorry I wasn't able to get back to you yesterday. The issue here is some sort of bad interaction with Restify. I will have to look into it this weekend. The good news is, Node Monkey has a feature that allows you to provide your own server as documented here. Since I don't have a Koa example there yet, here is some code based on yours that will work:
const NodeMonkey = require('node-monkey')
const Koa = require('koa')
const mount = require('koa-mount')
const send = require('koa-send')
const app = new Koa()
const monk = NodeMonkey({
server: {
server: app.listen(3000)
}
})
const monkPaths = monk.getServerPaths()
app.use(mount('/monkey.js', async ctx => await send(ctx, monkPaths.client, { root: monkPaths.basePath })))
app.use(mount('/monkey', async ctx => await send(ctx, monkPaths.index, { root: monkPaths.basePath })))
app.use(async (ctx, next) => {
await next()
let url = ctx.request.url
ctx.body = url
console.log(ctx)
})
Note that you'll have to install koa-mount
and koa-send
for those to work. To access the Node Monkey output you should then open a new tab, open your dev console and go to http://localhost:3000/monkey to see output from your app. Also, keep in mind that even though your code sets ctx.body
you will not actually see it in the object dumped to the console because if you look in the Koa source code you'll notice ctx.body
only exists as a delegated getter/setter. Just didn't want you to be confused when you don't see it there.
thanks for your advice, i'll try to understand what you told me about ctx.body
. Don't worry about the code, relax and have fun at the weekend:)
my code is simple:
i want to log 'ctx' in chrome. but i got this problem:
there is no recursive call in my code, how this happen?