1- const API_BASE_URL = process . env . NEXT_PUBLIC_API_BASE_URL || 'https://one-password-api-latest.onrender.com' ;
21const REQUEST_TIMEOUT = 10000 ; // 10 seconds
32
43export interface APIResponse < T = unknown > {
@@ -110,7 +109,7 @@ class APIService {
110109
111110 // Auth endpoints
112111 async signup ( data : { fullName : string ; email : string ; password : string } ) : Promise < SignupResponse > {
113- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /auth/signup` , {
112+ const response = await this . fetchWithTimeout ( " /auth/signup" , {
114113 method : 'POST' ,
115114 headers : { 'Content-Type' : 'application/json' } ,
116115 body : JSON . stringify ( data ) ,
@@ -119,7 +118,7 @@ class APIService {
119118 }
120119
121120 async login ( data : { email : string ; password : string } ) : Promise < LoginResponse > {
122- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /auth/login` , {
121+ const response = await this . fetchWithTimeout ( " /auth/login" , {
123122 method : 'POST' ,
124123 headers : { 'Content-Type' : 'application/json' } ,
125124 body : JSON . stringify ( data ) ,
@@ -136,7 +135,7 @@ class APIService {
136135 recentApiKeys : APIKey [ ] ;
137136 recentlyUsedKeys : APIKey [ ] ;
138137 } > {
139- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /dashboard` , {
138+ const response = await this . fetchWithTimeout ( " /dashboard" , {
140139 headers : this . getAuthHeaders ( ) ,
141140 } ) ;
142141 return this . handleResponse < {
@@ -156,7 +155,7 @@ class APIService {
156155 sharedKeys : number ;
157156 teamsOwned : Array < { id : number ; name : string ; description ?: string ; createdAt : string } > ;
158157 } > {
159- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /dashboard/teams` , {
158+ const response = await this . fetchWithTimeout ( " /dashboard/teams" , {
160159 headers : this . getAuthHeaders ( ) ,
161160 } ) ;
162161 return this . handleResponse < {
@@ -170,7 +169,7 @@ class APIService {
170169
171170 // API Keys endpoints
172171 async createAPIKey ( data : { name : string ; key : string ; description ?: string ; tags ?: string } ) {
173- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /apikeys` , {
172+ const response = await this . fetchWithTimeout ( " /apikeys" , {
174173 method : 'POST' ,
175174 headers : this . getAuthHeaders ( ) ,
176175 body : JSON . stringify ( data ) ,
@@ -179,14 +178,14 @@ class APIService {
179178 }
180179
181180 async listAPIKeys ( ) : Promise < APIKey [ ] > {
182- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /apikeys/list` , {
181+ const response = await this . fetchWithTimeout ( " /apikeys/list" , {
183182 headers : this . getAuthHeaders ( ) ,
184183 } ) ;
185184 return this . handleResponse < APIKey [ ] > ( response ) ;
186185 }
187186
188187 async revealAPIKey ( name : string ) {
189- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /apikeys/reveal` , {
188+ const response = await this . fetchWithTimeout ( " /apikeys/reveal" , {
190189 method : 'POST' ,
191190 headers : this . getAuthHeaders ( ) ,
192191 body : JSON . stringify ( { name } ) ,
@@ -195,7 +194,7 @@ class APIService {
195194 }
196195
197196 async deleteAPIKey ( name : string ) {
198- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /apikeys/delete` , {
197+ const response = await this . fetchWithTimeout ( " /apikeys/delete" , {
199198 method : 'DELETE' ,
200199 headers : this . getAuthHeaders ( ) ,
201200 body : JSON . stringify ( { name } ) ,
@@ -205,7 +204,7 @@ class APIService {
205204
206205 // Teams endpoints
207206 async createTeam ( data : { name : string ; description ?: string } ) {
208- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /teams` , {
207+ const response = await this . fetchWithTimeout ( " /teams" , {
209208 method : 'POST' ,
210209 headers : this . getAuthHeaders ( ) ,
211210 body : JSON . stringify ( data ) ,
@@ -215,7 +214,7 @@ class APIService {
215214
216215 // Team Memberships endpoints
217216 async createTeamMembership ( data : { teamId : number ; userId : number } ) {
218- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /team-memberships` , {
217+ const response = await this . fetchWithTimeout ( " /team-memberships" , {
219218 method : 'POST' ,
220219 headers : this . getAuthHeaders ( ) ,
221220 body : JSON . stringify ( data ) ,
@@ -224,14 +223,14 @@ class APIService {
224223 }
225224
226225 async listTeamMemberships ( ) : Promise < TeamMembership [ ] > {
227- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /team-memberships/list` , {
226+ const response = await this . fetchWithTimeout ( " /team-memberships/list" , {
228227 headers : this . getAuthHeaders ( ) ,
229228 } ) ;
230229 return this . handleResponse < TeamMembership [ ] > ( response ) ;
231230 }
232231
233232 async deleteTeamMembership ( data : { teamId : number ; userId : number } ) {
234- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /team-memberships/delete` , {
233+ const response = await this . fetchWithTimeout ( " /team-memberships/delete" , {
235234 method : 'DELETE' ,
236235 headers : this . getAuthHeaders ( ) ,
237236 body : JSON . stringify ( data ) ,
@@ -241,7 +240,7 @@ class APIService {
241240
242241 // API Key-Team relationship endpoints
243242 async attachAPIKeyToTeam ( data : { teamId : number ; apiKeyId : number } ) {
244- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /apikey-teams` , {
243+ const response = await this . fetchWithTimeout ( " /apikey-teams" , {
245244 method : 'POST' ,
246245 headers : this . getAuthHeaders ( ) ,
247246 body : JSON . stringify ( data ) ,
@@ -250,14 +249,14 @@ class APIService {
250249 }
251250
252251 async listAPIKeyTeams ( teamId : number ) : Promise < APIKeyTeam [ ] > {
253- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /apikey-teams/list?team_id=${ teamId } ` , {
252+ const response = await this . fetchWithTimeout ( " /apikey-teams/list?team_id=${teamId}" , {
254253 headers : this . getAuthHeaders ( ) ,
255254 } ) ;
256255 return this . handleResponse < APIKeyTeam [ ] > ( response ) ;
257256 }
258257
259258 async detachAPIKeyFromTeam ( data : { teamId : number ; apiKeyId : number } ) {
260- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /apikey-teams/delete` , {
259+ const response = await this . fetchWithTimeout ( " /apikey-teams/delete" , {
261260 method : 'DELETE' ,
262261 headers : this . getAuthHeaders ( ) ,
263262 body : JSON . stringify ( data ) ,
@@ -267,22 +266,22 @@ class APIService {
267266
268267 // Activity endpoints
269268 async listActivities ( ) : Promise < unknown [ ] > {
270- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /dashboard/activity` , {
269+ const response = await this . fetchWithTimeout ( " /dashboard/activity" , {
271270 headers : this . getAuthHeaders ( ) ,
272271 } ) ;
273272 return this . handleResponse < unknown [ ] > ( response ) ;
274273 }
275274
276275 async getActivityStats ( ) : Promise < unknown > {
277- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /dashboard/activity/detail` , {
276+ const response = await this . fetchWithTimeout ( " /dashboard/activity/detail" , {
278277 headers : this . getAuthHeaders ( ) ,
279278 } ) ;
280279 return this . handleResponse ( response ) ;
281280 }
282281
283282 // Health check
284283 async healthCheck ( ) {
285- const response = await this . fetchWithTimeout ( ` ${ API_BASE_URL } /health` , { } ) ;
284+ const response = await this . fetchWithTimeout ( " /health" , { } ) ;
286285 return this . handleResponse < { status : string } > ( response ) ;
287286 }
288287}
0 commit comments