Skip to content

Commit

Permalink
clean up DadJokes (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Jun 26, 2024
1 parent 819b1e3 commit 02b18bf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/DadJokes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ import {
HttpClientResponse,
} from "@effect/platform"
import { Schema } from "@effect/schema"
import { DiscordIxLive, InteractionsRegistry } from "dfx/gateway"
import { InteractionsRegistry } from "dfx/gateway"
import { Ix } from "dfx"
import { Effect, flow, Layer, Schedule } from "effect"
import { NodeHttpClient } from "@effect/platform-node"
import { DiscordLive } from "./Discord.js"

const make = Effect.gen(function* () {
const client = (yield* HttpClient.HttpClient).pipe(
HttpClient.mapRequest(
flow(HttpClientRequest.prependUrl("https://icanhazdadjoke.com")),
flow(
HttpClientRequest.prependUrl("https://icanhazdadjoke.com"),
HttpClientRequest.acceptJson,
),
),
)

const getJoke = HttpClientRequest.get("/").pipe(
HttpClientRequest.acceptJson,
client,
HttpClientResponse.schemaBodyJsonScoped(Joke),
Effect.retry({
times: 3,
schedule: Schedule.exponential(200),
}),
Effect.orDie,
Effect.withSpan("DadJokes.getJoke"),
)

// discord
Expand Down

0 comments on commit 02b18bf

Please sign in to comment.