jsir 2.5.3 → 2.5.4
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.
- package/deps/room.js +3 -1
- package/deps/server.js +3 -2
- package/package.json +1 -1
package/deps/room.js
CHANGED
|
@@ -180,7 +180,9 @@ async function syncRooms() {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
if (respBody) {
|
|
183
|
-
|
|
183
|
+
let currRoom = JSON.parse(respBody);
|
|
184
|
+
currRoom.selfNode = node;
|
|
185
|
+
syncRooms.push(currRoom)
|
|
184
186
|
debug(`sync ${node} success`);
|
|
185
187
|
}
|
|
186
188
|
} catch (e) {
|
package/deps/server.js
CHANGED
|
@@ -7,6 +7,7 @@ const preferredPort = setting.defaultPort;
|
|
|
7
7
|
// 路由存储
|
|
8
8
|
const routes = setting.routes;
|
|
9
9
|
let invokeStart = false;
|
|
10
|
+
const apiReg = /[^a-zA-Z]api[^a-zA-Z]|[^a-zA-Z]api$/i;
|
|
10
11
|
|
|
11
12
|
function debug(...args) {
|
|
12
13
|
if (global.$DEBUG) {
|
|
@@ -35,7 +36,7 @@ function createSign() {
|
|
|
35
36
|
async function process(routeKey, req, res, params) {
|
|
36
37
|
let router = routes[routeKey]
|
|
37
38
|
if (router) {
|
|
38
|
-
if ("get /" !== routeKey && !router.isApi) {
|
|
39
|
+
if ("get /" !== routeKey && !router.isApi && !apiReg.test(routeKey)) {
|
|
39
40
|
// 如果不是api接口,则校验签名
|
|
40
41
|
// 取header里的sign字段
|
|
41
42
|
const sign = req.headers['sign'];
|
|
@@ -140,7 +141,7 @@ async function startServer() {
|
|
|
140
141
|
method, url, fn(req, res, err), null
|
|
141
142
|
err: {code, msg}
|
|
142
143
|
*/
|
|
143
|
-
function setRoute(method, url, fn, handler = jsonHandle
|
|
144
|
+
function setRoute(method, url, fn, isApi = false, handler = jsonHandle) {
|
|
144
145
|
startServer();
|
|
145
146
|
|
|
146
147
|
const routeKey = `${method.toLowerCase()} ${url}`;
|