@@ -25,7 +25,37 @@ export async function POST(request: NextRequest) {
2525 "url_metadata.nft_collection_id" ,
2626 "nft_collections.id"
2727 )
28- . selectAll ( )
28+ . select ( [
29+ /* Select all columns with aliases to prevent collisions */
30+
31+ // URL metadata
32+ "url_metadata.image_url as url_image_url" ,
33+ "url_metadata.image_height as url_image_height" ,
34+ "url_metadata.image_width as url_image_width" ,
35+ "url_metadata.alt as url_alt" ,
36+ "url_metadata.url as url_url" ,
37+ "url_metadata.description as url_description" ,
38+ "url_metadata.title as url_title" ,
39+ "url_metadata.publisher as url_publisher" ,
40+ "url_metadata.logo_url as url_logo_url" ,
41+ "url_metadata.mime_type as url_mime_type" ,
42+ "url_metadata.nft_collection_id as nft_collection_id" ,
43+ "url_metadata.nft_metadata_id as nft_metadata_id" ,
44+
45+ // NFT Collection metadata
46+ "nft_collections.creator_address as collection_creator_address" ,
47+ "nft_collections.description as collection_description" ,
48+ "nft_collections.image_url as collection_image_url" ,
49+ "nft_collections.item_count as collection_item_count" ,
50+ "nft_collections.mint_url as collection_mint_url" ,
51+ "nft_collections.name as collection_name" ,
52+ "nft_collections.open_sea_url as collection_open_sea_url" ,
53+ "nft_collections.owner_count as collection_owner_count" ,
54+
55+ // NFT metadata
56+ "nft_metadata.token_id as nft_token_id" ,
57+ "nft_metadata.media_url as nft_media_url" ,
58+ ] )
2959 . execute ( ) ;
3060
3161 const rowsFormatted = metadata . map ( ( row ) => {
@@ -41,44 +71,44 @@ export async function POST(request: NextRequest) {
4171 const chain = chainById [ chainId ] ;
4272
4373 nftMetadata = {
44- mediaUrl : row . media_url || undefined ,
45- tokenId : row . token_id || undefined ,
74+ mediaUrl : row . nft_media_url || undefined ,
75+ tokenId : row . nft_token_id || undefined ,
4676 collection : {
4777 chain : chain . network ,
4878 contractAddress,
49- creatorAddress : row . creator_address ,
50- description : row . description ,
79+ creatorAddress : row . collection_creator_address ,
80+ description : row . collection_description ,
5181 id : row . nft_collection_id ,
52- imageUrl : row . image_url ,
53- itemCount : row . item_count ,
54- mintUrl : row . mint_url ,
55- name : row . name ,
56- openSeaUrl : row . open_sea_url || undefined ,
57- ownerCount : row . owner_count || undefined ,
82+ imageUrl : row . collection_image_url ,
83+ itemCount : row . collection_item_count ,
84+ mintUrl : row . collection_mint_url ,
85+ name : row . collection_name ,
86+ openSeaUrl : row . collection_open_sea_url || undefined ,
87+ ownerCount : row . collection_owner_count || undefined ,
5888 creator : undefined , // TODO: Look up farcaster user by FID
5989 } ,
6090 } ;
6191 }
6292
6393 const urlMetadata : UrlMetadata = {
64- image : row . image_url
94+ image : row . url_image_url
6595 ? {
66- url : row . image_url ,
67- height : row . image_height || undefined ,
68- width : row . image_width || undefined ,
96+ url : row . url_image_url ,
97+ height : row . url_image_height || undefined ,
98+ width : row . url_image_width || undefined ,
6999 }
70100 : undefined ,
71- alt : row . alt || undefined ,
72- description : row . description || undefined ,
73- title : row . title || undefined ,
74- publisher : row . publisher || undefined ,
75- logo : row . logo_url ? { url : row . logo_url } : undefined ,
76- mimeType : row . mime_type || undefined ,
101+ alt : row . url_alt || undefined ,
102+ description : row . url_description || undefined ,
103+ title : row . url_title || undefined ,
104+ publisher : row . url_publisher || undefined ,
105+ logo : row . url_logo_url ? { url : row . url_logo_url } : undefined ,
106+ mimeType : row . url_mime_type || undefined ,
77107 nft : nftMetadata ,
78108 } ;
79109
80110 return {
81- url : row . url ,
111+ url : row . url_url ,
82112 urlMetadata,
83113 } ;
84114 } ) ;
0 commit comments