Edits history of script submission #345 for ' Get Repo Content (github)'

  • deno
    One script reply has been approved by the moderators
    Ap­pro­ved
    import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
    
    /**
     * @param owner The account owner of the repository. The name is not case sensitive.
     *
     * @param repo The name of the repository. The name is not case sensitive.
     *
     * @param path The path to the file or directory.
     * If omitted, the contents of the repository's root directory will be returned.
     *
     * @param ref The name of the commit/branch/tag. Defaults to the default branch of the repository.
     *
     * @param result_format The kind of data to be returned. This controls how the result is structured.
     * Learn more at https://docs.github.com/en/rest/repos/contents#get-repository-content
     */
    type Github = {
      token: string;
    };
    export async function main(
      gh_auth: Github,
      owner: string,
      repo: string,
      path?: string,
      ref?: string,
      result_format: "github_object" | "json" = "github_object"
    ) {
      const octokit = new Octokit({ auth: gh_auth.token });
    
      return await octokit.request(
        `GET /repos/{owner}/{repo}/contents/{path}${ref ? "?{ref}" : ""}`,
        {
          owner,
          repo,
          path,
          headers: {
            "X-GitHub-Api-Version": "2022-11-28",
            Accept: `application/${
              result_format === "json" ? "vnd.github+json" : "vnd.github.object"
            }`,
          },
        }
      );
    }
    

    Submitted by hugo697 388 days ago

  • deno
    import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
    
    /**
     * @param owner The account owner of the repository. The name is not case sensitive.
     *
     * @param repo The name of the repository. The name is not case sensitive.
     *
     * @param path The path to the file or directory.
     * If omitted, the contents of the repository's root directory will be returned.
     *
     * @param ref The name of the commit/branch/tag. Defaults to the default branch of the repository.
     *
     * @param result_format The kind of data to be returned. This controls how the result is structured.
     * Learn more at https://docs.github.com/en/rest/repos/contents#get-repository-content
     */
    type Github = {
      token: string;
    };
    export async function main(
      gh_auth: Github,
      owner: string,
      repo: string,
      path?: string,
      ref?: string,
      result_format: "github_object" | "json" = "github_object"
    ) {
      const octokit = new Octokit({ auth: gh_auth.token });
    
      return await octokit.request(
        `GET /repos/{owner}/{repo}/contents/{path}${ref ? "?{ref}" : ""}`,
        {
          owner,
          repo,
          path,
          headers: {
            "X-GitHub-Api-Version": "2022-11-28",
            Accept: `application/${
              result_format === "json" ? "vnd.github+json" : "vnd.github.object"
            }`,
          },
        }
      );
    }
    

    Submitted by hugo697 948 days ago

  • deno
    import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
    
    /**
     * @param owner The account owner of the repository. The name is not case sensitive.
     *
     * @param repo The name of the repository. The name is not case sensitive.
     *
     * @param path The path to the file or directory.
     * If omitted, the contents of the repository's root directory will be returned.
     *
     * @param ref The name of the commit/branch/tag. Defaults to the default branch of the repository.
     *
     * @param result_format The kind of data to be returned. This controls how the result is structured.
     * Learn more at https://docs.github.com/en/rest/repos/contents#get-repository-content
     */
    type Github = {
      token: string;
    };
    export async function main(
      gh_auth: Github,
      owner: string,
      repo: string,
      path?: string,
      ref?: string,
      result_format: "github_object" | "json" = "github_object",
    ) {
      const octokit = new Octokit({ auth: gh_auth.token });
    
      return await octokit.request(
        `GET /repos/{owner}/{repo}/contents/{path}${ref ? "?{ref}" : ""}`,
        {
          owner,
          repo,
          path,
          headers: {
            "X-GitHub-Api-Version": "2022-11-28",
            Accept: `application/${
              result_format === "json" ? "vnd.github+json" : "vnd.github.object"
            }`,
          },
        },
      );
    }
    

    Submitted by admin 1020 days ago

  • deno
    import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
    
    /**
     * @param owner The account owner of the repository. The name is not case sensitive.
     * 
     * @param repo The name of the repository. The name is not case sensitive.
     * 
     * @param path The path to the file or directory.
     * If omitted, the contents of the repository's root directory will be returned.
     * 
     * @param ref The name of the commit/branch/tag. Defaults to the default branch of the repository.
     * 
     * @param result_format The kind of data to be returned. This controls how the result is structured.
     * Learn more at https://docs.github.com/en/rest/repos/contents#get-repository-content
     */
    type Github = {
      token: string;
    };
    export async function main(
      gh_auth: Github,
      owner: string,
      repo: string,
      path?: string,
      ref?: string,
      result_format: 'github_object' | 'json' = 'github_object'
    ) {
      const octokit = new Octokit({ auth: gh_auth.token });
    
      return await octokit.request(`GET /repos/{owner}/{repo}/contents/{path}${ref ? '?{ref}' : ''}`, {
        owner,
        repo,
        path,
        headers: {
          "X-GitHub-Api-Version": "2022-11-28",
          Accept: `application/${result_format === 'json' ? 'vnd.github+json' : 'vnd.github.object'}`,
        },
      });
    }
    

    Submitted by admin 1024 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
    
    /**
     * @param owner The account owner of the repository. The name is not case sensitive.
     * 
     * @param repo The name of the repository. The name is not case sensitive.
     * 
     * @param path The path to the file or directory.
     * If omitted, the contents of the repository's root directory will be returned.
     * 
     * @param ref The name of the commit/branch/tag. Defaults to the default branch of the repository.
     * 
     * @param result_format The kind of data to be returned. This controls how the result is structured.
     * Learn more at https://docs.github.com/en/rest/repos/contents#get-repository-content
     */
    export async function main(
      gh_auth: wmill.Resource<"github">,
      owner: string,
      repo: string,
      path?: string,
      ref?: string,
      result_format: 'github_object' | 'json' = 'github_object'
    ) {
      const octokit = new Octokit({ auth: gh_auth.token });
    
      return await octokit.request(`GET /repos/{owner}/{repo}/contents/{path}${ref ? '?{ref}' : ''}`, {
        owner,
        repo,
        path,
        headers: {
          "X-GitHub-Api-Version": "2022-11-28",
          Accept: `application/${result_format === 'json' ? 'vnd.github+json' : 'vnd.github.object'}`,
        },
      });
    }
    

    Submitted by adam186 1138 days ago