Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add httpie type for Error and Respond #256

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading