A decentralized music tracking and discovery platform built on AT Protocol 🎵

fix: improve error handling and logging in getProfile functions

+14 -12
+14 -12
apps/api/src/xrpc/app/rocksky/actor/getProfile.ts
··· 33 Effect.catchAll((err) => { 34 console.error(err); 35 return Effect.succeed({}); 36 - }), 37 ); 38 server.app.rocksky.actor.getProfile({ 39 auth: ctx.authVerifier, ··· 138 agent, 139 }: WithAgent): Effect.Effect<WithUser, Error> => { 140 return Effect.tryPromise({ 141 - try: async () => 142 - ctx.db 143 .select() 144 .from(tables.users) 145 .where(eq(tables.users.did, did)) ··· 150 params, 151 did, 152 agent, 153 - })), 154 catch: (error) => new Error(`Failed to retrieve current user: ${error}`), 155 }); 156 }; ··· 192 .from(tables.spotifyAccounts) 193 .leftJoin( 194 tables.users, 195 - eq(tables.spotifyAccounts.userId, tables.users.id), 196 ) 197 .where(eq(tables.users.did, did)) 198 .execute() ··· 202 .from(tables.spotifyTokens) 203 .leftJoin( 204 tables.users, 205 - eq(tables.spotifyTokens.userId, tables.users.id), 206 ) 207 .where(eq(tables.users.did, did)) 208 .execute() ··· 212 .from(tables.googleDriveAccounts) 213 .leftJoin( 214 tables.users, 215 - eq(tables.googleDriveAccounts.userId, tables.users.id), 216 ) 217 .where(eq(tables.users.did, did)) 218 .execute() ··· 222 .from(tables.dropboxAccounts) 223 .leftJoin( 224 tables.users, 225 - eq(tables.dropboxAccounts.userId, tables.users.id), 226 ) 227 .where(eq(tables.users.did, did)) 228 .execute() ··· 279 xata_createdat: profile.user.createdAt.toISOString(), 280 xata_updatedat: profile.user.updatedAt.toISOString(), 281 xata_version: 1, 282 - }), 283 - ), 284 ); 285 } else { 286 // Update existing user in background if handle or avatar or displayName changed ··· 313 xata_createdat: profile.user.createdAt.toISOString(), 314 xata_updatedat: new Date().toISOString(), 315 xata_version: (profile.user.xataVersion || 1) + 1, 316 - }), 317 - ), 318 ); 319 } 320 }
··· 33 Effect.catchAll((err) => { 34 console.error(err); 35 return Effect.succeed({}); 36 + }) 37 ); 38 server.app.rocksky.actor.getProfile({ 39 auth: ctx.authVerifier, ··· 138 agent, 139 }: WithAgent): Effect.Effect<WithUser, Error> => { 140 return Effect.tryPromise({ 141 + try: async () => { 142 + console.log(">> did", did); 143 + return ctx.db 144 .select() 145 .from(tables.users) 146 .where(eq(tables.users.did, did)) ··· 151 params, 152 did, 153 agent, 154 + })); 155 + }, 156 catch: (error) => new Error(`Failed to retrieve current user: ${error}`), 157 }); 158 }; ··· 194 .from(tables.spotifyAccounts) 195 .leftJoin( 196 tables.users, 197 + eq(tables.spotifyAccounts.userId, tables.users.id) 198 ) 199 .where(eq(tables.users.did, did)) 200 .execute() ··· 204 .from(tables.spotifyTokens) 205 .leftJoin( 206 tables.users, 207 + eq(tables.spotifyTokens.userId, tables.users.id) 208 ) 209 .where(eq(tables.users.did, did)) 210 .execute() ··· 214 .from(tables.googleDriveAccounts) 215 .leftJoin( 216 tables.users, 217 + eq(tables.googleDriveAccounts.userId, tables.users.id) 218 ) 219 .where(eq(tables.users.did, did)) 220 .execute() ··· 224 .from(tables.dropboxAccounts) 225 .leftJoin( 226 tables.users, 227 + eq(tables.dropboxAccounts.userId, tables.users.id) 228 ) 229 .where(eq(tables.users.did, did)) 230 .execute() ··· 281 xata_createdat: profile.user.createdAt.toISOString(), 282 xata_updatedat: profile.user.updatedAt.toISOString(), 283 xata_version: 1, 284 + }) 285 + ) 286 ); 287 } else { 288 // Update existing user in background if handle or avatar or displayName changed ··· 315 xata_createdat: profile.user.createdAt.toISOString(), 316 xata_updatedat: new Date().toISOString(), 317 xata_version: (profile.user.xataVersion || 1) + 1, 318 + }) 319 + ) 320 ); 321 } 322 }