
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 · 1966 阅读 · 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 · 612 阅读 · 0 评论