A deployable markdown editor that connects with your self hosted files and lets you edit in a beautiful interface
at main 53 lines 1.2 kB view raw
1import { apiClient } from './client'; 2 3export interface BranchStatus { 4 branch_name: string; 5 base_branch: string; 6 has_changes: boolean; 7 last_push_at: string; 8 edited_files: string[]; 9 hours_since_push: number; 10 has_draft_content: boolean; 11} 12 13export interface PublishParams { 14 owner: string; 15 repo: string; 16 commit_message: string; 17 pr_title?: string; 18 pr_description?: string; 19 files?: string[]; 20} 21 22export interface PullRequest { 23 number: number; 24 url: string; 25 html_url: string; 26 title: string; 27} 28 29export interface PublishResponse { 30 success: boolean; 31 branch: string; 32 commit_sha: string; 33 pull_request?: PullRequest; 34 error?: string; 35} 36 37export const branchApi = { 38 async getBranchStatus(owner: string, repo: string): Promise<BranchStatus> { 39 const response = await apiClient.get<BranchStatus>( 40 `/api/repos/${owner}/${repo}/branch/status` 41 ); 42 return response.data; 43 }, 44 45 async publish(params: PublishParams): Promise<PublishResponse> { 46 const { owner, repo, ...body } = params; 47 const response = await apiClient.post<PublishResponse>( 48 `/api/repos/${owner}/${repo}/publish`, 49 body 50 ); 51 return response.data; 52 }, 53};