@@ -3,8 +3,10 @@ import { getAxiosConfig, processAuthError } from './auth.js';
33import { API_BASE } from '../apiBase' ;
44import { RepositoryData , RepositoryDataWithId } from '../views/RepoList/Components/NewRepo' ;
55
6+ const API_V1_BASE = `${ API_BASE } /api/v1` ;
7+
68const canAddUser = ( repoId : string , user : string , action : string ) => {
7- const url = new URL ( `${ API_BASE } /repo/${ repoId } ` ) ;
9+ const url = new URL ( `${ API_V1_BASE } /repo/${ repoId } ` ) ;
810 return axios
911 . get ( url . toString ( ) , getAxiosConfig ( ) )
1012 . then ( ( response ) => {
@@ -35,7 +37,7 @@ const getRepos = async (
3537 setErrorMessage : ( errorMessage : string ) => void ,
3638 query : Record < string , boolean > = { } ,
3739) : Promise < void > => {
38- const url = new URL ( `${ API_BASE } /repo` ) ;
40+ const url = new URL ( `${ API_V1_BASE } /repo` ) ;
3941 url . search = new URLSearchParams ( query as any ) . toString ( ) ;
4042 setIsLoading ( true ) ;
4143 await axios ( url . toString ( ) , getAxiosConfig ( ) )
@@ -66,7 +68,7 @@ const getRepo = async (
6668 setIsError : ( isError : boolean ) => void ,
6769 id : string ,
6870) : Promise < void > => {
69- const url = new URL ( `${ API_BASE } /repo/${ id } ` ) ;
71+ const url = new URL ( `${ API_V1_BASE } /repo/${ id } ` ) ;
7072 setIsLoading ( true ) ;
7173 await axios ( url . toString ( ) , getAxiosConfig ( ) )
7274 . then ( ( response ) => {
@@ -88,7 +90,7 @@ const getRepo = async (
8890const addRepo = async (
8991 data : RepositoryData ,
9092) : Promise < { success : boolean ; message ?: string ; repo : RepositoryDataWithId | null } > => {
91- const url = new URL ( `${ API_BASE } /repo` ) ;
93+ const url = new URL ( `${ API_V1_BASE } /repo` ) ;
9294
9395 try {
9496 const response = await axios . post ( url . toString ( ) , data , getAxiosConfig ( ) ) ;
@@ -108,7 +110,7 @@ const addRepo = async (
108110const addUser = async ( repoId : string , user : string , action : string ) : Promise < void > => {
109111 const canAdd = await canAddUser ( repoId , user , action ) ;
110112 if ( canAdd ) {
111- const url = new URL ( `${ API_BASE } /repo/${ repoId } /user/${ action } ` ) ;
113+ const url = new URL ( `${ API_V1_BASE } /repo/${ repoId } /user/${ action } ` ) ;
112114 const data = { username : user } ;
113115 await axios . patch ( url . toString ( ) , data , getAxiosConfig ( ) ) . catch ( ( error : any ) => {
114116 console . log ( error . response . data . message ) ;
@@ -121,7 +123,7 @@ const addUser = async (repoId: string, user: string, action: string): Promise<vo
121123} ;
122124
123125const deleteUser = async ( user : string , repoId : string , action : string ) : Promise < void > => {
124- const url = new URL ( `${ API_BASE } /repo/${ repoId } /user/${ action } /${ user } ` ) ;
126+ const url = new URL ( `${ API_V1_BASE } /repo/${ repoId } /user/${ action } /${ user } ` ) ;
125127
126128 await axios . delete ( url . toString ( ) , getAxiosConfig ( ) ) . catch ( ( error : any ) => {
127129 console . log ( error . response . data . message ) ;
@@ -130,7 +132,7 @@ const deleteUser = async (user: string, repoId: string, action: string): Promise
130132} ;
131133
132134const deleteRepo = async ( repoId : string ) : Promise < void > => {
133- const url = new URL ( `${ API_BASE } /repo/${ repoId } /delete` ) ;
135+ const url = new URL ( `${ API_V1_BASE } /repo/${ repoId } /delete` ) ;
134136
135137 await axios . delete ( url . toString ( ) , getAxiosConfig ( ) ) . catch ( ( error : any ) => {
136138 console . log ( error . response . data . message ) ;
0 commit comments