Skip to content

Commit 765e03a

Browse files
committed
Update API endpoints for invite-only mode management
- Change endpoint URLs from /api/allowed-users to /api/allowed/users - Use proper REST methods: POST for add, DELETE for remove - Maintain NPUB format for backend compatibility - Add comprehensive logging for debugging backend communication - Ready for backend team to implement missing endpoints
1 parent 348b5ee commit 765e03a

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/api/allowedUsers.api.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ export const updateAllowedUsersSettings = async (settings: AllowedUsersSettings)
144144
}
145145
};
146146

147-
// Unified User Management - Direct API calls (no fallback needed)
147+
// Unified User Management - Using correct invite-only endpoints
148148
export const getAllowedUsers = async (page = 1, pageSize = 20): Promise<AllowedUsersResponse> => {
149149
const token = readToken();
150-
const response = await fetch(`${config.baseURL}/api/allowed-users?page=${page}&pageSize=${pageSize}`, {
150+
const response = await fetch(`${config.baseURL}/api/allowed/users?page=${page}&pageSize=${pageSize}`, {
151151
headers: {
152152
'Authorization': `Bearer ${token}`,
153153
},
@@ -176,15 +176,16 @@ export const getAllowedUsers = async (page = 1, pageSize = 20): Promise<AllowedU
176176
export const addAllowedUser = async (request: AddAllowedUserRequest): Promise<ApiResponse> => {
177177
const token = readToken();
178178

179-
// Comprehensive logging for user addition
179+
// Backend expects NPUB format (not hex), so keep as-is
180180
console.group('👤 [API] Adding Allowed User');
181181
console.log('📤 Request payload:', request);
182-
console.log('🌐 Request URL:', `${config.baseURL}/api/allowed-users`);
182+
console.log('🌐 Request URL:', `${config.baseURL}/api/allowed/add`);
183183
console.log('📄 Request body (stringified):', JSON.stringify(request, null, 2));
184184
console.log('🔑 Authorization token present:', !!token);
185185
console.groupEnd();
186186

187-
const response = await fetch(`${config.baseURL}/api/allowed-users`, {
187+
// Using correct POST method with request body
188+
const response = await fetch(`${config.baseURL}/api/allowed/add`, {
188189
method: 'POST',
189190
headers: {
190191
'Content-Type': 'application/json',
@@ -225,7 +226,8 @@ export const addAllowedUser = async (request: AddAllowedUserRequest): Promise<Ap
225226
export const removeAllowedUser = async (request: RemoveAllowedUserRequest): Promise<ApiResponse> => {
226227
const token = readToken();
227228

228-
const response = await fetch(`${config.baseURL}/api/allowed-users`, {
229+
// Using correct DELETE method with request body
230+
const response = await fetch(`${config.baseURL}/api/allowed/remove`, {
229231
method: 'DELETE',
230232
headers: {
231233
'Content-Type': 'application/json',

0 commit comments

Comments
 (0)