This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Data, | |
Effect, | |
Layer, | |
pipe, | |
PubSub, | |
Schedule, | |
Scope, | |
Stream, | |
} from "effect" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Fs from "node:fs/promises" | |
export async function* readLinesReverse(path: string, chunkSize = 1024) { | |
const file = await Fs.open(path, "r") | |
const stat = await file.stat() | |
let pos = stat.size | |
let buffer: Buffer | null = null | |
while (true) { | |
pos = Math.max(0, pos - chunkSize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
HttpApi, | |
HttpApiBuilder, | |
HttpApiEndpoint, | |
HttpApiGroup, | |
HttpApiMiddleware, | |
HttpApiSwagger, | |
HttpServerRequest | |
} from "@effect/platform" | |
import { NodeHttpServer, NodeRuntime } from "@effect/platform-node" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Schema } from "@effect/schema" | |
import * as Model from "./Model.js" | |
import { DateTime } from "effect" | |
export const GroupId = Schema.Number.pipe(Schema.brand("GroupId")) | |
export class Group extends Model.Class<Group>("Group")({ | |
id: Model.PrimaryKey(GroupId), | |
name: Schema.NonEmptyTrimmedString, | |
createdAt: Model.CreatedAt, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Http from "@effect/platform/HttpClient" | |
Http.request.post("https://accounts.spotify.com/api/token").pipe( | |
Http.request.basicAuth(clientId, clientSecret) | |
Http.request.urlParamsBody({ | |
grant_type: "refresh_token", | |
refresh_token: refreshToken, | |
client_id: clientId, | |
}), | |
Http.client.fetchOk, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Http from "@effect/platform/HttpClient" | |
import { Schema } from "@effect/schema" | |
import { Array, Config, Context, Data, Effect, Layer, flow } from "effect" | |
import { Inngest as Inngest_ } from "inngest" | |
class InngestRun extends Schema.Class<InngestRun>("InngestRun")({ | |
run_id: Schema.String, | |
status: Schema.Literal("Running", "Completed", "Failed", "Cancelled"), | |
}) { | |
static decodeArray = Http.response.schemaBodyJsonScoped( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Http from "@effect/platform/HttpClient" | |
import { Context, Effect, Layer, pipe } from "effect" | |
const headers = { | |
Accept: | |
"application/graphql-response+json; charset=utf-8, application/json; charset=utf-8", | |
"Content-Type": "application/json", | |
} | |
export class GraphQLClient extends Context.Tag("graphql-codegen/GraphQLClient")< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Duration, Scope } from "effect" | |
import { Effect, SynchronizedRef } from "effect" | |
export const make = (limit: number, window: Duration.DurationInput): Effect.Effect< | |
<A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>, | |
never, | |
Scope.Scope | |
> => | |
Effect.gen(function*(_) { | |
const scope = yield* _(Effect.scope) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Schema, TreeFormatter } from "@effect/schema" | |
import { | |
Cause, | |
Context, | |
Data, | |
Effect, | |
Either, | |
Layer, | |
Option, | |
PrimaryKey, |
NewerOlder