-dev.ts
This file
Path
apps/web/src/routes/auth/-dev.ts
26 lines · 957 bytes · TypeScript
Last changed by
Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
line 1why, one step back1// Development only: the leading `-` keeps this module out of the route tree, and only a development build imports 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 2–26why, one step back2import { Handle } from "@repo/protocol/ids";3import { Option, Schema } from "effect";45import type { Handled } from "../../server/session.ts";6import { redirect, returnPath, sessionCookie } from "../../server/session.ts";78const DEV_SESSION_SECONDS = 8 * 60 * 60;910const decodeHandle = Schema.decodeUnknownOption(Handle);1112export const devSignIn = ({ request }: Handled): Response => {13 const here = new URL(request.url);1415 return Option.match(decodeHandle(here.searchParams.get("handle")), {16 onNone: () =>17 new Response("Give a handle: /auth/dev?handle=<handle>", {18 headers: { "cache-control": "no-store" },19 status: 400,20 }),21 onSome: (handle) =>22 redirect(returnPath(here.origin, here.searchParams.get("return")), [23 sessionCookie(`dev-${handle}`, DEV_SESSION_SECONDS),24 ]),25 });26};