mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-02-19 15:25:13 -05:00
* 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
20 lines
647 B
TypeScript
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,
|
|
};
|
|
});
|