@@ -5,7 +5,7 @@ import { buildFeedAddressMarkdown, VALID_FEED_TYPES } from "~/features/feeds/uti
55import { STREAM_CATEGORY_MAP } from "~/features/feeds/utils/streamMetadata.ts"
66import type { DataFeedType } from "~/features/feeds/components/FeedList.tsx"
77
8- // Reverse map: internal → public (streamsCrypto → crypto)
8+ // Reverse map: internal → public
99const INTERNAL_TO_PUBLIC : Record < string , string > = Object . fromEntries (
1010 Object . entries ( STREAM_CATEGORY_MAP ) . map ( ( [ pub , internal ] ) => [ internal , pub ] )
1111)
@@ -18,10 +18,10 @@ export async function getStaticPaths() {
1818
1919 for ( const type of VALID_FEED_TYPES ) {
2020 for ( const chain of Object . values ( chainCache ) ) {
21- for ( const network of chain . networks ?? [ ] ) {
22- const queryString = network . queryString
21+ const chainNetworks = ( chain as { networks ?: any [ ] } ) . networks ?? [ ]
2322
24- // Guardrails
23+ for ( const network of chainNetworks ) {
24+ const queryString = network . queryString
2525 if ( ! queryString ) continue
2626
2727 const key = `${ type } :${ queryString } `
@@ -43,31 +43,22 @@ export async function getStaticPaths() {
4343
4444export const GET : APIRoute = async ( { params } ) => {
4545 const type = params . type as DataFeedType
46- const network = params . network
46+ const network = params . network ?? null // ✅ FIX
4747
4848 if ( ! VALID_FEED_TYPES . includes ( type ) ) {
4949 return new Response ( `Invalid type "${ type } "` , { status : 400 } )
5050 }
5151
52- const publicType = INTERNAL_TO_PUBLIC [ type ]
52+ const publicType = INTERNAL_TO_PUBLIC [ type ] ?? type // ✅ SAFE
5353
5454 const chainCache = await getServerSideChainMetadata ( CHAINS )
5555
56- const markdown = buildFeedAddressMarkdown (
57- type ,
58- network , // ✅ scoped per-network
59- chainCache ,
60- "https://docs.chain.link" ,
61- {
62- publicType,
63- }
64- )
56+ const markdown = buildFeedAddressMarkdown ( type , network , chainCache , "https://docs.chain.link" , { publicType } )
6557
6658 return new Response ( markdown , {
6759 status : 200 ,
6860 headers : {
6961 "Content-Type" : "text/plain; charset=utf-8" ,
70- // CDN-friendly caching
7162 "Cache-Control" : "public, max-age=0, s-maxage=86400, stale-while-revalidate=604800" ,
7263 } ,
7364 } )
0 commit comments