![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
node
微若年华ヽ
Uncaught
展开
-
基于socket.io +koa2 +天行机器人 实现简单人机实时通讯(nginx处理socket.io https代理问题)
先上实现结果(免费的机器人真的是一言难尽)需要注意的点需要处理开发环境的跨域问题、见代码由于服务器使用了https协议,所以客户端需要用wss。因为我用nginx进行https的转发,因此也需要在nginx上做同步配置(配置在下面)因为是点对点聊天,因此不是广播形式,用steamUsers 来保存每个链接实现步骤服务端koa、http、socket.io等组件的引入及注册const Koa = require('koa')const app = new Koa()const rou原创 2021-08-11 17:00:19 · 1877 阅读 · 3 评论 -
node做中间层
node中间层(一般只处理查询类的请求)解决的问题转发api接口合并缓存// controller 实现缓存var request = require('request');var getIndex = require('../../model/index.js');function index(req, res) { if (global.cache.index) { res.render('index.html', global.cache.index); } els原创 2021-08-06 11:51:56 · 550 阅读 · 0 评论