@effect/platform-node
Advanced tools
Comparing version 0.11.4 to 0.11.5
@@ -42,3 +42,3 @@ "use strict"; | ||
exports.agentLayer = agentLayer; | ||
const fromAgent = agent => request => Effect.flatMap(UrlParams.makeUrl(request.url, request.urlParams, _ => Error.RequestError({ | ||
const fromAgent = agent => Client.make(request => Effect.flatMap(UrlParams.makeUrl(request.url, request.urlParams, _ => Error.RequestError({ | ||
request, | ||
@@ -63,3 +63,3 @@ reason: "InvalidUrl", | ||
}))); | ||
})); | ||
}))); | ||
const sendBody = (nodeRequest, request, body) => Effect.suspend(() => { | ||
@@ -66,0 +66,0 @@ switch (body._tag) { |
{ | ||
"name": "@effect/platform-node", | ||
"version": "0.11.4", | ||
"version": "0.11.5", | ||
"description": "Unified interfaces for common platform-specific services", | ||
@@ -31,4 +31,4 @@ "license": "MIT", | ||
"@effect/stream": "^0.34.0", | ||
"@effect/platform": "^0.11.4" | ||
"@effect/platform": "^0.11.5" | ||
} | ||
} |
@@ -54,34 +54,36 @@ import * as Context from "@effect/data/Context" | ||
const fromAgent = (agent: NodeClient.HttpAgent): Client.Client.Default => (request) => | ||
Effect.flatMap( | ||
UrlParams.makeUrl(request.url, request.urlParams, (_) => | ||
Error.RequestError({ | ||
request, | ||
reason: "InvalidUrl", | ||
error: _ | ||
})), | ||
(url) => | ||
Effect.suspend(() => { | ||
const controller = new AbortController() | ||
const nodeRequest = url.protocol === "https:" ? | ||
Https.request(url, { | ||
agent: agent.https, | ||
method: request.method, | ||
headers: Object.fromEntries(request.headers), | ||
signal: controller.signal | ||
}) : | ||
Http.request(url, { | ||
agent: agent.http, | ||
method: request.method, | ||
headers: Object.fromEntries(request.headers), | ||
signal: controller.signal | ||
}) | ||
return pipe( | ||
Effect.zipRight(sendBody(nodeRequest, request, request.body), waitForResponse(nodeRequest), { | ||
concurrent: true | ||
}), | ||
Effect.onInterrupt(() => Effect.sync(() => controller.abort())), | ||
Effect.map((_) => new ClientResponseImpl(request, _)) | ||
) | ||
}) | ||
const fromAgent = (agent: NodeClient.HttpAgent): Client.Client.Default => | ||
Client.make((request) => | ||
Effect.flatMap( | ||
UrlParams.makeUrl(request.url, request.urlParams, (_) => | ||
Error.RequestError({ | ||
request, | ||
reason: "InvalidUrl", | ||
error: _ | ||
})), | ||
(url) => | ||
Effect.suspend(() => { | ||
const controller = new AbortController() | ||
const nodeRequest = url.protocol === "https:" ? | ||
Https.request(url, { | ||
agent: agent.https, | ||
method: request.method, | ||
headers: Object.fromEntries(request.headers), | ||
signal: controller.signal | ||
}) : | ||
Http.request(url, { | ||
agent: agent.http, | ||
method: request.method, | ||
headers: Object.fromEntries(request.headers), | ||
signal: controller.signal | ||
}) | ||
return pipe( | ||
Effect.zipRight(sendBody(nodeRequest, request, request.body), waitForResponse(nodeRequest), { | ||
concurrent: true | ||
}), | ||
Effect.onInterrupt(() => Effect.sync(() => controller.abort())), | ||
Effect.map((_) => new ClientResponseImpl(request, _)) | ||
) | ||
}) | ||
) | ||
) | ||
@@ -88,0 +90,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
293156
4812