baja-lite 1.7.8 → 1.8.0

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/package.json +10 -13
  2. package/wx/base.js +19 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baja-lite",
3
- "version": "1.7.8",
3
+ "version": "1.8.0",
4
4
  "description": "some util for self",
5
5
  "homepage": "https://github.com/void-soul/baja-lite",
6
6
  "repository": {
@@ -36,8 +36,6 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@msgpack/msgpack": "3.1.3",
39
- "@types/request-promise": "4.1.51",
40
- "baja-lite-field": "1.5.0",
41
39
  "decimal.js": "10.6.0",
42
40
  "html-parse-stringify": "3.0.1",
43
41
  "iterare": "1.2.1",
@@ -45,8 +43,6 @@
45
43
  "pino": "10.3.1",
46
44
  "pino-pretty": "13.1.3",
47
45
  "reflect-metadata": "0.2.2",
48
- "request": "2.88.2",
49
- "request-promise": "4.2.6",
50
46
  "sql-formatter": "15.7.3",
51
47
  "sqlstring": "2.3.3",
52
48
  "tslib": "2.8.1"
@@ -54,21 +50,22 @@
54
50
  "devDependencies": {
55
51
  "@types/better-sqlite3": "7.6.13",
56
52
  "@types/mustache": "4.2.6",
57
- "@types/node": "25.5.0",
53
+ "@types/node": "25.6.0",
58
54
  "@types/shelljs": "0.10.0",
59
55
  "@types/sqlstring": "2.3.2",
60
- "@typescript-eslint/eslint-plugin": "8.57.2",
61
- "@typescript-eslint/parser": "8.57.2",
62
- "axios": "1.14.0",
63
- "better-sqlite3": "12.8.0",
56
+ "@typescript-eslint/eslint-plugin": "8.59.0",
57
+ "@typescript-eslint/parser": "8.59.0",
58
+ "axios": "1.15.2",
59
+ "baja-lite-field": "1.6.0",
60
+ "better-sqlite3": "12.9.0",
64
61
  "ioredis": "5.10.1",
65
- "mongodb": "7.1.1",
66
- "mysql2": "3.20.0",
62
+ "mongodb": "7.2.0",
63
+ "mysql2": "3.22.2",
67
64
  "pg": "8.20.0",
68
65
  "pg-pool": "3.13.0",
69
66
  "redlock": "5.0.0-beta.2",
70
67
  "shelljs": "0.10.0",
71
- "typescript": "5.9.3"
68
+ "typescript": "6.0.3"
72
69
  },
73
70
  "engines": {
74
71
  "node": ">=20"
package/wx/base.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
2
+ import axios from 'axios';
2
3
  import pino from 'pino';
3
- import * as rp from 'request-promise';
4
4
  import { Throw } from '../error.js';
5
5
  const logger = process.env['NODE_ENV'] !== 'production' ? pino({
6
6
  name: 'wx',
@@ -47,32 +47,30 @@ export class BaseWx {
47
47
  if (!needToken || token) {
48
48
  const start = +new Date();
49
49
  let url = uri(token);
50
- const param = method === 'get' ? {
50
+ const config = {
51
51
  method,
52
- json: buffer ? false : true,
53
- qs: data,
54
- encoding: buffer ? null : undefined
55
- } : {
56
- json: data,
57
- method,
58
- encoding: buffer ? null : undefined
52
+ url,
53
+ responseType: buffer ? 'arraybuffer' : 'json',
59
54
  };
60
- let response = await rp.default({
61
- uri: url,
62
- ...param
63
- });
64
- if (this.authErrorCodes.includes(response.errcode)) {
55
+ if (method === 'get') {
56
+ config.params = data;
57
+ }
58
+ else {
59
+ config.data = data;
60
+ }
61
+ let response = await axios(config);
62
+ let result = buffer ? response.data : response.data;
63
+ if (this.authErrorCodes.includes(result.errcode)) {
65
64
  token = await this.getToken(true);
66
65
  url = uri(token);
67
- response = await rp.default({
68
- uri: url,
69
- ...param
70
- });
71
- Throw.if(response.errcode && response.errcode - 0 !== 0, `${url}-${response.errcode}-${response.errmsg}`);
66
+ config.url = url;
67
+ response = await axios(config);
68
+ result = buffer ? response.data : response.data;
69
+ Throw.if(result.errcode && result.errcode - 0 !== 0, `${url}-${result.errcode}-${result.errmsg}`);
72
70
  }
73
- Throw.if(response.errcode && response.errcode - 0 !== 0, `${url}-${response.errcode}-${response.errmsg}`);
71
+ Throw.if(result.errcode && result.errcode - 0 !== 0, `${url}-${result.errcode}-${result.errmsg}`);
74
72
  logger.info(`fetch data ${+new Date() - start} ms`);
75
- return response;
73
+ return result;
76
74
  }
77
75
  }
78
76
  }