Skip to content

Commit

Permalink
[r11s] Allowing getOrCreateRepo to handle headers (#9691)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedasilv authored Mar 31, 2022
1 parent 666f704 commit 40a0e58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const getAuthorizationTokenFromCredentials: (credentials: ICredentials) =
export function getNextHash(message: ISequencedDocumentMessage, lastHash: string): string;

// @public (undocumented)
export function getOrCreateRepository(endpoint: string, owner: string, repository: string): Promise<void>;
export function getOrCreateRepository(endpoint: string, owner: string, repository: string, headers?: AxiosRequestHeaders): Promise<void>;

// @public (undocumented)
export function getRandomName(connector?: string, capitalize?: boolean): string;
Expand Down
12 changes: 8 additions & 4 deletions server/routerlicious/packages/services-client/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
*/

import * as resources from "@fluidframework/gitresources";
import Axios from "axios";
import Axios, { AxiosRequestHeaders } from "axios";

export async function getOrCreateRepository(endpoint: string, owner: string, repository: string): Promise<void> {
export async function getOrCreateRepository(
endpoint: string,
owner: string,
repository: string,
headers?: AxiosRequestHeaders): Promise<void> {
console.log(`Get Repo: ${endpoint}/${owner}/${repository}`);

const details = await Axios.get(`${endpoint}/repos/${owner}/${repository}`)
const details = await Axios.get(`${endpoint}/repos/${owner}/${repository}`, { headers })
.catch((error) => {
if (error.response && error.response.status === 400) {
return null;
Expand All @@ -24,6 +28,6 @@ export async function getOrCreateRepository(endpoint: string, owner: string, rep
name: repository,
};

await Axios.post(`${endpoint}/${owner}/repos`, createParams);
await Axios.post(`${endpoint}/${owner}/repos`, createParams, { headers });
}
}

0 comments on commit 40a0e58

Please sign in to comment.