@navservice/core 1.57.0 → 1.58.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
1
  import { AxiosResponse } from "axios";
2
- interface ApiClientOptions {
3
- baseURL?: string;
4
- withAuth?: boolean;
5
- }
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
+ private static axios;
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,14 @@ 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,
61
- headers: {
62
- "Content-Type": "application/json"
63
- }
64
- });
65
- }
66
- get_headers(setToken) {
55
+ static axios = axios.create({
56
+ baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL,
57
+ headers: {
58
+ "Content-Type": "application/json"
59
+ }
60
+ });
61
+ static withAuth = true;
62
+ static get_headers(setToken) {
67
63
  if (true === setToken && true === this.withAuth) {
68
64
  const auth = utils_session_storage.get_item_session_storage("auth_user");
69
65
  return {
@@ -79,19 +75,19 @@ class api {
79
75
  }
80
76
  };
81
77
  }
82
- async get({ url, params, setToken = true }) {
78
+ static async get({ url, params, setToken = true }) {
83
79
  return this.axios.get(url, {
84
80
  params,
85
81
  ...this.get_headers(setToken)
86
82
  });
87
83
  }
88
- async post({ url, data, setToken = true }) {
84
+ static async post({ url, data, setToken = true }) {
89
85
  return this.axios.post(url, data, this.get_headers(setToken));
90
86
  }
91
- async patch({ url, data, setToken = true }) {
87
+ static async patch({ url, data, setToken = true }) {
92
88
  return this.axios.patch(url, data, this.get_headers(setToken));
93
89
  }
94
- async delete({ url, setToken = true }) {
90
+ static async delete({ url, setToken = true }) {
95
91
  return this.axios.delete(url, this.get_headers(setToken));
96
92
  }
97
93
  }
@@ -1,31 +1,25 @@
1
1
  import { AxiosResponse } from "axios";
2
- interface ApiClientOptions {
3
- baseURL?: string;
4
- withAuth?: boolean;
5
- }
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
+ private static axios;
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,14 @@ 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,
126
- headers: {
127
- "Content-Type": "application/json"
128
- }
129
- });
130
- }
131
- get_headers(setToken) {
120
+ static axios = external_axios_default().create({
121
+ baseURL: src_config_env.PUBLIC_BASE_URL_BACKEND_PRINCIPAL,
122
+ headers: {
123
+ "Content-Type": "application/json"
124
+ }
125
+ });
126
+ static withAuth = true;
127
+ static get_headers(setToken) {
132
128
  if (setToken === true && this.withAuth === true) {
133
129
  const auth = utils_session_storage.get_item_session_storage("auth_user");
134
130
  return {
@@ -144,19 +140,19 @@ class api {
144
140
  }
145
141
  };
146
142
  }
147
- async get({ url, params, setToken = true }) {
143
+ static async get({ url, params, setToken = true }) {
148
144
  return this.axios.get(url, {
149
145
  params,
150
146
  ...this.get_headers(setToken)
151
147
  });
152
148
  }
153
- async post({ url, data, setToken = true }) {
149
+ static async post({ url, data, setToken = true }) {
154
150
  return this.axios.post(url, data, this.get_headers(setToken));
155
151
  }
156
- async patch({ url, data, setToken = true }) {
152
+ static async patch({ url, data, setToken = true }) {
157
153
  return this.axios.patch(url, data, this.get_headers(setToken));
158
154
  }
159
- async delete({ url, setToken = true }) {
155
+ static async delete({ url, setToken = true }) {
160
156
  return this.axios.delete(url, this.get_headers(setToken));
161
157
  }
162
158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navservice/core",
3
- "version": "1.57.0",
3
+ "version": "1.58.0",
4
4
  "description": "Service core de todos os micro serviços",
5
5
  "type": "module",
6
6
  "exports": {