Koa.js

概念

中间件 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
  
  1. chrome 打开 chrome://inspect
  2. Remote Target 选择对应的页面
  3. Source - add folder to workspace,在 server.js 中添加断点

附录


Related Posts

GraphQL in Action

GraphQL 解决什么问题 REST-ful Routing Given a collection of records on a server, there should be a uniform URL and HTTP request method to utilize that collection of records. GraphQL 是如何解决问题的

GraphQL小记

基于 GraphQL、express、MongoDB、Apollo、React.js 的小应用。 ->> 项目源码 github 传送门 内容包括:如何搭建基于 GraphQL、express、MongoDB 的后台服务器 如何