Tests
All checks were successful
Lint / lint (push) Successful in 11s

This commit is contained in:
Julien Valverdé
2026-01-23 17:22:19 +01:00
parent 9f2704333b
commit c1a52d29d4
3 changed files with 88 additions and 3 deletions

View File

@@ -38,9 +38,10 @@
"clean:modules": "rm -rf node_modules"
},
"devDependencies": {
"@effect/platform-browser": "^0.74.0"
"@effect/platform-node": "^0.104.1"
},
"peerDependencies": {
"@effect/platform": "^0.94.2",
"effect": "^3.19.0"
}
}

View File

@@ -0,0 +1,25 @@
import net from "node:net"
import { HttpClient } from "@effect/platform"
import { NodeHttpClient, NodeRuntime } from "@effect/platform-node"
import { Effect, Layer } from "effect"
const DockerSocketAgent = Effect.acquireRelease(
Effect.sync(() => net.createConnection({ path: "/var/run/docker.sock" })),
socket => Effect.sync(() => socket.end()),
).pipe(
Effect.andThen(socket => NodeHttpClient.makeAgentLayer({ socket })),
Layer.unwrapScoped,
)
const DockerHttpClient = Layer.provide(NodeHttpClient.layerWithoutAgent, DockerSocketAgent)
Effect.gen(function*() {
const client = yield* HttpClient.HttpClient
const response = yield* client.get("http://localhost/containers/json")
console.log(yield* response.json)
}).pipe(
Effect.provide(DockerHttpClient),
NodeRuntime.runMain,
)