@designliquido/delegua-http 0.1.0 → 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.
- package/fontes/cliente-http.js +6 -6
- package/fontes/cliente-http.js.map +1 -1
- package/index.js +1 -2
- package/index.js.map +1 -1
- package/jest.config.d.ts +3 -0
- package/jest.config.js +12 -0
- package/jest.config.js.map +1 -0
- package/package.json +7 -2
- package/testes/cliente-http.test.d.ts +1 -0
- package/testes/cliente-http.test.js +12 -0
- package/testes/cliente-http.test.js.map +1 -0
package/fontes/cliente-http.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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;
|
|
1
|
+
{"version":3,"file":"cliente-http.js","sourceRoot":"","sources":["../../fontes/cliente-http.ts"],"names":[],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,IAAI,CACrB,CAAC;IACN,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,SAAiB,EAAE,UAAmC;QACzE,MAAM,aAAa,GAA4B,MAAM,IAAI,CAAC,cAAc,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.js
CHANGED
|
@@ -14,7 +14,7 @@ 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 =
|
|
17
|
+
exports.novoClienteHttp = novoClienteHttp;
|
|
18
18
|
const cliente_http_1 = require("./fontes/cliente-http");
|
|
19
19
|
/**
|
|
20
20
|
* Monta o cliente HTTP básico para requisições.
|
|
@@ -28,6 +28,5 @@ const cliente_http_1 = require("./fontes/cliente-http");
|
|
|
28
28
|
function novoClienteHttp(_, urlBase = "", tempoMaximo = 5000, cabecalhos = {}) {
|
|
29
29
|
return new cliente_http_1.ClienteHttp(urlBase, tempoMaximo, cabecalhos);
|
|
30
30
|
}
|
|
31
|
-
exports.novoClienteHttp = novoClienteHttp;
|
|
32
31
|
__exportStar(require("./fontes/resposta-http"), exports);
|
|
33
32
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/jest.config.d.ts
ADDED
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.1.
|
|
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
|
-
"
|
|
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"}
|