Files
zerobyte/app/server/lib/functions/server-constants.ts
Nico 1017f1a38b feat: edit repository form (#507)
* feat: edit repository form

* refactor: local repo path concat as a code migration

* refactor: server constants

* chore: fix lint issue in test file

* refactor: add auth to getServerConstants
2026-02-14 11:49:33 +01:00

20 lines
647 B
TypeScript

import { createServerFn } from "@tanstack/react-start";
import { getRequestHeaders } from "@tanstack/react-start/server";
import { UnauthorizedError } from "http-errors-enhanced";
import { auth } from "~/server/lib/auth";
import { REGISTRATION_ENABLED_KEY, REPOSITORY_BASE } from "~/server/core/constants";
export const getServerConstants = createServerFn({ method: "GET" }).handler(async () => {
const headers = getRequestHeaders();
const session = await auth.api.getSession({ headers });
if (!session?.user) {
throw new UnauthorizedError("Invalid or expired session");
}
return {
REPOSITORY_BASE,
REGISTRATION_ENABLED_KEY,
};
});