@@ -22,11 +22,8 @@ if (!apiKey || !bearerToken) {
2222}
2323
2424const { sdk } = await import ( '@audius/sdk' )
25- // Provide appName to avoid SDK fetching developer app by apiKey (which can 404 if app not on prod)
2625const audius = sdk ( { appName, apiKey, bearerToken } )
2726
28- // console.log({ appName, apiKey, bearerToken })
29-
3027const app = express ( )
3128app . use ( express . json ( ) )
3229
@@ -43,36 +40,18 @@ app.post('/update-description', async (req, res) => {
4340 userId,
4441 metadata : { bio : String ( description ) }
4542 } )
46- const body = {
43+ return res . json ( {
4744 success : true ,
48- transaction_hash : result ?. transactionHash ?? result ?. transaction_hash ?? null
49- }
50- console . log ( '[update-description] response body' , JSON . stringify ( body , null , 2 ) )
51- return res . json ( body )
45+ transaction_hash :
46+ result ?. transactionHash ?? result ?. transaction_hash ?? null
47+ } )
5248 } catch ( e ) {
53- let body = e ?. message ?? 'Unknown error'
54- if ( e ?. response ) {
55- const resHeaders = Object . fromEntries ( e . response . headers . entries ( ) )
56- console . error ( 'API response:' , e . response . status , e . response . statusText )
57- console . error ( 'Response headers:' , JSON . stringify ( resHeaders , null , 2 ) )
58- if ( e ?. request ) {
59- const reqHeaders = e . request ?. headers
60- ? Object . fromEntries ( e . request . headers . entries ( ) )
61- : { }
62- console . error ( 'Request URL:' , e . request ?. url ?? e . response ?. url )
63- console . error ( 'Request headers:' , JSON . stringify ( reqHeaders , null , 2 ) )
64- }
65- body = await e . response . text ( ) . catch ( ( ) => body )
66- if ( body ) console . error ( 'Body:' , body )
67- } else {
68- console . error ( e )
69- }
7049 const status = e ?. response ?. status ?? 500
50+ const body = e ?. response
51+ ? await e . response . text ( ) . catch ( ( ) => e ?. message ?? 'Update failed' )
52+ : ( e ?. message ?? 'Update failed' )
7153 return res . status ( status ) . json ( { error : body || 'Update failed' } )
7254 }
7355} )
7456
75- app . listen ( PORT , ( ) => {
76- console . log ( `Authenticated writes server at http://localhost:${ PORT } ` )
77- console . log ( 'POST /update-description body: { userId, description }' )
78- } )
57+ app . listen ( PORT )
0 commit comments