@navservice/core 1.57.0 → 1.59.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.
@@ -1,31 +1,25 @@
1
- import { AxiosResponse } from "axios";
2
- interface ApiClientOptions {
3
- baseURL?: string;
4
- withAuth?: boolean;
5
- }
1
+ import { AxiosInstance, AxiosResponse } from "axios";
6
2
  export default class api {
7
- private axios;
8
- private withAuth;
9
- constructor({ baseURL, withAuth }: ApiClientOptions);
10
- private get_headers;
11
- get<T = any>({ url, params, setToken }: {
3
+ static get axios(): AxiosInstance;
4
+ private static withAuth;
5
+ private static get_headers;
6
+ static get<T = any>({ url, params, setToken }: {
12
7
  url: string;
13
8
  params?: Record<string, any>;
14
9
  setToken?: boolean;
15
10
  }): Promise<AxiosResponse<T>>;
16
- post<T = any>({ url, data, setToken }: {
11
+ static post<T = any>({ url, data, setToken }: {
17
12
  url: string;
18
13
  data?: any;
19
14
  setToken?: boolean;
20
15
  }): Promise<AxiosResponse<T>>;
21
- patch<T = any>({ url, data, setToken }: {
16
+ static patch<T = any>({ url, data, setToken }: {
22
17
  url: string;
23
18
  data?: any;
24
19
  setToken?: boolean;
25
20
  }): Promise<AxiosResponse<T>>;
26
- delete<T = any>({ url, setToken }: {
21
+ static delete<T = any>({ url, setToken }: {
27
22
  url: string;
28
23
  setToken?: boolean;
29
24
  }): Promise<AxiosResponse<T>>;
30
25
  }
31
- export {};
package/build/es/utils.js CHANGED
@@ -52,18 +52,16 @@ class config_env {
52
52
  }
53
53
  const src_config_env = config_env;
54
54
  class api {
55
- axios;
56
- withAuth;
57
- constructor({ baseURL, withAuth = true }){
58
- this.withAuth = withAuth;
59
- this.axios = axios.create({
60
- baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL ?? baseURL,
55
+ static get axios() {
56
+ return axios.create({
57
+ baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL,
61
58
  headers: {
62
59
  "Content-Type": "application/json"
63
60
  }
64
61
  });
65
62
  }
66
- get_headers(setToken) {
63
+ static withAuth = true;
64
+ static get_headers(setToken) {
67
65
  if (true === setToken && true === this.withAuth) {
68
66
  const auth = utils_session_storage.get_item_session_storage("auth_user");
69
67
  return {
@@ -79,19 +77,19 @@ class api {
79
77
  }
80
78
  };
81
79
  }
82
- async get({ url, params, setToken = true }) {
80
+ static async get({ url, params, setToken = true }) {
83
81
  return this.axios.get(url, {
84
82
  params,
85
83
  ...this.get_headers(setToken)
86
84
  });
87
85
  }
88
- async post({ url, data, setToken = true }) {
86
+ static async post({ url, data, setToken = true }) {
89
87
  return this.axios.post(url, data, this.get_headers(setToken));
90
88
  }
91
- async patch({ url, data, setToken = true }) {
89
+ static async patch({ url, data, setToken = true }) {
92
90
  return this.axios.patch(url, data, this.get_headers(setToken));
93
91
  }
94
- async delete({ url, setToken = true }) {
92
+ static async delete({ url, setToken = true }) {
95
93
  return this.axios.delete(url, this.get_headers(setToken));
96
94
  }
97
95
  }
@@ -1,31 +1,25 @@
1
- import { AxiosResponse } from "axios";
2
- interface ApiClientOptions {
3
- baseURL?: string;
4
- withAuth?: boolean;
5
- }
1
+ import { AxiosInstance, AxiosResponse } from "axios";
6
2
  export default class api {
7
- private axios;
8
- private withAuth;
9
- constructor({ baseURL, withAuth }: ApiClientOptions);
10
- private get_headers;
11
- get<T = any>({ url, params, setToken }: {
3
+ static get axios(): AxiosInstance;
4
+ private static withAuth;
5
+ private static get_headers;
6
+ static get<T = any>({ url, params, setToken }: {
12
7
  url: string;
13
8
  params?: Record<string, any>;
14
9
  setToken?: boolean;
15
10
  }): Promise<AxiosResponse<T>>;
16
- post<T = any>({ url, data, setToken }: {
11
+ static post<T = any>({ url, data, setToken }: {
17
12
  url: string;
18
13
  data?: any;
19
14
  setToken?: boolean;
20
15
  }): Promise<AxiosResponse<T>>;
21
- patch<T = any>({ url, data, setToken }: {
16
+ static patch<T = any>({ url, data, setToken }: {
22
17
  url: string;
23
18
  data?: any;
24
19
  setToken?: boolean;
25
20
  }): Promise<AxiosResponse<T>>;
26
- delete<T = any>({ url, setToken }: {
21
+ static delete<T = any>({ url, setToken }: {
27
22
  url: string;
28
23
  setToken?: boolean;
29
24
  }): Promise<AxiosResponse<T>>;
30
25
  }
31
- export {};
@@ -117,18 +117,16 @@ class config_env {
117
117
 
118
118
 
119
119
  class api {
120
- axios;
121
- withAuth;
122
- constructor({ baseURL, withAuth = true }){
123
- this.withAuth = withAuth;
124
- this.axios = external_axios_default().create({
125
- baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL ?? baseURL,
120
+ static get axios() {
121
+ return external_axios_default().create({
122
+ baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL,
126
123
  headers: {
127
124
  "Content-Type": "application/json"
128
125
  }
129
126
  });
130
127
  }
131
- get_headers(setToken) {
128
+ static withAuth = true;
129
+ static get_headers(setToken) {
132
130
  if (setToken === true && this.withAuth === true) {
133
131
  const auth = utils_session_storage.get_item_session_storage("auth_user");
134
132
  return {
@@ -144,19 +142,19 @@ class api {
144
142
  }
145
143
  };
146
144
  }
147
- async get({ url, params, setToken = true }) {
145
+ static async get({ url, params, setToken = true }) {
148
146
  return this.axios.get(url, {
149
147
  params,
150
148
  ...this.get_headers(setToken)
151
149
  });
152
150
  }
153
- async post({ url, data, setToken = true }) {
151
+ static async post({ url, data, setToken = true }) {
154
152
  return this.axios.post(url, data, this.get_headers(setToken));
155
153
  }
156
- async patch({ url, data, setToken = true }) {
154
+ static async patch({ url, data, setToken = true }) {
157
155
  return this.axios.patch(url, data, this.get_headers(setToken));
158
156
  }
159
- async delete({ url, setToken = true }) {
157
+ static async delete({ url, setToken = true }) {
160
158
  return this.axios.delete(url, this.get_headers(setToken));
161
159
  }
162
160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navservice/core",
3
- "version": "1.57.0",
3
+ "version": "1.59.0",
4
4
  "description": "Service core de todos os micro serviços",
5
5
  "type": "module",
6
6
  "exports": {