Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
1234567891011121314151617181920212223242526import { error } from "@sveltejs/kit";
export type RepoRole = "owner" | "collaborator" | "none";
export interface RepoAccess { readonly role: RepoRole; readonly canPush: boolean; readonly canAdminister: boolean;}
export const NO_ACCESS: RepoAccess = { role: "none", canPush: false, canAdminister: false };
export const accessFor = (role: RepoRole): RepoAccess => ({ role, canPush: role !== "none", canAdminister: role === "owner"});
export const requireRepoPush = (access: RepoAccess): void => { if (!access.canPush) error(403, "Only the repository owner and collaborators can change this");};
export const requireRepoAdmin = (access: RepoAccess): void => { if (!access.canAdminister) error(403, "Only the repository owner can change this");};