-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Env } from '../common'; | ||
import { FeedObject } from '../shared/feed-types'; | ||
|
||
export const onRequestPost: PagesFunction<Env> = async (context) => { | ||
const { request } = context; | ||
const js = (await request.json()) as { fid: number; limit: number; cursor?: string }; | ||
const { fid, limit, cursor } = js; | ||
|
||
const neynarApiKey = context.env.NEYNAR_API_KEY; | ||
const provider = 'karma'; | ||
|
||
const paginationParam = cursor ? `&cursor=${cursor}` : ''; | ||
const endpoint = `https://api.neynar.com/v2/farcaster/feed/for_you?fid=${fid}&viewer_fid=${fid}&provider=${provider}&limit=${limit}${paginationParam}`; | ||
|
||
const res = await fetch(endpoint, { | ||
method: 'GET', | ||
headers: { | ||
accept: 'application/json', | ||
api_key: `${neynarApiKey}`, | ||
}, | ||
}); | ||
|
||
if (!res.ok) throw new Error('Failed to fetch data'); | ||
|
||
const forYouFeedResponse = (await res.json()) as FeedObject; | ||
return new Response(JSON.stringify(forYouFeedResponse)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { httpApi } from '@app/api/http.api'; | ||
import './mocks/mockornot'; | ||
|
||
interface ForYouFeedRequest { | ||
fid: number; | ||
limit: number; | ||
cursor?: string; | ||
} | ||
|
||
interface ForYouFeedResponse { | ||
casts: { | ||
object: 'cast'; | ||
}[]; | ||
cursor?: string; | ||
} | ||
export const getNeynarOpenrankForYouFeed = (forYouFeedRequestPayload: ForYouFeedRequest): Promise<ForYouFeedResponse> => | ||
httpApi.post<ForYouFeedResponse>('getForYouFeed', { ...forYouFeedRequestPayload }).then(({ data }) => data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { FeedObject } from '@app/api/feed-types'; | ||
import { RawAPIResponse, transformRawAPIResponse } from '@app/api/mocks/cronFeed.api.mock'; | ||
import { httpApiMock } from '@app/api/mocks/http.api.mock'; | ||
|
||
const rawForYouFeed: RawAPIResponse = { | ||
casts: [ | ||
{ | ||
object: 'cast', | ||
hash: '0x14be3ad800e885d545671acb647123d70bd8b182', | ||
thread_hash: '0x14be3ad800e885d545671acb647123d70bd8b182', | ||
parent_hash: null, | ||
parent_url: 'https://warpcast.com/~/channel/six', | ||
root_parent_url: 'https://warpcast.com/~/channel/six', | ||
parent_author: { | ||
fid: null, | ||
}, | ||
author: { | ||
object: 'user', | ||
fid: 680, | ||
custody_address: '0x0b28a373fc8d92669aefb420499e74ce2dd5d356', | ||
username: 'woj.eth', | ||
display_name: 'woj', | ||
pfp_url: | ||
'https://peach-changing-limpet-80.mypinata.cloud/ipfs/QmZenqRfBERmodRVUHhLaYvYVsRasihVcMY2gqUP2tX7t2?filename=profile_picture.png', | ||
profile: { | ||
bio: { | ||
text: 'customer support @supercast\n\ntrying to sound smart /doingnumbers', | ||
}, | ||
}, | ||
follower_count: 155270, | ||
following_count: 982, | ||
verifications: ['0xf417ace7b13c0ef4fcb5548390a450a4b75d3eb3'], | ||
verified_addresses: { | ||
eth_addresses: ['0xf417ace7b13c0ef4fcb5548390a450a4b75d3eb3'], | ||
sol_addresses: ['9hrZunMWouN6AtFp4Hoi3e4yWkVT32ZyfsQVqkmqLAft'], | ||
}, | ||
active_status: 'inactive', | ||
power_badge: true, | ||
viewer_context: { | ||
following: true, | ||
followed_by: false, | ||
}, | ||
}, | ||
text: 'threads algo absolutely cooked', | ||
timestamp: '2024-06-25T12:45:13.000Z', | ||
embeds: [ | ||
{ | ||
url: 'https://supercast.mypinata.cloud/ipfs/QmVXYY4ekyvGKi4Kem6iTUEc1xhpiVoArHeXx7XUnEvMhe?filename=IMG_2551.png', | ||
}, | ||
], | ||
reactions: { | ||
likes_count: 22, | ||
recasts_count: 0, | ||
likes: [ | ||
{ | ||
fid: 4167, | ||
fname: 'nounishprof', | ||
}, | ||
{ | ||
fid: 648638, | ||
fname: 'fac12344321666', | ||
}, | ||
{ | ||
fid: 530854, | ||
fname: 'javahed', | ||
}, | ||
{ | ||
fid: 380246, | ||
fname: 'filimonovaver', | ||
}, | ||
{ | ||
fid: 697932, | ||
fname: 'illeks', | ||
}, | ||
], | ||
recasts: [], | ||
}, | ||
replies: { | ||
count: 7, | ||
}, | ||
channel: { | ||
object: 'channel_dehydrated', | ||
id: 'six', | ||
name: 'six', | ||
image_url: 'https://i.imgur.com/eLsRTEP.jpg', | ||
}, | ||
mentioned_profiles: [], | ||
viewer_context: { | ||
liked: false, | ||
recasted: false, | ||
}, | ||
}, | ||
], | ||
}; | ||
const mockForYouFeed: FeedObject = transformRawAPIResponse(rawForYouFeed); | ||
httpApiMock.onPost('getForYouFeed').reply(200, mockForYouFeed); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters