@designliquido/delegua-http 0.0.2 → 0.1.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,11 +1,11 @@
1
- import { AxiosInstance, RawAxiosRequestHeaders } from "axios";
2
- import { RespostaHttp } from "./resposta-http";
3
- export declare class ClienteHttp {
4
- instanciaAxios: AxiosInstance;
5
- constructor(urlBase?: string, tempoMaximo?: number, cabecalhos?: any);
6
- requisicaoGet(sufixoUrl: string, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
7
- requisicaoPost(sufixoUrl: string, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
8
- requisicaoPut(sufixoUrl: string, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
9
- requisicaoDelete(sufixoUrl: string, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
10
- requisicaoPatch(sufixoUrl: string, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
11
- }
1
+ import { AxiosInstance, RawAxiosRequestHeaders } from "axios";
2
+ import { RespostaHttp } from "./resposta-http";
3
+ export declare class ClienteHttp {
4
+ instanciaAxios: AxiosInstance;
5
+ constructor(urlBase?: string, tempoMaximo?: number, cabecalhos?: any);
6
+ requisicaoGet(sufixoUrl: string, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
7
+ requisicaoPost(sufixoUrl: string, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
8
+ requisicaoPut(sufixoUrl: string, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
9
+ requisicaoDelete(sufixoUrl: string, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
10
+ requisicaoPatch(sufixoUrl: string, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
11
+ }
@@ -1,49 +1,49 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ClienteHttp = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- const resposta_http_1 = require("./resposta-http");
9
- class ClienteHttp {
10
- constructor(urlBase = "", tempoMaximo = 5000, cabecalhos = {}) {
11
- this.instanciaAxios = axios_1.default.create({
12
- baseURL: urlBase,
13
- timeout: tempoMaximo,
14
- headers: cabecalhos
15
- });
16
- }
17
- async requisicaoGet(sufixoUrl, cabecalhos) {
18
- const respostaAxios = await this.instanciaAxios.get(sufixoUrl, {
19
- headers: Object.assign({}, cabecalhos)
20
- });
21
- return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
22
- }
23
- async requisicaoPost(sufixoUrl, corpo, cabecalhos) {
24
- const respostaAxios = await this.instanciaAxios.post(sufixoUrl, corpo, {
25
- headers: Object.assign({}, cabecalhos)
26
- });
27
- return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
28
- }
29
- async requisicaoPut(sufixoUrl, corpo, cabecalhos) {
30
- const respostaAxios = await this.instanciaAxios.put(sufixoUrl, corpo, {
31
- headers: Object.assign({}, cabecalhos)
32
- });
33
- return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
34
- }
35
- async requisicaoDelete(sufixoUrl, cabecalhos) {
36
- const respostaAxios = await this.instanciaAxios.delete(sufixoUrl, {
37
- headers: Object.assign({}, cabecalhos)
38
- });
39
- return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
40
- }
41
- async requisicaoPatch(sufixoUrl, corpo, cabecalhos) {
42
- const respostaAxios = await this.instanciaAxios.patch(sufixoUrl, corpo, {
43
- headers: Object.assign({}, cabecalhos)
44
- });
45
- return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
46
- }
47
- }
48
- exports.ClienteHttp = ClienteHttp;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ClienteHttp = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const resposta_http_1 = require("./resposta-http");
9
+ class ClienteHttp {
10
+ constructor(urlBase = "", tempoMaximo = 5000, cabecalhos = {}) {
11
+ this.instanciaAxios = axios_1.default.create({
12
+ baseURL: urlBase,
13
+ timeout: tempoMaximo,
14
+ headers: cabecalhos
15
+ });
16
+ }
17
+ async requisicaoGet(sufixoUrl, cabecalhos) {
18
+ const respostaAxios = await this.instanciaAxios.get(sufixoUrl, {
19
+ headers: Object.assign({}, cabecalhos)
20
+ });
21
+ return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
22
+ }
23
+ async requisicaoPost(sufixoUrl, corpo, cabecalhos) {
24
+ const respostaAxios = await this.instanciaAxios.post(sufixoUrl, corpo, {
25
+ headers: Object.assign({}, cabecalhos)
26
+ });
27
+ return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
28
+ }
29
+ async requisicaoPut(sufixoUrl, corpo, cabecalhos) {
30
+ const respostaAxios = await this.instanciaAxios.put(sufixoUrl, corpo, {
31
+ headers: Object.assign({}, cabecalhos)
32
+ });
33
+ return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
34
+ }
35
+ async requisicaoDelete(sufixoUrl, cabecalhos) {
36
+ const respostaAxios = await this.instanciaAxios.delete(sufixoUrl, {
37
+ headers: Object.assign({}, cabecalhos)
38
+ });
39
+ return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
40
+ }
41
+ async requisicaoPatch(sufixoUrl, corpo, cabecalhos) {
42
+ const respostaAxios = await this.instanciaAxios.patch(sufixoUrl, corpo, {
43
+ headers: Object.assign({}, cabecalhos)
44
+ });
45
+ return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
46
+ }
47
+ }
48
+ exports.ClienteHttp = ClienteHttp;
49
49
  //# sourceMappingURL=cliente-http.js.map
@@ -1,6 +1,6 @@
1
- export declare class RespostaHttp {
2
- codigoStatus: number;
3
- mensagemStatus: string;
4
- dados: any;
5
- constructor(codigoStatus: number, mensagemStatus: string, dados: any);
6
- }
1
+ export declare class RespostaHttp {
2
+ codigoStatus: number;
3
+ mensagemStatus: string;
4
+ dados: any;
5
+ constructor(codigoStatus: number, mensagemStatus: string, dados: any);
6
+ }
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RespostaHttp = void 0;
4
- class RespostaHttp {
5
- constructor(codigoStatus, mensagemStatus, dados) {
6
- this.codigoStatus = codigoStatus;
7
- this.mensagemStatus = mensagemStatus;
8
- this.dados = dados;
9
- }
10
- }
11
- exports.RespostaHttp = RespostaHttp;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RespostaHttp = void 0;
4
+ class RespostaHttp {
5
+ constructor(codigoStatus, mensagemStatus, dados) {
6
+ this.codigoStatus = codigoStatus;
7
+ this.mensagemStatus = mensagemStatus;
8
+ this.dados = dados;
9
+ }
10
+ }
11
+ exports.RespostaHttp = RespostaHttp;
12
12
  //# sourceMappingURL=resposta-http.js.map
package/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
- import { ClienteHttp } from "./fontes/cliente-http";
2
- export declare function novoClienteHttp(urlBase?: string, tempoMaximo?: number, cabecalhos?: any): ClienteHttp;
3
- export * from './fontes/resposta-http';
1
+ import { ClienteHttp } from "./fontes/cliente-http";
2
+ /**
3
+ * Monta o cliente HTTP básico para requisições.
4
+ * @param {any} _ O visitante da instrução, normalmente um interpretador.
5
+ * @param {string} urlBase O prefixo do endereço para a requisição. Por exemplo, https://designliquido.com.br.
6
+ * @param {number} tempoMaximo O tempo máximo de espera para uma requisição responder, em milisegundos.
7
+ * Por padrão, 5000 ms (5 segundos).
8
+ * @param {any} cabecalhos Configurações adicionais de cabeçalhos.
9
+ * @returns {ClienteHttp} Um cliente HTTP configurado e pronto para uso.
10
+ */
11
+ export declare function novoClienteHttp(_: any, urlBase?: string, tempoMaximo?: number, cabecalhos?: any): ClienteHttp;
12
+ export * from './fontes/resposta-http';
package/index.js CHANGED
@@ -1,24 +1,33 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.novoClienteHttp = void 0;
18
- const cliente_http_1 = require("./fontes/cliente-http");
19
- function novoClienteHttp(urlBase = "", tempoMaximo = 5000, cabecalhos = {}) {
20
- return new cliente_http_1.ClienteHttp(urlBase, tempoMaximo, cabecalhos);
21
- }
22
- exports.novoClienteHttp = novoClienteHttp;
23
- __exportStar(require("./fontes/resposta-http"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.novoClienteHttp = void 0;
18
+ const cliente_http_1 = require("./fontes/cliente-http");
19
+ /**
20
+ * Monta o cliente HTTP básico para requisições.
21
+ * @param {any} _ O visitante da instrução, normalmente um interpretador.
22
+ * @param {string} urlBase O prefixo do endereço para a requisição. Por exemplo, https://designliquido.com.br.
23
+ * @param {number} tempoMaximo O tempo máximo de espera para uma requisição responder, em milisegundos.
24
+ * Por padrão, 5000 ms (5 segundos).
25
+ * @param {any} cabecalhos Configurações adicionais de cabeçalhos.
26
+ * @returns {ClienteHttp} Um cliente HTTP configurado e pronto para uso.
27
+ */
28
+ function novoClienteHttp(_, urlBase = "", tempoMaximo = 5000, cabecalhos = {}) {
29
+ return new cliente_http_1.ClienteHttp(urlBase, tempoMaximo, cabecalhos);
30
+ }
31
+ exports.novoClienteHttp = novoClienteHttp;
32
+ __exportStar(require("./fontes/resposta-http"), exports);
24
33
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wDAAoD;AAEpD,SAAgB,eAAe,CAAC,UAAkB,EAAE,EAAE,cAAsB,IAAI,EAAE,aAAkB,EAAE;IAClG,OAAO,IAAI,0BAAW,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAC7D,CAAC;AAFD,0CAEC;AAED,yDAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wDAAoD;AAEpD;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAAC,CAAM,EAAE,UAAkB,EAAE,EAAE,cAAsB,IAAI,EAAE,aAAkB,EAAE;IAC1G,OAAO,IAAI,0BAAW,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAC7D,CAAC;AAFD,0CAEC;AAED,yDAAuC"}
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "@designliquido/delegua-http",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "description": "Biblioteca para acessos HTTP em Delégua",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/DesignLiquido/delegua-http.git"
8
8
  },
9
9
  "scripts": {
10
- "empacotar": "yarn rimraf ./dist && tsc && copyfiles -V ./README.md ./dist && copyfiles -V ./LICENSE ./dist",
10
+ "empacotar": "yarn rimraf ./dist && tsc && yarn copyfiles -V ./README.md ./dist && yarn copyfiles -V ./LICENSE ./dist",
11
11
  "publicar-npm": "npm publish --access public"
12
12
  },
13
13
  "author": "Leonel Sanches da Silva",
14
14
  "dependencies": {
15
- "axios": "^1.4.0"
15
+ "axios": "^1.8.4"
16
16
  },
17
17
  "devDependencies": {
18
- "rimraf": "^5.0.1"
18
+ "copyfiles": "^2.4.1",
19
+ "rimraf": "^6.0.1"
19
20
  }
20
21
  }