socketio封装

This commit is contained in:
robin
2022-05-31 06:52:00 +08:00
parent 96bfa3f2d3
commit c764e7097d
9 changed files with 77 additions and 4 deletions
+6 -1
View File
@@ -1,6 +1,7 @@
const Koa = require("koa")
const glob = require("glob")
const path = require('path')
const xe = require("xe-utils")
/**
* bamboo 核心
@@ -10,12 +11,12 @@ module.exports = class Bamboo extends Koa {
/*初始化业务目录*/
constructor(extend_directory, root) {
super();
this.xe = xe
this.root = this.isPath() || root;
this.extend_directory = extend_directory || `extend/*/index.js`
console.log(`当前根目录${this.root}`);
console.log(`当前插件目录${this.extend_directory}`);
this.loadEvent()
this.startServer()
}
/*加载扩展库目录*/
@@ -24,6 +25,7 @@ module.exports = class Bamboo extends Koa {
for (let listElement of list) {
await listElement.res(this)
}
this.startServer()
}
/*当前根目录*/
@@ -55,8 +57,11 @@ module.exports = class Bamboo extends Koa {
})
}
/*启动服务*/
startServer(prod) {
this.listen(prod || 3000)
console.log('启动服务:3000');
}
}
+2 -1
View File
@@ -10,6 +10,7 @@
"license": "ISC",
"dependencies": {
"glob": "^8.0.3",
"koa": "^2.13.4"
"koa": "^2.13.4",
"xe-utils": "^3.5.4"
}
}