@tuya-sat/micro-script 3.0.27-beta.15 → 3.0.27-beta.16

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.
@@ -1,2 +1,2 @@
1
- import { Application } from "express";
1
+ import { Application } from 'express';
2
2
  export default function useProxy(app: Application): void;
@@ -4,12 +4,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const paths_1 = __importDefault(require("../config/paths"));
7
+ const http_proxy_middleware_1 = require("http-proxy-middleware");
7
8
  function useProxy(app) {
8
- const isProxy = process.env.MICRO_PROXY === "true";
9
+ const isProxy = process.env.MICRO_PROXY === 'true';
10
+ const { debuggerConfig } = require(paths_1.default.microConfig);
9
11
  if (isProxy) {
10
- const createProxy = require("@tuya-sat/micro-dev-proxy").default;
11
- const { debuggerConfig } = require(paths_1.default.microConfig);
12
+ const createProxy = require('@tuya-sat/micro-dev-proxy').default;
12
13
  createProxy(debuggerConfig)(app);
13
14
  }
15
+ const customApi = debuggerConfig === null || debuggerConfig === void 0 ? void 0 : debuggerConfig.customApi;
16
+ if (customApi) {
17
+ app.use(['custom-api'], (0, http_proxy_middleware_1.createProxyMiddleware)({
18
+ target: customApi,
19
+ changeOrigin: true,
20
+ selfHandleResponse: true,
21
+ }));
22
+ }
14
23
  }
15
24
  exports.default = useProxy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-script",
3
- "version": "3.0.27-beta.15",
3
+ "version": "3.0.27-beta.16",
4
4
  "bin": "./dist/bin/cli.js",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
@@ -23,9 +23,9 @@
23
23
  "@babel/preset-typescript": "7.16.7",
24
24
  "@babel/traverse": "^7.20.13",
25
25
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.4",
26
- "@tuya-sat/micro-dev-loader": "3.0.27-beta.15",
27
- "@tuya-sat/micro-dev-proxy": "3.0.27-beta.15",
28
- "@tuya-sat/micro-utils": "3.0.27-beta.15",
26
+ "@tuya-sat/micro-dev-loader": "3.0.27-beta.16",
27
+ "@tuya-sat/micro-dev-proxy": "3.0.27-beta.16",
28
+ "@tuya-sat/micro-utils": "3.0.27-beta.16",
29
29
  "@types/kill-port": "^2.0.0",
30
30
  "babel-loader": "8.2.4",
31
31
  "babel-plugin-import": "1.13.3",