UNPKG

@softr/sdk

Version:

The SDK for building Softr apps on TanStack Start. It lets an app interact with Softr: auth, datasources, workflows and integrations.

13 lines (11 loc) • 689 B
import { assert } from "../assertions.js"; import { getGlobalStartContext } from "@tanstack/react-start"; //#region src/auth/context.ts /** The context that `softrAuthMiddleware` resolved for this request. Server only. */ function readSoftrContext() { const context = getGlobalStartContext(); assert(typeof context === "object" && context !== null && "user" in context && "permissions" in context && "formatting" in context, "softrAuthMiddleware has not run: the Start global context carries no session. Register it as a global request middleware, e.g. createStart(() => ({ requestMiddleware: [softrAuthMiddleware()] }))."); return context; } //#endregion export { readSoftrContext };