@tuya-sat/micro-dev-proxy 3.0.9 → 3.0.10

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/appProxy.js +18 -16
  2. package/package.json +1 -1
package/dist/appProxy.js CHANGED
@@ -146,23 +146,25 @@ class AppProxy {
146
146
  this.log('----json parse responseBuffer string error-----', err);
147
147
  return responseBuffer;
148
148
  }
149
- const apiPathMatchReg = /\/(:[^/]+|\$?{[^/]+})/g;
150
- const apis = mf.apis || [];
151
- if (!(req === null || req === void 0 ? void 0 : req.headers['micro-app-id'].includes('main-app'))) {
152
- const method = (req === null || req === void 0 ? void 0 : req.method) || 'GET';
153
- const urlPath = ((_a = req === null || req === void 0 ? void 0 : req.path) === null || _a === void 0 ? void 0 : _a.replace(/^\s*\/(custom-api|open-api)/, '')) || '';
154
- let isExists = false;
155
- apis.forEach((api) => {
156
- const isLegal = new RegExp(`^${api.path.replace(apiPathMatchReg, '/[^/]+')}/?$`).test(urlPath);
157
- if (isLegal && method.toLowerCase() === api.method.toLowerCase()) {
158
- isExists = true;
159
- }
160
- });
161
- if (!isExists) {
162
- return JSON.stringify({
163
- msg: `${method}:${urlPath} 未在manifest.json中注册`,
164
- code: '888888',
149
+ if (!this.isMainApp) {
150
+ const apiPathMatchReg = /\/(:[^/]+|\$?{[^/]+})/g;
151
+ const apis = mf.apis || [];
152
+ if (!(req === null || req === void 0 ? void 0 : req.headers['micro-app-id'].includes('main-app'))) {
153
+ const method = (req === null || req === void 0 ? void 0 : req.method) || 'GET';
154
+ const urlPath = ((_a = req === null || req === void 0 ? void 0 : req.path) === null || _a === void 0 ? void 0 : _a.replace(/^\s*\/(custom-api|open-api)/, '')) || '';
155
+ let isExists = false;
156
+ apis.forEach((api) => {
157
+ const isLegal = new RegExp(`^${api.path.replace(apiPathMatchReg, '/[^/]+')}/?$`).test(urlPath);
158
+ if (isLegal && method.toLowerCase() === api.method.toLowerCase()) {
159
+ isExists = true;
160
+ }
165
161
  });
162
+ if (!isExists) {
163
+ return JSON.stringify({
164
+ msg: `${method}:${urlPath} 未在manifest.json中注册`,
165
+ code: '888888',
166
+ });
167
+ }
166
168
  }
167
169
  }
168
170
  if (response.code === 1010 && !this.isMainApp) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-dev-proxy",
3
- "version": "3.0.9",
3
+ "version": "3.0.10",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {