@domain.js/main 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/http/socket.js +13 -13
  2. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BridgeSocket = void 0;
4
4
  const basic_errors_1 = require("../basic-errors");
5
- const proxyIps = new Set(["127.0.0.1"]);
5
+ const proxyIps = new Set((process.env["PROXY_IPS"] || "127.0.0.1").split(","));
6
6
  class MyError extends Error {
7
7
  constructor(code, message, data) {
8
8
  super(message);
@@ -91,13 +91,13 @@ function BridgeSocket(io, domain) {
91
91
  });
92
92
  console.log("[%s] connection: client.id: %s", new Date(), client.id);
93
93
  client.on("init", async (type, auth, extra = {}) => {
94
- if (client.inited)
95
- throw basic_errors_1.errors.notAllowed("已经初始化,请勿重复操作");
96
- if (client.extra.initing)
97
- throw basic_errors_1.errors.notAllowed("正在初始化,请勿重复操作");
98
- client.extra.initing = true;
99
- console.log("[%s] socket.init: client.id: %s", new Date(), client.id);
100
94
  try {
95
+ if (client.inited)
96
+ throw basic_errors_1.errors.notAllowed("已经初始化,请勿重复操作");
97
+ if (client.extra.initing)
98
+ throw basic_errors_1.errors.notAllowed("正在初始化,请勿重复操作");
99
+ client.extra.initing = true;
100
+ console.log("[%s] socket.init: client.id: %s", new Date(), client.id);
101
101
  Object.assign(client, { profile: makeProfile(client, type, auth, extra) });
102
102
  if (!client.profile)
103
103
  throw new MyError("noAuth", "请先登录");
@@ -116,10 +116,10 @@ function BridgeSocket(io, domain) {
116
116
  client.extra.initing = false;
117
117
  });
118
118
  client.on("entrance", async (roomId, ...opts) => {
119
- if (client.extra.entrancing)
120
- throw basic_errors_1.errors.notAllowed("正在进入房间,请勿重复操作");
121
- client.extra.entrancing = true;
122
119
  try {
120
+ if (client.extra.entrancing)
121
+ throw basic_errors_1.errors.notAllowed("正在进入房间,请勿重复操作");
122
+ client.extra.entrancing = true;
123
123
  if (!client.profile || !client.inited)
124
124
  throw basic_errors_1.errors.notAllowed("请先执行 init");
125
125
  if (opts.length)
@@ -139,10 +139,10 @@ function BridgeSocket(io, domain) {
139
139
  client.use(async ([name, params, responseId], next) => {
140
140
  if (name === "init" || name === "entrance")
141
141
  return next();
142
- if (!client.methods)
143
- throw new MyError("没有允许执行的方法", "请先进入房间");
144
- const method = client.methods[name];
145
142
  try {
143
+ if (!client.methods)
144
+ throw new MyError("没有允许执行的方法", "请先进入房间");
145
+ const method = client.methods[name];
146
146
  if (!method)
147
147
  throw new MyError("notFound", `不存在该领域方法: ${name}`);
148
148
  if (!client.profile)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domain.js/main",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "DDD framework",
5
5
  "main": "dist/index.js",
6
6
  "bin": {