who.ts
This file
Path
apps/web/src/features/auth/who.ts
15 lines · 619 bytes · TypeScript
Last changed by
Merge build/comments-web-features into mainoscabrielbefore adoption74bfc72
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 1–15why, one step back1import { Handle } from "@repo/protocol/ids";2import { Effect, Option, Schema } from "effect";3import { FetchHttpClient, HttpClient, HttpClientResponse } from "effect/http";4import { Atom } from "effect/reactivity";56const Who = Schema.Struct({ handle: Schema.optionalKey(Handle) });78export const whoAtom = Atom.make(9 HttpClient.get("/auth/whoami").pipe(10 Effect.flatMap(HttpClientResponse.schemaBodyJson(Who)),11 Effect.map(({ handle }) => Option.fromUndefinedOr(handle)),12 Effect.orElseSucceed(() => Option.none<Handle>()),13 Effect.provide(FetchHttpClient.layer)14 )15).pipe(Atom.withServerValueInitial);