Functions to get, update, and set a signed session cookie with validation using Valibot for team and checkout data.
// Source: https://github.com/mperkins0155/giselle | License: Apache-2.0 | Copyright 2024 ROUTE06, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import * as v from "valibot";
import { teamIdSchema } from "@/services/teams/validations";
import { getCookie, setCookie } from "./signed-cookie";
const COOKIE_NAME = "giselle-session";
const GiselleSessionSchema = v.object({
teamId: v.optional(teamIdSchema),
// used in creating a new pro team flow
checkoutSessionId: v.optional(v.string()),
});
type GiselleSession = v.InferOutput<typeof GiselleSessionSchema>;
export async function getGiselleSession(): Promise<GiselleSession | null> {
const rawSession = await getCookie(COOKIE_NAME);
if (rawSession == null) {
return null;
}
return v.parse(GiselleSessionSchema, raw
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key