@domain.js/main 1.0.0-alpha.10 → 1.0.0-alpha.11

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,5 +1,4 @@
1
1
  import axios, { AxiosInstance } from "axios";
2
- import * as utils from "../../utils";
3
2
  import { Main as Logger } from "../logger";
4
3
  interface Cnf {
5
4
  /** axios config */
@@ -17,13 +16,7 @@ interface Cnf {
17
16
  };
18
17
  }
19
18
  interface Deps {
20
- axios: {
21
- create: typeof axios.create;
22
- };
23
19
  logger: ReturnType<typeof Logger>;
24
- utils: {
25
- sleep: typeof utils.sleep;
26
- };
27
20
  }
28
21
  /**
29
22
  * axios module
@@ -35,9 +28,7 @@ interface Deps {
35
28
  */
36
29
  export declare function Main(cnf: Cnf, deps: Deps): AxiosInstance & {
37
30
  /** Original Axios module */
38
- origin?: {
39
- create: (config?: import("axios").CreateAxiosDefaults) => AxiosInstance;
40
- };
31
+ origin?: typeof axios;
41
32
  };
42
33
  export declare const Deps: string[];
43
34
  export {};
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.Deps = void 0;
4
7
  exports.Main = Main;
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const utils_1 = require("../../utils");
5
10
  /**
6
11
  * axios module
7
12
  * @link https://www.npmjs.com/package/axios
@@ -25,7 +30,7 @@ function Main(cnf, deps) {
25
30
  if (!cnf.axios)
26
31
  cnf.axios = {};
27
32
  const { loggers, retrys, retryTimes = 3, retryIntervalMS = 3000, conf } = cnf.axios;
28
- const { axios, utils: { sleep }, logger, } = deps;
33
+ const { logger } = deps;
29
34
  const retryAble = (fn, times, interval) => {
30
35
  const exec = async (args, no) => {
31
36
  try {
@@ -35,7 +40,7 @@ function Main(cnf, deps) {
35
40
  catch (e) {
36
41
  if (e.code === "ETIMEDOUT") {
37
42
  if (interval)
38
- await sleep(interval);
43
+ await (0, utils_1.sleep)(interval);
39
44
  if (times <= no)
40
45
  throw e;
41
46
  return exec(args, no + 1);
@@ -45,8 +50,8 @@ function Main(cnf, deps) {
45
50
  };
46
51
  return ((...args) => exec(args, 1));
47
52
  };
48
- const instance = axios.create(conf);
49
- instance.origin = axios;
53
+ const instance = axios_1.default.create(conf);
54
+ instance.origin = axios_1.default;
50
55
  if (loggers) {
51
56
  for (const x of loggers) {
52
57
  if (typeof instance[x] !== "function")
@@ -64,4 +69,4 @@ function Main(cnf, deps) {
64
69
  }
65
70
  return instance;
66
71
  }
67
- exports.Deps = ["logger", "utils", "axios"];
72
+ exports.Deps = ["logger"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domain.js/main",
3
- "version": "1.0.0-alpha.10",
3
+ "version": "1.0.0-alpha.11",
4
4
  "description": "DDD framework",
5
5
  "main": "dist/index.js",
6
6
  "bin": {