![](https://img-blog.csdnimg.cn/2019091813595558.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
node-koa2
1
Specialize in Linxu
代码就是不断发现问题从而解决问题!
展开
-
node-js中间件实现的机制---洋葱圈模型
const Koa = require('koa'); const app = new Koa(); app.use(async (ctx, next) => { console.log(1); await next(); console.log(6); }); app.use(async (ctx, next) => { console.log(2); await next(); console.log(5); }); app.use(as原创 2020-07-05 23:21:22 · 591 阅读 · 0 评论 -
使用node.js实现访问/api/blog/list制造一个get接口
第一步 我们需要新建一个js文件夹 比如bolglist.js文件 const router = require('koa-router')() router.prefix('/api/blog') router.get('/', function (ctx, next) { ctx.body = 'this is a users response!' }) router.get('/list', function (ctx, next) { // const query =ctx.query原创 2020-07-05 19:39:55 · 172 阅读 · 0 评论 -
node-js实现访问8000端口出现hello koa2
node实现打印第一个hello world 首先我们需要安装node 这个在本次博客就省略了 第一步 npm install koa-generator -g 第二步:建立文件夹 koa2 blog-koa2 第三步 cd blog-koa2 && npm install 安装环境参数 nodo-env npm cross-env 然后我们可以在vscode将package.json中 "dev": "cross-env NODE_ENV=dev./node_modules/.b原创 2020-07-05 18:47:29 · 266 阅读 · 0 评论