Skip to content

Commit

Permalink
feat: add httpie type for Error and Respond (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreMalaj authored Sep 10, 2024
1 parent 820f704 commit e70c419
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export * from "./retry";
export * as policies from "./policies";
export { agents, computeURI, CustomHttpAgent } from "./agents";
export { DEFAULT_HEADER, isHTTPError, isHttpieError } from "./utils";

export { HttpieOnHttpError } from "./class/HttpieOnHttpError";
export * from "./class/undiciResponseHandler";

export {
Expand Down
1 change: 0 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,3 @@ export function getCurrentEnv() {

return "dev";
}

4 changes: 2 additions & 2 deletions test/__snapshots__/request.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`http.get should throw a 404 Not Found error because the path is not kno
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache/2.4.59 (Debian) Server at ws-dev.myunisoft.fr Port 443</address>
<address>Apache/2.4.58 (Ubuntu) Server at ws.dev.myunisoft.tech Port 80</address>
</body></html>
"
`;
Expand All @@ -21,7 +21,7 @@ exports[`http.safeGet should throw a 404 Not Found error because the path is not
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache/2.4.59 (Debian) Server at ws-dev.myunisoft.fr Port 443</address>
<address>Apache/2.4.58 (Ubuntu) Server at ws.dev.myunisoft.tech Port 80</address>
</body></html>
"
`;
4 changes: 2 additions & 2 deletions test/agents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { windev } from "./helpers";
import * as Agents from "../src/agents";

// CONSTANTS
const kWindevMonitoringURL = "https://ws-dev.myunisoft.fr/ws_monitoring";
const kWindevMonitoringURL = "https://ws.dev.myunisoft.tech/ws_monitoring";

describe("agents", () => {
it("should be an Array of CustomHttpAgent and must remain extensible", () => {
Expand Down Expand Up @@ -50,7 +50,7 @@ describe("computeURIOnAllAgents", () => {

describe("detectAgentFromURI", () => {
it("should detect windev agent with URI hostname", () => {
const returnedAgent = Agents.detectAgentFromURI(new URL("https://ws-dev.myunisoft.fr"));
const returnedAgent = Agents.detectAgentFromURI(new URL("https://ws.dev.myunisoft.tech"));

expect(returnedAgent).toStrictEqual(windev);
});
Expand Down
8 changes: 4 additions & 4 deletions test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { CustomHttpAgent, agents } from "../src/agents";
const windev: CustomHttpAgent = {
customPath: "windev",
domains: new Set([
"ws-dev.myunisoft.fr"
"ws.dev.myunisoft.tech"
]),
agent: new undici.Agent({
connections: 500
}),
prod: "https://ws-dev.myunisoft.fr",
preprod: "https://ws-dev.myunisoft.fr",
dev: "https://ws-dev.myunisoft.fr"
prod: "https://ws.dev.myunisoft.tech",
preprod: "https://ws.dev.myunisoft.tech",
dev: "https://ws.dev.myunisoft.tech"
};
agents.add(windev);

Expand Down
2 changes: 1 addition & 1 deletion test/request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe("http.get", () => {
});

it("should GET json response from node.js health endpoint", async() => {
const { data } = await get<any>("https://yoda.myunisoft.fr:1337/api/authenticate/healthz");
const { data } = await get<any>("https://app.dev.myunisoft.tech/api/authenticate/healthz");

expect(Object.keys(data).sort()).toMatchObject([
"status", "version", "description", "checks"
Expand Down

0 comments on commit e70c419

Please sign in to comment.