@designliquido/delegua-http 0.0.3 → 0.1.1

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.
@@ -9,37 +9,37 @@ const resposta_http_1 = require("./resposta-http");
9
9
  class ClienteHttp {
10
10
  constructor(urlBase = "", tempoMaximo = 5000, cabecalhos = {}) {
11
11
  this.instanciaAxios = axios_1.default.create({
12
- baseURL: urlBase,
12
+ baseURL: `${urlBase}`,
13
13
  timeout: tempoMaximo,
14
14
  headers: cabecalhos
15
15
  });
16
16
  }
17
17
  async requisicaoGet(sufixoUrl, cabecalhos) {
18
- const respostaAxios = await this.instanciaAxios.get(sufixoUrl, {
18
+ const respostaAxios = await this.instanciaAxios.get(`${sufixoUrl}`, {
19
19
  headers: Object.assign({}, cabecalhos)
20
20
  });
21
21
  return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
22
22
  }
23
23
  async requisicaoPost(sufixoUrl, corpo, cabecalhos) {
24
- const respostaAxios = await this.instanciaAxios.post(sufixoUrl, corpo, {
24
+ const respostaAxios = await this.instanciaAxios.post(`${sufixoUrl}`, corpo, {
25
25
  headers: Object.assign({}, cabecalhos)
26
26
  });
27
27
  return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
28
28
  }
29
29
  async requisicaoPut(sufixoUrl, corpo, cabecalhos) {
30
- const respostaAxios = await this.instanciaAxios.put(sufixoUrl, corpo, {
30
+ const respostaAxios = await this.instanciaAxios.put(`${sufixoUrl}`, corpo, {
31
31
  headers: Object.assign({}, cabecalhos)
32
32
  });
33
33
  return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
34
34
  }
35
35
  async requisicaoDelete(sufixoUrl, cabecalhos) {
36
- const respostaAxios = await this.instanciaAxios.delete(sufixoUrl, {
36
+ const respostaAxios = await this.instanciaAxios.delete(`${sufixoUrl}`, {
37
37
  headers: Object.assign({}, cabecalhos)
38
38
  });
39
39
  return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
40
40
  }
41
41
  async requisicaoPatch(sufixoUrl, corpo, cabecalhos) {
42
- const respostaAxios = await this.instanciaAxios.patch(sufixoUrl, corpo, {
42
+ const respostaAxios = await this.instanciaAxios.patch(`${sufixoUrl}`, corpo, {
43
43
  headers: Object.assign({}, cabecalhos)
44
44
  });
45
45
  return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
@@ -1 +1 @@
1
- {"version":3,"file":"cliente-http.js","sourceRoot":"","sources":["../../fontes/cliente-http.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAoF;AACpF,mDAA+C;AAE/C,MAAa,WAAW;IAGpB,YAAY,UAAkB,EAAE,EAAE,cAAsB,IAAI,EAAE,aAAkB,EAAE;QAC9E,IAAI,CAAC,cAAc,GAAG,eAAK,CAAC,MAAM,CAAC;YAC/B,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,WAAW;YACpB,OAAO,EAAE,UAAU;SACtB,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,SAAiB,EAAE,UAAmC;QACtE,MAAM,aAAa,GAA4B,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CACxE,SAAS,EACT;YACI,OAAO,oBACA,UAAU,CAChB;SACJ,CACJ,CAAC;QAEF,OAAO,IAAI,4BAAY,CACnB,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,IAAI,CACrB,CAAC;IACN,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,SAAiB,EAAE,KAAU,EAAE,UAAmC;QACnF,MAAM,aAAa,GAA4B,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CACzE,SAAS,EACT,KAAK,EACL;YACI,OAAO,oBACA,UAAU,CAChB;SACJ,CACJ,CAAC;QAEF,OAAO,IAAI,4BAAY,CACnB,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,IAAI,CACrB,CAAC;IACN,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,SAAiB,EAAE,KAAU,EAAE,UAAmC;QAClF,MAAM,aAAa,GAA4B,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CACxE,SAAS,EACT,KAAK,EACL;YACI,OAAO,oBACA,UAAU,CAChB;SACJ,CACJ,CAAC;QAEF,OAAO,IAAI,4BAAY,CACnB,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,IAAI,CACrB,CAAC;IACN,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,SAAiB,EAAE,UAAmC;QACzE,MAAM,aAAa,GAA4B,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAC3E,SAAS,EACT;YACI,OAAO,oBACA,UAAU,CAChB;SACJ,CACJ,CAAC;QAEF,OAAO,IAAI,4BAAY,CACnB,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,IAAI,CACrB,CAAC;IACN,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,SAAiB,EAAE,KAAU,EAAE,UAAmC;QACpF,MAAM,aAAa,GAA4B,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAC1E,SAAS,EACT,KAAK,EACL;YACI,OAAO,oBACA,UAAU,CAChB;SACJ,CACJ,CAAC;QAEF,OAAO,IAAI,4BAAY,CACnB,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,IAAI,CACrB,CAAC;IACN,CAAC;CACJ;AAlGD,kCAkGC"}
1
+ {"version":3,"file":"cliente-http.js","sourceRoot":"","sources":["../../fontes/cliente-http.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAoF;AACpF,mDAA+C;AAE/C,MAAa,WAAW;IAGpB,YAAY,UAAkB,EAAE,EAAE,cAAsB,IAAI,EAAE,aAAkB,EAAE;Q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Ac,CAAC,MAAM,CAC3E,GAAG,SAAS,EAAE,EACd;YACI,OAAO,oBACA,UAAU,CAChB;SACJ,CACJ,CAAC;QAEF,OAAO,IAAI,4BAAY,CACnB,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,IAAI,CACrB,CAAC;IACN,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,SAAiB,EAAE,KAAU,EAAE,UAAmC;QACpF,MAAM,aAAa,GAA4B,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAC1E,GAAG,SAAS,EAAE,EACd,KAAK,EACL;YACI,OAAO,oBACA,UAAU,CAChB;SACJ,CACJ,CAAC;QAEF,OAAO,IAAI,4BAAY,CACnB,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,UAAU,EACxB,aAAa,CAAC,IAAI,CACrB,CAAC;IACN,CAAC;CACJ;AAlGD,kCAkGC"}
package/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
1
  import { ClienteHttp } from "./fontes/cliente-http";
2
- export declare function novoClienteHttp(urlBase?: string, tempoMaximo?: number, cabecalhos?: any): ClienteHttp;
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;
3
12
  export * from './fontes/resposta-http';
package/index.js CHANGED
@@ -14,11 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.novoClienteHttp = void 0;
17
+ exports.novoClienteHttp = novoClienteHttp;
18
18
  const cliente_http_1 = require("./fontes/cliente-http");
19
- function novoClienteHttp(urlBase = "", tempoMaximo = 5000, cabecalhos = {}) {
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 = {}) {
20
29
  return new cliente_http_1.ClienteHttp(urlBase, tempoMaximo, cabecalhos);
21
30
  }
22
- exports.novoClienteHttp = novoClienteHttp;
23
31
  __exportStar(require("./fontes/resposta-http"), exports);
24
32
  //# 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":";;;;;;;;;;;;;;;;AAWA,0CAEC;AAbD,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;AAED,yDAAuC"}
@@ -0,0 +1,3 @@
1
+ import type { Config } from '@jest/types';
2
+ declare const _default: () => Promise<Config.InitialOptions>;
3
+ export default _default;
package/jest.config.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = async () => {
4
+ return {
5
+ verbose: true,
6
+ modulePathIgnorePatterns: ['<rootDir>/dist/'],
7
+ preset: 'ts-jest',
8
+ testEnvironment: 'node',
9
+ coverageReporters: ['text', 'text-summary', 'lcov'],
10
+ };
11
+ };
12
+ //# sourceMappingURL=jest.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest.config.js","sourceRoot":"","sources":["../jest.config.ts"],"names":[],"mappings":";;AAEA,kBAAe,KAAK,IAAoC,EAAE;IACtD,OAAO;QACH,OAAO,EAAE,IAAI;QACb,wBAAwB,EAAE,CAAC,iBAAiB,CAAC;QAC7C,MAAM,EAAE,SAAS;QACjB,eAAe,EAAE,MAAM;QACvB,iBAAiB,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC;KACtD,CAAC;AACN,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@designliquido/delegua-http",
3
- "version": "0.0.3",
3
+ "version": "0.1.1",
4
4
  "description": "Biblioteca para acessos HTTP em Delégua",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,12 @@
15
15
  "axios": "^1.8.4"
16
16
  },
17
17
  "devDependencies": {
18
+ "@types/jest": "^29.5.14",
18
19
  "copyfiles": "^2.4.1",
19
- "rimraf": "^6.0.1"
20
+ "jest": "^29.7.0",
21
+ "rimraf": "^6.0.1",
22
+ "ts-jest": "^29.3.1",
23
+ "ts-node": "^10.9.2",
24
+ "typescript": "^5.8.3"
20
25
  }
21
26
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const __1 = require("..");
4
+ describe('Cliente HTTP', () => {
5
+ it('Deve trazer dados com sucesso', async () => {
6
+ const clienteHttp = (0, __1.novoClienteHttp)(undefined, "https://github.com");
7
+ const resultado = await clienteHttp.requisicaoGet("/DesignLiquido/delegua");
8
+ expect(resultado).toBeTruthy();
9
+ expect(resultado.codigoStatus).toBe(200);
10
+ });
11
+ });
12
+ //# sourceMappingURL=cliente-http.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cliente-http.test.js","sourceRoot":"","sources":["../../testes/cliente-http.test.ts"],"names":[],"mappings":";;AAAA,0BAAqC;AAErC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,WAAW,GAAG,IAAA,mBAAe,EAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QACrE,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC;QAC5E,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;QAC/B,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}