Koa.js
1 min
概念
中间件 middleware
app.use(async (ctx, next) => {
// ctx, context, 上下文
console.log(`${ctx.method} ${ctx.url} ${new Date()}`);
// next, promise,下一步
return await next();
});
调试
VSCode
VS Code 侧边栏的“调试”,在代码中设置断点。
Chrome
node --inspect server.js
- chrome 打开
chrome://inspect
- Remote Target 选择对应的页面
- Source - add folder to workspace,在
server.js
中添加断点