Skip to content

Commit 174608a

Browse files
committed
typecheck
1 parent 52a9243 commit 174608a

3 files changed

Lines changed: 19 additions & 27 deletions

File tree

src/pages/[...path].md.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import type { APIRoute } from "astro"
22
import fs from "node:fs/promises"
33
import path from "node:path"
4+
5+
import { getServerSideChainMetadata } from "~/features/data/api/backend.ts"
6+
import { CHAINS } from "~/features/data/chains.ts"
7+
import { buildFeedAddressMarkdown, collectStreamEntries } from "~/features/feeds/utils/feedOutput.ts"
8+
import { STREAM_CATEGORY_MAP } from "~/features/feeds/utils/streamMetadata.ts"
9+
410
import { textPlainHeaders } from "@lib/api/cacheHeaders.js"
511
import { transformPageToMarkdown } from "@lib/markdown/transformMarkdown.js"
612
import { extractFrontmatter, getIsoStringOrUndefined, toCanonicalUrl, toContentRelative } from "@lib/markdown/utils.js"
713

8-
// Feeds
9-
import { getServerSideChainMetadata } from "~/features/data/api/backend"
10-
import { CHAINS } from "~/features/data/chains"
11-
import { buildFeedAddressMarkdown } from "~/features/feeds/utils/feedOutput"
12-
13-
// Streams (reuse same builder + data source)
14-
import { STREAM_CATEGORY_MAP } from "~/features/feeds/utils/streamMetadata"
15-
1614
const SITE_BASE = "https://docs.chain.link"
1715
const CONTENT_ROOT = path.resolve("src/content")
1816

@@ -188,7 +186,7 @@ ${exampleMarkdown}
188186
// -----------------------
189187
// STREAM EXAMPLE BUILDER
190188
// -----------------------
191-
function buildStreamExample(streams: any[]): string {
189+
function buildStreamExample(streams: Array<{ name: string; feedId: string; schema: string }>): string {
192190
const sample = streams.slice(0, 10)
193191

194192
const lines = ["| Stream | Feed ID | Schema |", "|--------|---------|--------|"]

src/pages/data-feeds/feed-addresses/[type].txt.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export const GET: APIRoute = async ({ params }) => {
2929
const seen = new Set<string>()
3030

3131
for (const chain of Object.values(chainCache)) {
32-
for (const network of chain.networks ?? []) {
32+
// ✅ FIX: rename to avoid shadowing
33+
const chainNetworks = (chain as { networks?: any[] }).networks ?? []
34+
35+
for (const network of chainNetworks) {
3336
const queryString = network.queryString
3437
if (!queryString) continue
3538

@@ -39,7 +42,7 @@ export const GET: APIRoute = async ({ params }) => {
3942
networks.push({
4043
queryString,
4144
networkName: network.name,
42-
chain: network.chain || "",
45+
chain: typeof network.chain === "string" ? network.chain : "",
4346
networkType: network.networkType || "mainnet",
4447
})
4548
}

src/pages/data-feeds/feed-addresses/[type]/[network].txt.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { buildFeedAddressMarkdown, VALID_FEED_TYPES } from "~/features/feeds/uti
55
import { STREAM_CATEGORY_MAP } from "~/features/feeds/utils/streamMetadata.ts"
66
import type { DataFeedType } from "~/features/feeds/components/FeedList.tsx"
77

8-
// Reverse map: internal → public (streamsCrypto → crypto)
8+
// Reverse map: internal → public
99
const 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

4444
export 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

Comments
 (0)