Edits history of script submission #2043 for ' Set interaction restrictions for your public repositories (github)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Github = {
      token: string;
    };
    /**
     * Set interaction restrictions for your public repositories
     * Temporarily restricts which type of GitHub user can interact with your public repositories. Setting the interaction limit at the user level will overwrite any interaction limits that are set for individual repositories owned by the user.
     */
    export async function main(
      auth: Github,
      body: {
        expiry?: "one_day" | "three_days" | "one_week" | "one_month" | "six_months";
        limit: "existing_users" | "contributors_only" | "collaborators_only";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.github.com/user/interaction-limits`);
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 367 days ago

  • nativets
    type Github = {
      token: string;
    };
    /**
     * Set interaction restrictions for your public repositories
     * Temporarily restricts which type of GitHub user can interact with your public repositories. Setting the interaction limit at the user level will overwrite any interaction limits that are set for individual repositories owned by the user.
     */
    export async function main(
      auth: Github,
      body: {
        expiry?: "one_day" | "three_days" | "one_week" | "one_month" | "six_months";
        limit: "existing_users" | "contributors_only" | "collaborators_only";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.github.com/user/interaction-limits`);
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 927 days ago